0
$\begingroup$

I'm new to MLM both in R and in general. I have a dataset of Building permits for a couple of cities and I have created a variable counting the number of parcels with a permit. Now, I want to perform a MLM to see if there is a census tract (a geographic level) effect going on. Here's where I hit a problem. When writing this line:

lmer(PERMITS ~ 1 + howeownership + (1 | CITY), data = dt2, REML = FALSE) Do I need to also include census tract variable? If not, how would R know that my levels are CITY>>CT>>PERMITS (which is really the outcome)?

P.S. Home ownership is a variable in the census tracts. It is defined as the proportion of poeple being home owners in each tract.

$\endgroup$
2
  • $\begingroup$ Can you share the data? $\endgroup$ Commented Feb 19, 2020 at 20:23
  • $\begingroup$ Is this a programming question? Search for nested random effects. $\endgroup$
    – Firebug
    Commented Feb 19, 2020 at 20:30

1 Answer 1

1
$\begingroup$

For multilevel models, which usually model longitudinal/hierarchical structures, we still need to have a design matrix in order to fit the model (either by MLE, RMLE or GLS).

Looking at your code, the design matrix build by the formula you pass onto lmer will not contain any information about CT apparently. The formula should be something like:

lmer(PERMITS ~ 1 + howeownership + (1 |CT/CITY), data = dt2, REML = FALSE)
$\endgroup$
3
  • $\begingroup$ Thank you! I didn't think of that. Is this code conceptually the same as lmer(PERMITS ~ 1 + howeownership + (1 |CITY) + (1 |CT), data = dt2, REML = FALSE)? $\endgroup$
    – Kawi
    Commented Feb 19, 2020 at 21:40
  • $\begingroup$ Nope, those are non nested groups. To picture this, think of the hierarchical structure of states, within a county, within a city as compared to counties that have schools that have teachers when a teacher can teach in multiple schools, and then has to be modelled in a non nested manner, since a teacher can teach in many schools. $\endgroup$ Commented Feb 19, 2020 at 21:53
  • $\begingroup$ @Sani, those two formulations can produce the same output, however, if you have coded your data correctly. See bbolker.github.io/mixedmodels-misc/… for more information. $\endgroup$
    – Erik Ruzek
    Commented Feb 20, 2020 at 13:11

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.