Search code examples
rlmr-mice

where is the factor(age)20-39 in a data(nhanes2)?


I did imputation using mice from the mice package.

Then I used the function 'summary' to see the result of linear regression.

I can see the factor(age)40-59 and factor(age)60-99.

But I can't find the factor(age)20-39 from the result.

Can I know the reason?

I think the factor(age)20-39 is not linear model. Am I right?

library(mice)

data("nhanes2")

attach(nhanes2)

nhanes2.lm <- lm(chl~factor(age)+bmi, data=nhanes2)

summary(nhanes2.lm)

Solution

  • The age group 20-39 is the reference group in your model. So the summary gives you the effect of being in the other age groups. You can relevel your model if another group should be reference group.

    nhanes2$factorage<-factor(nhanes2$age)
    levels(nhanes2$factorage)
    nhanes2$factorage<-relevel(nhanes2$factorage, ref="60-99")
    nhanes2.lm <- lm(chl~factorage+bmi, data=nhanes2)
    
    summary(nhanes2.lm)