Re: [R] regression coefficients

2016-02-17 Thread William Dunlap via R-help
> mod_c <- aov(dv ~ myfactor_c + Error(subject/myfactor_c), data=mydata_c)
>
> summary.lm(mod_c)
> Error in if (p == 0) { : argument is of length zero>

You called the lm method for summary() on an object of class c("aovlist",
"listof").   You should not expect a method for one class to work on an
object of a different class.

coefficients(mod_c) will give you the coefficients of the 3 linear models
(including the intercept-only model) that aov fits.  Since an aovlist
object is a list of c("aov","lm") objects you can get the summaries of its
components with lapply(mod_c, summary).



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Feb 17, 2016 at 5:54 PM, Cristiano Alessandro <
cri.alessan...@gmail.com> wrote:

> Dear all,
>
> I am trying to visualize the regression coefficients of the linear model
> that the function aov() implicitly fits. Unfortunately the function
> summary.lm() throws an error I do not understand. Here is a toy example:
>
> dv <- c(1,3,4,2,2,3,2,5,6,3,4,4,3,5,6);
> subject <-
> factor(c("s1","s1","s1","s2","s2","s2","s3","s3","s3","s4","s4","s4","s5","s5","s5"));
> myfactor_c <-
> factor(c("f1","f2","f3","f1","f2","f3","f1","f2","f3","f1","f2","f3","f1","f2","f3"))
>
> mydata_c <- data.frame(dv, subject, myfactor)
>
> mod_c <- aov(dv ~ myfactor_c + Error(subject/myfactor_c), data=mydata_c)
>
> > summary.lm(mod_c)
> Error in if (p == 0) { : argument is of length zero
>
> Please note that the example is a within-subject design with factor
> myfactor_c.
>
> Any help is greatly appreciated.
>
> Best
> Cristiano
>
> PS. If this is a stupid question, I apologize. I am very new to R.
>
> __
> 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.


Re: [R] regression coefficients

2016-02-17 Thread Jim Lemon
Hi Cristiano,
Might be the data you have for "dv". I don't seem to get the problem.

dv<-sample(1:6,15,TRUE)
subject<-factor(rep(paste("s",1:5,sep=""),each=3))
myfactor_c<-factor(rep(paste("f",1:3,sep=""),5))
mydata_c<-data.frame(dv,subject,myfactor_c)
mod_c<-aov(dv~myfactor_c+Error(subject/myfactor_c),data=mydata_c)
mod_c

Call:
aov(formula = dv ~ myfactor_c + Error(subject/myfactor_c),
...

summary(mod_c)

Error: subject
  Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4   13.6 3.4

Error: subject:myfactor_c
 Df Sum Sq Mean Sq F value Pr(>F)
myfactor_c  2  8.133   4.067   1.196  0.351
Residuals   8 27.200   3.400

Jim



On Thu, Feb 18, 2016 at 12:54 PM, Cristiano Alessandro <
cri.alessan...@gmail.com> wrote:

> Dear all,
>
> I am trying to visualize the regression coefficients of the linear model
> that the function aov() implicitly fits. Unfortunately the function
> summary.lm() throws an error I do not understand. Here is a toy example:
>
> dv <- c(1,3,4,2,2,3,2,5,6,3,4,4,3,5,6);
> subject <-
> factor(c("s1","s1","s1","s2","s2","s2","s3","s3","s3","s4","s4","s4","s5","s5","s5"));
> myfactor_c <-
> factor(c("f1","f2","f3","f1","f2","f3","f1","f2","f3","f1","f2","f3","f1","f2","f3"))
>
> mydata_c <- data.frame(dv, subject, myfactor)
>
> mod_c <- aov(dv ~ myfactor_c + Error(subject/myfactor_c), data=mydata_c)
>
> > summary.lm(mod_c)
> Error in if (p == 0) { : argument is of length zero
>
> Please note that the example is a within-subject design with factor
> myfactor_c.
>
> Any help is greatly appreciated.
>
> Best
> Cristiano
>
> PS. If this is a stupid question, I apologize. I am very new to R.
>
> __
> 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] regression coefficients

2016-02-17 Thread Cristiano Alessandro

Dear all,

I am trying to visualize the regression coefficients of the linear model 
that the function aov() implicitly fits. Unfortunately the function 
summary.lm() throws an error I do not understand. Here is a toy example:


dv <- c(1,3,4,2,2,3,2,5,6,3,4,4,3,5,6);
subject <- 
factor(c("s1","s1","s1","s2","s2","s2","s3","s3","s3","s4","s4","s4","s5","s5","s5"));
myfactor_c <- 
factor(c("f1","f2","f3","f1","f2","f3","f1","f2","f3","f1","f2","f3","f1","f2","f3")) 


mydata_c <- data.frame(dv, subject, myfactor)

mod_c <- aov(dv ~ myfactor_c + Error(subject/myfactor_c), data=mydata_c)

> summary.lm(mod_c)
Error in if (p == 0) { : argument is of length zero

Please note that the example is a within-subject design with factor 
myfactor_c.


Any help is greatly appreciated.

Best
Cristiano

PS. If this is a stupid question, I apologize. I am very new to R.

__
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] Regression coefficients

2013-04-26 Thread Jeff Newmiller
?coef

There are many introductory texts on R... I recommend getting a few.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Preetam Pal  wrote:

>Hi all,
>
>I have run a ridge regression as follows:
>
>reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$g+final$u,
>lambda=seq(0,10,0.01))
>
>Then I enter :
>
>select(reg)   and it returns: modified HKB estimator is 19.3409
> modified L-W estimator is 36.18617
>   smallest value of GCV  at 10
>
>I think it means that it is advisable to use the results of regression
>corresponding to lambda= 10;
>so the next thing I do is:
>
>reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$u, lambda=10)
>
>which yields:
>
> final$lag1final$lag2   final$g
>final$u
> 3.147255e-04  1.802505e-01 -4.461005e-02 -1.728046e-09 -5.154932e-04
>
>
>If I am to use these coefficient values later in my analysis, how do I
>call
>them; for clearly reg$final$lag1  does not work.
>
>1> Any way I can access these values?
>
>2> The main issue is that I want to access these coefficient values
>automatically, i.e. R should run the regression and automatically
>provide
>me these values after taking into consideration that lambda which
>minimizes
>the GCV.   Kindly advise me how I can proceed.
>
>
>Thanks and regards,
>Preetam

__
R-help@r-project.org mailing list
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] Regression coefficients

2013-04-26 Thread Preetam Pal
Hi all,

I have run a ridge regression as follows:

reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$g+final$u,
lambda=seq(0,10,0.01))

Then I enter :

select(reg)   and it returns: modified HKB estimator is 19.3409
   modified L-W estimator is 36.18617
   smallest value of GCV  at 10

I think it means that it is advisable to use the results of regression
corresponding to lambda= 10;
so the next thing I do is:

reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$u, lambda=10)

which yields:

 final$lag1final$lag2   final$g
final$u
 3.147255e-04  1.802505e-01 -4.461005e-02 -1.728046e-09 -5.154932e-04


If I am to use these coefficient values later in my analysis, how do I call
them; for clearly reg$final$lag1  does not work.

1> Any way I can access these values?

2> The main issue is that I want to access these coefficient values
automatically, i.e. R should run the regression and automatically provide
me these values after taking into consideration that lambda which minimizes
the GCV.   Kindly advise me how I can proceed.


Thanks and regards,
Preetam

-- 
Preetam Pal
(+91)-9432212774
M-Stat 2nd Year, Room No. N-114
Statistics Division,   C.V.Raman
Hall
Indian Statistical Institute, B.H.O.S.
Kolkata.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.