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.
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.alessandro at 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 at 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]]
> 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.alessandro at 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 at 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]]