2

I have the following linear models

library(nlme)
fm2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
fm2.lm <- lm(distance ~ age + Sex,data = Orthodont)

How can I obtain the standard error of distance with age and Sex?

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
ECII
  • 10,297
  • 18
  • 80
  • 121

2 Answers2

2

For fm2 (linear mixed model), you can do

sqrt(diag(summary(fm2)$varFix))
#(Intercept)         age   SexFemale 
# 0.83392247  0.06160592  0.76141685 

For fm2.lm (linear model), you can do

summary(fm2.lm)$coefficients[, "Std. Error"]
#(Intercept)         age   SexFemale 
# 1.11220946  0.09775895  0.44488623 
Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
0

see attributes(summary(your.model)). what you're after is summary(your.model)$coefficients (or did I get your question wrong?). just use subsetting with [] to get what you want

Sarunas
  • 341
  • 1
  • 10
  • No thats not what I mean. The coefficients show you the change of the mean of the outcome with the change in the independent variables. I want to get the **st.error of the outcome** at the various values of the dependent variables. Not the estimates (coefficients and st.errors of the independent variables. – ECII Mar 10 '14 at 10:37
  • wait. I'm puzzled. since you're not estimating dependent variable as a coefficient, isn't standard deviation that you're after? I mean, if I understand it correctly, you want to see what is the variance of distance with respect to different combination of age and sex. so you don't need to use regression to find this out. you need sample standard deviations for different combinations of age and sex, no? – Sarunas Mar 10 '14 at 12:01
  • @ECII; You can get st. errors of the predicted line ?predict. And http://glmm.wikidot.com/faq – user20650 Mar 10 '14 at 12:38