I have data for student test scores taken over many years as well as demographic and screening data (Emohealth
, memory
, and the dependent variable MathScore
changes for each year for each student). When I construct a longitudinal model in R, I'm not sure where to put certain variables.
I've built two models:
fit <- lme(MathScore~Year+White+Black+Hispanic+Male+Age+EmoHealth+Memory,
random=~Year|ID, data=df, na.action="na.omit")
fit2 <- lme(DState ~ Year+White+Black+Hispanic+Male+Age+EmoHealth+Memory,
random=~1|Year, data=df, na.action=na.omit, method='ML'))
What I don't understand is:
- Why does Rstudio
lme
code recommend I add the1+
to the variables? Do I need it? - Whether or not
fit2
is accounting forYear
andStudent ID
, or if it needs to do so. - I don't know how to indicate in the model that emotional health can change each year but being male cannot.