2
$\begingroup$

I am new to mixed effects modelling and I am trying to predict depression from physical activity using mixed effects modelling / multi-level modelling. The data consists of timepoints in months (7 months), so each month there is a different value for depression and physical activity (below). When adding activity as the time-varying predictor, the model predictions become non-linear. Is this supposed to happen?

   country Month depression  activity
1       20     0  -6.552636  0.000000
2       20     1  -5.499386  0.000000
3       20     2  -6.766055 10.129032
4       20     3  -5.396426 17.000000
5       20     4  -3.647919 17.000000
6       20     5  -4.616490 16.466667
7       20     6  -3.686440 16.000000
8        3     0  -7.449156  0.000000
9        3     1  -4.847658  0.000000
10       3     2  -7.860457  7.387097
11       3     3  -6.819432 15.000000
12       3     4  -5.227588 15.000000
13       3     5  -4.867199 14.700000
14       3     6  -3.627923 14.000000

Below is my model specification in r nlme:

# basic growth model to account for effects of time
model = lme(depression ~ Month, random=~1|country, data=df, method='ML', na.action=na.exclude) 

# adding activity as a time-varying predictor
model2 = lme(depression ~ Month + activity, random=~1|country, data=df, method='ML', na.action=na.exclude)

Results:

summary(model2)

Linear mixed-effects model fit by maximum likelihood
 Data: df 
       AIC      BIC    logLik
  709.7921 724.5003 -349.8961

Random effects:
 Formula: ~1 | country
        (Intercept) Residual
StdDev:    1.615538 2.692369

Fixed effects: depression ~ Month + activity 
                Value Std.Error  DF    t-value p-value
(Intercept) -8.067505 0.5647178 118 -14.285905       0
Month        1.016504 0.1451743 118   7.001952       0
activity    -0.295092 0.0507493 118  -5.814699       0
 Correlation: 
         (Intr) Month 
Month    -0.358       
activity -0.206 -0.610

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-4.0076454 -0.4664691  0.0966998  0.5998769  1.9300630 

Number of Observations: 140
Number of Groups: 20 

Predictions from model1 and model2:

df <- df %>% mutate(model = predict(model), model2 = predict(model2))
df %>% filter(country %in% c(20,19,18,17)) %>% 
       ggplot(aes(x=Month, y=depression)) + 
       geom_point(aes(color=country)) + 
       geom_line(aes(y=model2, color=country)) + 
       geom_line(aes(y=model, color=country), linetype='longdash') + 
       facet_wrap(~ country, ncol=2)

enter image description here

The dashed line is prediction from model1 and solid line is the predictions from model2 (with activity as time-varying predictor). My question is:

  1. Does adding a level 1 time-varying predictor make the model non-linear?'
  2. Can I interpret the coefficient for activity the same way as a linear model? Meaning 1 unit increase in activity is associated with a decrease in -0.295 unit decrease in depression?
$\endgroup$
2
  • 2
    $\begingroup$ Why do you think the model is non linear ? and plesse include the code you used to create the plots $\endgroup$ Oct 5, 2020 at 5:04
  • $\begingroup$ The predictions from model 1 (dashed lines) are linear (straight line) while those from model 2 are not. Does this imply non-linearity? $\endgroup$
    – TYL
    Oct 5, 2020 at 7:45

1 Answer 1

1
$\begingroup$

Does adding a level 1 time-varying predictor make the model non-linear?'

No, the model is a linear model - this means that it is linear in the parameters. Of course, it is perfectly normal to model non-linear associations with a linear model. There is no reason to expect that the predictions will lie on a straight line after you introduce another variable.

Can I interpret the coefficient for activity the same way as a linear model? Meaning 1 unit increase in activity is associated with a decrease in -0.295 unit decrease in depression?

Yes, while leaving the other variable unchanged.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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