[R] renaming intercept column when retrieving coeficients from lme using coef function

jim holtman jholtman at gmail.com
Sat Sep 26 03:25:01 CEST 2009


Is this what you want:

> coef.y
  (Intercept)
1  0.03109602
2  0.03109602
3  0.03109603
4  0.03109602
> str(coef.y)
Classes ‘coef.lme’, ‘ranef.lme’ and 'data.frame':       4 obs. of  1 variable:
 $ (Intercept): num  0.0311 0.0311 0.0311 0.0311
 - attr(*, "level")= int 1
 - attr(*, "label")= chr "Coefficients"
 - attr(*, "effectNames")= chr "(Intercept)"
 - attr(*, "standardized")= logi FALSE
 - attr(*, "grpNames")= chr "ID"
> names(coef.y) <- 'myName'
> coef.y
      myName
1 0.03109602
2 0.03109602
3 0.03109603
4 0.03109602
>


On Fri, Sep 25, 2009 at 9:10 PM, Eric McKibben <EMcKibb at clemson.edu> wrote:
> I am still fairly new to R and have a fairly rudimentary question.  I am
> trying to name a vector of coefficients retrieved from a multilevel model
> using the coef function.  I guess the default name is "Intercept" and I
> cannot figure out how to rename it.
>
>
>
> I have tried the using the code below to name the column of coefficients
> ind.y derived from an lme model.  Unfortunately, the name ind.y is not
> applied to the column.  What can I do to name the column?
>
>
>
> toy<-data.frame(ID=c(1,1,1,2,2,2,3,3,3,4,4,4), x=rnorm(12), y=rnorm(12))
>
>> model.toy<-lme(y~1, random=~1|ID, data=toy)
>
>> coef.y<-("ind.y"=coef(model.toy))
>
>> coef.y
>
>  (Intercept)
>
> 1  0.52065015
>
> 2  0.04066776
>
> 3  0.29793571
>
> 4  0.11213693
>
>
>
> Thanks,
>
>
>
> Eric McKibben
>
> Doctoral Candidate
>
> I-O Psychology
>
> Clemson University
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list