[R] regression coefficients

William Dunlap wdunlap at tibco.com
Thu Feb 18 06:16:11 CET 2016


> 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]]



More information about the R-help mailing list