Re: [R] Optimisation with Normalisation Constraint

2018-06-20 Thread David Winsemius


> On Jun 20, 2018, at 8:50 AM, Lorenzo Isella  wrote:
> 
> Dear All,
> I have a problem I haver been struggling with for a while: I need to
> carry out a non-linear fit (and this is the
> easy part).
> I have a set of discrete values {x1,x2...xN} and the corresponding
> {y1, y2...yN}. The difficulty is that I would like the linear fit to
> preserve the sum of the values y1+y2+...yN.
> I give an example below (for which there may even be an analytical
> solution, but that is not the point here)
> 
> 
> library(minpack.lm)
> 
> 
> 
> set.seed(124)
> 
> z <- rexp(3000,3)
> 
> 
> zf <- z[z<= 0.5 | z>=0.9]
> 
> myhist <- hist(zf, plot=FALSE) 
> 
> 
> df <- data.frame(x=myhist$mids, y=myhist$density)
> 
> 
> 
> myfit <- nlsLM(y~(A*exp(-lambda*x))
>   ,data=df, start=list(A=1,lambda=1))
> 
> 
> 
>> sum(myhist$density)
> [1] 5
>> sum(predict(myfit))
> [1] 4.931496
> 
> 
> I would like sum(predict(myfit)) to be exactly 5 from the start,
> without renormalising a posteriori the fit.

Wouldn't that happen if you minimized that absolute deviations from the fit 
rather than minimizing the sums of squares??
> 
> Any suggestion is appreciated.
> Cheers
> 
> Lorenzo
> 

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Optimisation with Normalisation Constraint

2018-06-20 Thread Jeff Newmiller
I recommend posting this on a mathematics discussion forum like Stack Exchange 
and (re-)reading the Posting Guide for this mailing list.

I think you are going to need to re-write your model function to algebraically 
combine your original model along with the constraint, and then use the 
original model alone for prediction... but I haven't tried it so might be quite 
far off the mark.

On June 20, 2018 8:50:48 AM PDT, Lorenzo Isella  
wrote:
>Dear All,
>I have a problem I haver been struggling with for a while: I need to
>carry out a non-linear fit (and this is the
>easy part).
>I have a set of discrete values {x1,x2...xN} and the corresponding
>{y1, y2...yN}. The difficulty is that I would like the linear fit to
>preserve the sum of the values y1+y2+...yN.
>I give an example below (for which there may even be an analytical
>solution, but that is not the point here)
>
>
>library(minpack.lm)
>
>
>
>set.seed(124)
>
>z <- rexp(3000,3)
>
>
>zf <- z[z<= 0.5 | z>=0.9]
>
>myhist <- hist(zf, plot=FALSE) 
>
>
>
>df <- data.frame(x=myhist$mids, y=myhist$density)
>
>
>
>myfit <- nlsLM(y~(A*exp(-lambda*x))
>,data=df, start=list(A=1,lambda=1))
>
>
>
>> sum(myhist$density)
>[1] 5
>> sum(predict(myfit))
>[1] 4.931496
>
>
>I would like sum(predict(myfit)) to be exactly 5 from the start,
>without renormalising a posteriori the fit.
>
>Any suggestion is appreciated.
>Cheers
>
>Lorenzo
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Any Unsupervised Learning Algorithm for Time Series Forecasting in R

2018-06-20 Thread Hasan Diwan
Paul,

On Wed, 20 Jun 2018 at 09:04, Paul Bernal  wrote:
> I would like to know if R has any unsupervised algorithm to generate 
> forecasts for historical data.

Yes , it does. Perhaps you'd be kind enough to provide a sample of
your data --dput(sample(pauls.data)) on gist.github.com -- and what
you wish to achieve with it? Many thanks! -- H
-- 
OpenPGP: https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.
Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.

Sent from my mobile device
Envoye de mon portable

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Any Unsupervised Learning Algorithm for Time Series Forecasting in R

2018-06-20 Thread Bert Gunter
... and II should have added that the "forecast" package may be what you're
looking for.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Jun 20, 2018 at 9:30 AM, Bert Gunter  wrote:

> Depending on exactly what you mean by"unsupervised", many.
>
> See here under "Decomposition and filtering":
>
> https://cran.r-project.org/web/views/TimeSeries.html
>
> You could also search on something like "smooth time series R" etc.
>
> However, assuming I have correcty interpreted "unsupervised algorithm," be
> aware that extrapolating from such smoothed historical data can be
> problematic precisely because no structure/model has been specified. See
> here for some further background and R functions:
>
> http://a-little-book-of-r-for-time-series.readthedocs.io/en/
> latest/src/timeseries.html#holt-winters-exponential-smoothing
>
>
> Cheers,
> Bert
>
>
>
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Wed, Jun 20, 2018 at 9:00 AM, Paul Bernal 
> wrote:
>
>> Dear friends,
>>
>> Hope you are all doing great. I would like to know if R has any
>> unsupervised algorithm to generate forecasts for historical data.
>>
>> Any help will be greatly appreciated,
>>
>> Best regards,
>>
>> Paul
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Any Unsupervised Learning Algorithm for Time Series Forecasting in R

2018-06-20 Thread Bert Gunter
Depending on exactly what you mean by"unsupervised", many.

See here under "Decomposition and filtering":

https://cran.r-project.org/web/views/TimeSeries.html

You could also search on something like "smooth time series R" etc.

However, assuming I have correcty interpreted "unsupervised algorithm," be
aware that extrapolating from such smoothed historical data can be
problematic precisely because no structure/model has been specified. See
here for some further background and R functions:

http://a-little-book-of-r-for-time-series.readthedocs.io/en/latest/src/timeseries.html#holt-winters-exponential-smoothing


Cheers,
Bert






Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Jun 20, 2018 at 9:00 AM, Paul Bernal  wrote:

> Dear friends,
>
> Hope you are all doing great. I would like to know if R has any
> unsupervised algorithm to generate forecasts for historical data.
>
> Any help will be greatly appreciated,
>
> Best regards,
>
> Paul
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Any Unsupervised Learning Algorithm for Time Series Forecasting in R

2018-06-20 Thread Paul Bernal
Dear friends,

Hope you are all doing great. I would like to know if R has any
unsupervised algorithm to generate forecasts for historical data.

Any help will be greatly appreciated,

Best regards,

Paul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Optimisation with Normalisation Constraint

2018-06-20 Thread Lorenzo Isella

Dear All,
I have a problem I haver been struggling with for a while: I need to
carry out a non-linear fit (and this is the
easy part).
I have a set of discrete values {x1,x2...xN} and the corresponding
{y1, y2...yN}. The difficulty is that I would like the linear fit to
preserve the sum of the values y1+y2+...yN.
I give an example below (for which there may even be an analytical
solution, but that is not the point here)


library(minpack.lm)



set.seed(124)

z <- rexp(3000,3)


zf <- z[z<= 0.5 | z>=0.9]

myhist <- hist(zf, plot=FALSE) 




df <- data.frame(x=myhist$mids, y=myhist$density)



myfit <- nlsLM(y~(A*exp(-lambda*x))
   ,data=df, start=list(A=1,lambda=1))




sum(myhist$density)

[1] 5

sum(predict(myfit))

[1] 4.931496


I would like sum(predict(myfit)) to be exactly 5 from the start,
without renormalising a posteriori the fit.

Any suggestion is appreciated.
Cheers

Lorenzo

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R-es] Paquete dismo, cálculo coeficiente de variación

2018-06-20 Thread Marcelino de la Cruz Rot

Hola Jaume:

Lo más rápido para ver el código, al ser un método S4 es escribir:

 findMethods(biovars)

La descripción de la función (con las definiciones y comentarios si los 
tuviese) los tendrías que ver rebuscando en el código fuente del 
paquete. Generalmente  en la carpeta "R" del paquete con el código 
fuente comprimido (dismo_1.1-4.tar.gz) que puedes encontrar en CRAN 
(https://cran.r-project.org/src/contrib/dismo_1.1-4.tar.gz) o en este 
caso, directamente desde su página de Github 
(https://github.com/cran/dismo/blob/master/R/biovars.R).



Un saludo,

Marcelino


El 19/06/2018 a las 23:22, Jaume Tormo escribió:

Hola Jorge y Marcelino,

Muchas gracias a los dos.
Para futuras dudas ¿Cómo puedo mirar el código y la definición de una 
función?


Gracias de nuevo.

Jaume.

El 19 de junio de 2018, 13:16, Jorge Virto > escribió:


Hola,

en la misma definición de la función:

# P15. Precipitation Seasonality(Coefficient of Variation)

# the "1 +" is to avoid strange CVs for areas where mean rainfaill
is < 1)

p[,15] <- apply(prec+1, 1, cv)

Un saludo,

Jorge

On Martes, 19 de Junio de 2018 13:07:27 Marcelino de la Cruz Rot
escribió:

> Hola Jaume:

>

> Si miras el código de biovars() verás que la variable bio15 (el

> coeficiente de variación de la precipitación) la obtiene sumando

> previamente 1 a "prec":

>

> p[, 15] <- apply(prec + 1, 1, cv)

>

>

> Es decir, en tu caso,

>

> > cv(prec+1)

>

> [1] 109.9637

>

> Lo que coincide con lo proporcionado por biovars, mientras que

>

> > cv(prec)

>

> [1] 112.5923

>

>  coincide con tu cálculo manual.

>

> En la página web de WorldClim, donde definieron originalmente esta

> variable no he encontrado una explicación de este sumatorio, pero

> tampoco he buscado mucho...Tal vez en alguno de los artículos en
los que

> se describe esta base de datos den razón de este sumatorio.

>

> Saludos,

>

> Marcelino

>

> El 19/06/2018 a las 11:43, Jaume Tormo escribió:

> > Estimados erreros,

> >

> > Estoy intentando entender como calcula el paquete dismo (

> > https://cran.r-project.org/web/packages/dismo/index.html
) un
coeficiente

> > de

> > variación. Os pongo un ejemplo:

> > tmin <- c(10,12,14,16,18,20,22,21,19,17,15,12) # temperatura
mínima media

> > mensual de un año

> > tmax <- tmin + 5 # temperatura máxima media mensual de un año

> > prec <- c(0,2,10,30,80,160,80,20,40,60,20,0) #precipitación
media mensual

> > de un año

> > biovars(prec, tmin, tmax) #este comando calcula una serie de
variables

> > relevantes para la distribución de especies.

> >

> > #El resultado es:

> > bio1 bio2 bio3 bio4 bio5 bio6 bio7 bio8 bio9 bio10

> >

> > bio11

> > [1,] 18.8 5 29.41176 384.5501 27 10 17 22.5 13.8 23.5

> > 13.8

> >

> > bio12 bio13 bio14 *bio15* bio16 bio17 bio18 bio19

> >

> > [1,] 502 160 0 *109.9637* 320 2 260 2

> >

> > La que a mi me interesa es bio15 el coeficiente de variación de la

> >

> > precipitación, pero no me da lo que yo esperaba que me diera:

> >> (sd(prec)/mean(prec))*100

> >

> > [1] *112.5923*

> >

> > ¿Hay otra forma de calcular el Coeficiente de variación? Me estoy

> > perdiendo

> > algo. En el manual del paquete (

> > https://cran.r-project.org/web/packages/dismo/dismo.pdf
), no
explica como

> > calcula el indice de variación ¿Hay alguna forma de rebuscar
en dentro de

> > biovars para saber que está haciendo?

> >

> > Muchas gracias.

-- 


--

Jorge Virto Moreno

Dpt. Economia Aplicada III

Facultad de Economía y Empresa UPV-EHU

Avda. Lehendakari Agirre, 83

48015 Bilbao

Spain

Tel: 94 601 3851

Fax: 94 601 3754

eman ta zabal zazu

_ _

| \___ |___\-\_

| ___] __ | |

| [_ __ [_ |_| |

|__ _] [_ |___] /

| [_ | __/

|___ \__| |

| |

|__|

Universidad del País Vasco

Euskal Herriko Unibertsitatea




--
Jaume Tormo.
https://es.linkedin.com/in/jaumetormo
https://acercad.wordpress.com/



--
Marcelino de la Cruz Rot
Depto. de Biología y Geología
Física y Química Inorgánica
Universidad Rey Juan Carlos
Móstoles España

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Gabor Grothendieck
If you specifically want to know which packages were loaded by the script
then using a vanilla version of R (i.e. one where only base packages are
loaded):

  vanilla_search <- search()
  source("myRprg.R")
  setdiff(search(), vanilla_search)



On Wed, Jun 20, 2018 at 4:08 AM, Sigbert Klinke
 wrote:
> Hi,
>
> I have read an R program with
>
> expr <- parse("myRprg.R")
>
> How can I extract the parameters of a specifc R command, e.g. "library"?
>
> So, if myprg.R containes the lines
>
> library("xyz")
> library("abc")
>
> then I would like to get "xyz" and "abc" back from expr.
>
> Thanks in advance
>
> Sigbert
>
> --
> https://hu.berlin/sk
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] interpret a p-value result as a significance of a linear regression in terms of sigmas

2018-06-20 Thread Peter Dalgaard
Sorry to say so, but you seem confused. 

The "sigma" in physics parlance is presumably the s.e. of the estimate so the 
"number of sigmas" equal the t statistic, in this case 5.738. However, use of 
that measure ignores the t distribution, effectively assuming that there are 
infinite df (and 24 in not quite infinite). 

- pd

> On 20 Jun 2018, at 12:53 , jean-philippe  
> wrote:
> 
> dear R community,
> 
> I am running a linear regression for my dataset between 2 variables (disk 
> mass and velocities).
> This is the result returned by the summary function onto the lm object for 
> one of my dataset.
> 
> Call:
> lm(formula = df$md1 ~ df$logV, data = df)
> 
> Residuals:
> Min   1Q   Median   3Q  Max
> -0.64856 -0.16492  0.04127  0.18027  0.45727
> 
> Coefficients:
>Estimate Std. Error t value Pr(>|t|)
> (Intercept)   6.2582 0.2682  23.333  < 2e-16 ***
> df$logV   1.2926 0.2253   5.738  6.5e-06 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> Residual standard error: 0.3067 on 24 degrees of freedom
> Multiple R-squared:  0.5784,Adjusted R-squared:  0.5609
> F-statistic: 32.93 on 1 and 24 DF,  p-value: 6.504e-06
> 
> 
> I am interested to give the significance in terms of sigmas (as generally 
> done in particle physics, see for instance the 7 \sigma discovery of the 
> Higgs particle)
> of my regression.
> For this, if I understood well, I should look at the p-value for the 
> F-statistic which is in this univariate linear regression the same as the one 
> for logV.
> 
> My question is, am I right if I state that the significance in terms of 
> sigmas (sign) is given by: p = 2*(1-pnorm(sign)) since I guess the p-value 
> returned by R is for a two sided test (and assuming Gaussianity for my 
> dataset)?
> 
> Otherwise is there any way to get the significance of this linear regression 
> in terms of sigmas?
> 
> I would have a similar question also, as extension, for a multivariate linear 
> regression for which the p-value associated to F statistics is not the same 
> as the p-value for each variable of the regression.
> 
> 
> 
> Thanks in advance,
> 
> 
> Best Regards
> 
> 
> Jean-Philippe Fontaine
> 
> -- 
> Jean-Philippe Fontaine
> PhD Student in Astroparticle Physics,
> Gran Sasso Science Institute (GSSI),
> Viale Francesco Crispi 7,
> 67100 L'Aquila, Italy
> Mobile: +393487128593, +33615653774
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] interpret a p-value result as a significance of a linear regression in terms of sigmas

2018-06-20 Thread Duncan Murdoch

On 20/06/2018 6:53 AM, jean-philippe wrote:

dear R community,

I am running a linear regression for my dataset between 2 variables
(disk mass and velocities).
This is the result returned by the summary function onto the lm object
for one of my dataset.

Call:
lm(formula = df$md1 ~ df$logV, data = df)

Residuals:
   Min   1Q   Median   3Q  Max
-0.64856 -0.16492  0.04127  0.18027  0.45727

Coefficients:
  Estimate Std. Error t value Pr(>|t|)
(Intercept)   6.2582 0.2682  23.333  < 2e-16 ***
df$logV   1.2926 0.2253   5.738  6.5e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.3067 on 24 degrees of freedom
Multiple R-squared:  0.5784,Adjusted R-squared:  0.5609
F-statistic: 32.93 on 1 and 24 DF,  p-value: 6.504e-06


I am interested to give the significance in terms of sigmas (as
generally done in particle physics, see for instance the 7 \sigma
discovery of the Higgs particle)
of my regression.
For this, if I understood well, I should look at the p-value for the
F-statistic which is in this univariate linear regression the same as
the one for logV.


The t value is probably what you want, but I think you'll have to ask 
your supervisor for the definition used in your area.


Duncan Murdoch



My question is, am I right if I state that the significance in terms of
sigmas (sign) is given by: p = 2*(1-pnorm(sign)) since I guess the
p-value returned by R is for a two sided test (and assuming Gaussianity
for my dataset)?

Otherwise is there any way to get the significance of this linear
regression in terms of sigmas?

I would have a similar question also, as extension, for a multivariate
linear regression for which the p-value associated to F statistics is
not the same as the p-value for each variable of the regression.



Thanks in advance,


Best Regards


Jean-Philippe Fontaine



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Bert Gunter
... or if the argument is just quoted text or a numeric value as in your
library() example, don't parse the text and use regex's to search for the
function call and pick out the text of the arguments.

Again, this only works (I think) for the simple sort of case of your
example. Beyond that, you'll have to follow Hadley's prescription.

Cheers,
Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Jun 20, 2018 at 1:26 AM, Hadley Wickham  wrote:

> You need to recursively walk the parse tree/AST. See, e.g.,
> https://adv-r.hadley.nz/expressions.html#ast-funs
>
> Hadley
>
> On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke
>  wrote:
> > Hi,
> >
> > I have read an R program with
> >
> > expr <- parse("myRprg.R")
> >
> > How can I extract the parameters of a specifc R command, e.g. "library"?
> >
> > So, if myprg.R containes the lines
> >
> > library("xyz")
> > library("abc")
> >
> > then I would like to get "xyz" and "abc" back from expr.
> >
> > Thanks in advance
> >
> > Sigbert
> >
> > --
> > https://hu.berlin/sk
> >
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> http://hadley.nz
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] interpret a p-value result as a significance of a linear regression in terms of sigmas

2018-06-20 Thread jean-philippe

dear R community,

I am running a linear regression for my dataset between 2 variables 
(disk mass and velocities).
This is the result returned by the summary function onto the lm object 
for one of my dataset.


Call:
lm(formula = df$md1 ~ df$logV, data = df)

Residuals:
 Min   1Q   Median   3Q  Max
-0.64856 -0.16492  0.04127  0.18027  0.45727

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   6.2582 0.2682  23.333  < 2e-16 ***
df$logV   1.2926 0.2253   5.738  6.5e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.3067 on 24 degrees of freedom
Multiple R-squared:  0.5784,Adjusted R-squared:  0.5609
F-statistic: 32.93 on 1 and 24 DF,  p-value: 6.504e-06


I am interested to give the significance in terms of sigmas (as 
generally done in particle physics, see for instance the 7 \sigma 
discovery of the Higgs particle)

of my regression.
For this, if I understood well, I should look at the p-value for the 
F-statistic which is in this univariate linear regression the same as 
the one for logV.


My question is, am I right if I state that the significance in terms of 
sigmas (sign) is given by: p = 2*(1-pnorm(sign)) since I guess the 
p-value returned by R is for a two sided test (and assuming Gaussianity 
for my dataset)?


Otherwise is there any way to get the significance of this linear 
regression in terms of sigmas?


I would have a similar question also, as extension, for a multivariate 
linear regression for which the p-value associated to F statistics is 
not the same as the p-value for each variable of the regression.




Thanks in advance,


Best Regards


Jean-Philippe Fontaine

--
Jean-Philippe Fontaine
PhD Student in Astroparticle Physics,
Gran Sasso Science Institute (GSSI),
Viale Francesco Crispi 7,
67100 L'Aquila, Italy
Mobile: +393487128593, +33615653774

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Extract function parameters from a R expression

2018-06-20 Thread Hadley Wickham
You need to recursively walk the parse tree/AST. See, e.g.,
https://adv-r.hadley.nz/expressions.html#ast-funs

Hadley

On Wed, Jun 20, 2018 at 10:08 AM, Sigbert Klinke
 wrote:
> Hi,
>
> I have read an R program with
>
> expr <- parse("myRprg.R")
>
> How can I extract the parameters of a specifc R command, e.g. "library"?
>
> So, if myprg.R containes the lines
>
> library("xyz")
> library("abc")
>
> then I would like to get "xyz" and "abc" back from expr.
>
> Thanks in advance
>
> Sigbert
>
> --
> https://hu.berlin/sk
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
http://hadley.nz

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Extract function parameters from a R expression

2018-06-20 Thread Sigbert Klinke

Hi,

I have read an R program with

expr <- parse("myRprg.R")

How can I extract the parameters of a specifc R command, e.g. "library"?

So, if myprg.R containes the lines

library("xyz")
library("abc")

then I would like to get "xyz" and "abc" back from expr.

Thanks in advance

Sigbert

--
https://hu.berlin/sk


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.