Hello, Could somebody please tell me what am I doing wrong in following? I try extract coefficients (using arm-package) from the lmer frunction, but I get the following warning: a<-data.frame(coef(res)) Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class "coef.mer" into a data.fram I think I have done it before the same way and it has worked, but not any more.. Jukka
On Dec 31, 2010, at 2:49 AM, Jukka Koskela wrote:> Hello, > > Could somebody please tell me what am I doing wrong in following? > > I try extract coefficients (using arm-package) from the lmer > frunction, but I get the > following warning: > a<-data.frame(coef(res)) > Error in as.data.frame.default(x[[i]], optional = TRUE, > stringsAsFactors = stringsAsFactors) : > cannot coerce class "coef.mer" into a data.fram > > I think I have done it before the same way and it has worked, but > not any more..Are you sure you were not looking at just one particular element of a coef.mer object? > fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) > a<-data.frame(coef(fm1)) Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class '"coef.mer"' into a data.frame > coef(fm1) $Subject (Intercept) Days 308 253.6623 19.6665383 309 211.0067 1.8461362 310 212.4446 5.0170766 330 275.0971 5.6535771 <snipped> . . > a<-data.frame(coef(fm1)[[1]]) > a X.Intercept. Days 308 253.6623 19.6665383 309 211.0067 1.8461362 310 212.4446 5.0170766 330 275.0971 5.6535771 331 273.6664 7.3980095 <snipped> -- David Winsemius, MD West Hartford, CT
Thank you! This was exactly what I was looking for. Jukka Lainaus "David Winsemius" <dwinsemius at comcast.net>:> > On Dec 31, 2010, at 2:49 AM, Jukka Koskela wrote: > >> Hello, >> >> Could somebody please tell me what am I doing wrong in following? >> >> I try extract coefficients (using arm-package) from the lmer >> frunction, but I get the >> following warning: >> a<-data.frame(coef(res)) >> Error in as.data.frame.default(x[[i]], optional = TRUE, >> stringsAsFactors = stringsAsFactors) : >> cannot coerce class "coef.mer" into a data.fram >> >> I think I have done it before the same way and it has worked, but >> not any more.. > > Are you sure you were not looking at just one particular element of > a coef.mer object? > >> fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) > >> a<-data.frame(coef(fm1)) > Error in as.data.frame.default(x[[i]], optional = TRUE, > stringsAsFactors = stringsAsFactors) : > cannot coerce class '"coef.mer"' into a data.frame >> coef(fm1) > $Subject > (Intercept) Days > 308 253.6623 19.6665383 > 309 211.0067 1.8461362 > 310 212.4446 5.0170766 > 330 275.0971 5.6535771 > <snipped> > . > . > >> a<-data.frame(coef(fm1)[[1]]) >> a > X.Intercept. Days > 308 253.6623 19.6665383 > 309 211.0067 1.8461362 > 310 212.4446 5.0170766 > 330 275.0971 5.6535771 > 331 273.6664 7.3980095 > <snipped> > > -- > > David Winsemius, MD > West Hartford, CT > > >