Eric McKibben
2009-Sep-26 01:10 UTC
[R] renaming intercept column when retrieving coeficients from lme using coef function
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]]
jim holtman
2009-Sep-26 01:25 UTC
[R] renaming intercept column when retrieving coeficients from lme using coef function
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.ymyName 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?
Seemingly Similar Threads
- error in importing text files
- Using while statements to insert rows in a dataframe
- plotting lm coeficients with their means
- How to calculate Hightest Posterior Density (HPD) of coeficients in a simple regression (lm) in R?
- Coeficients estimation in a repeated measures linear model