Im migrating from SAS to R with a few difficulties, not to mention some large gaps in statistical knowledge.
Im investigating the effect of ethnicity on blood pressure, in a longitudinal study. For all ethnic groups, it is evident that their blood pressure declines the first 3-4 years and then it increases steadily thereafter (no other trend observed).
I have 100.000 observations, from 10.000 unique individuals. Data is heavily unbalanced; some individuals have 1 observation while others have 20. Observations are gathered at different time points.
Fixed covariates: age, sex, treatment, BMI, ethnicity. Random covariates: ethnicity Repeated measure unit: individual (ID).
How would You model this? I'm interested in the ethnic differences and must therefore have ethnicity as a fixed covariate. But ethnicity could be appreciated as a level in terms of multilevel models, and thus modeled as random in mixed models. Så my subjects are, if im not wrong, nested within ethnic groups.
I have read instruction manuals for both nlme package and lme4 package. I decided to go with lme4, despite non-linear trend in blood pressure but tried to adjust for this by taking the second polynomial of duration (time*time).
How would you model this? E.g:
lmer(hba1c_up ~ age + sex + (1|Ethnicityx/ID)) ? lmer(hba1c_up ~ age + sex + (1|ID) + (1|Ethnicityx))
Help would be immensely appreciated!