1
$\begingroup$

I am working with a random intercept multilevel modeling.

I want to predict general health based on survey data. The survey uses nested data set on three levels: individual, county, and state.

I am working with predictor variables from all three levels. I want to make sure that I let the model know what level each of the variables are

age and diet are individual level

altitude is county level

pol.party and minimum.wage are state level

Here is my baseline model:

model1 <- lmer(health.outcome ~ 1 + age + diet + altitude + pol.party + minimum.wage +
(altitude|state:county) +
(altitude + pol.party + minimum.wage|state),
REML=FALSE,
                  data = df)
$\endgroup$
2
  • $\begingroup$ How is altitude measured? Is there a unique altitude per individual? Are there multiple values of minimum wage per state? How many political parties are there per state? $\endgroup$ Commented Aug 28 at 1:42
  • $\begingroup$ Altitude is measure by meters, it is a discreet variable. Altitude is measured by the county. Minimum wage is a state law applying to everyone in that state. Political parties is the party of the governor. THank you $\endgroup$ Commented Aug 29 at 0:12

1 Answer 1

0
$\begingroup$

In multilevel models, if you want a unique slope for a given level, you need to either center the variable around its higher-level mean or simply include the higher-level mean of that variable in the model. The coefficients for an uncentered variable measured at a lower level of the hierarchy provide a blended estimate that partially reflects their within- and between-level slope. In your case, the following would help give you what you are looking for:

library(dplyr)
# individual level variables centered around county means
df <- df %>% group_by(county) %>% 
          mutate(age_cmn = mean(age), 
                 diet_cmn = mean(diet)) %>% 
          ungroup() %>% 
                     mutate(age_cwc = age-age_cmn, 
                            diet_cwc = diet-diet_cmn)
# county variables centered around state means
df <- df %>% group_by(state) %>% 
          mutate(age_smn = mean(age), 
                 diet_smn = mean(diet),
                 altitude_smn = mean(altitude)) %>% 
          ungroup() %>% 
                     mutate(age_cws = age_cmn-age_smn,
                            diet_cws = diet_cmn-diet_smn,
                            altitude_cws = altitude-altitude_smn))
library(lme4)
m1 <- lmer(health.outcome ~ 1 + age_cwc + diet_cwc # level 1
         + altitude_cws + age_cws + diet_cws       # level 2
         + pol.party + minimum.wage + 
         (1|state:county) + (1|state), 
         REML=FALSE, data = df)

Note that I am assuming the random slopes were in your model because you thought that was how you tell lmer what level the variables were at. Instead, you have to do that by explicitly centering the variables or include the uncentered variables and their respective county and state means. The interpretation of the coefficients is different, however. See here for more details.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.