Good morning, i am looking for some help with longitudinal data with time-varying binary exposure in linear mixed model. Outcome is continuous variable. I am going to use R and the lme4 package. I want to identify association between time varying smoking status and hemoglobin A1c with random intercept and random slope.
Here is a sample dataset and R code that i conducted. Is this right analysis for my hypothesis?
id | smoking | HbA1c | visit |
---|---|---|---|
1 | 0 | 6.5 | 1 |
1 | 0 | 6.7 | 2 |
1 | 0 | 6.8 | 3 |
1 | 1 | 7 | 4 |
1 | 1 | 7.5 | 5 |
2 | 1 | 6.8 | 1 |
2 | 1 | 7.4 | 2 |
2 | 1 | 7.6 | 3 |
2 | 1 | 7.5 | 4 |
3 | 0 | 6.4 | 1 |
3 | 0 | 6.5 | 2 |
3 | 0 | 6.6 | 3 |
4 | 0 | 6.7 | 1 |
4 | 0 | 6.6 | 2 |
4 | 0 | 6.7 | 3 |
4 | 0 | 6.8 | 4 |
4 | 0 | 6.8 | 5 |
5 | 0 | 7 | 1 |
5 | 0 | 7 | 2 |
5 | 1 | 7 | 3 |
6 | 0 | 7.1 | 1 |
6 | 0 | 7 | 2 |
6 | 0 | 7.1 | 3 |
6 | 0 | 7.2 | 4 |
data1 <- read.xlsx("lmm_test.xlsx")
model1 <- lmer(a1c ~ smk + smk * visit + (visit | id), data = data1)
a <- tidy(model, conf.int = TRUE)
a %>% select(term, estimate, conf.low, conf.high)
# A tibble: 8 x 4
term estimate conf.low conf.high
smk -0.779 -1.22 -0.336
visit 0.0373 -0.0218 0.0964
smk:visit 0.268 0.160 0.377
When the results of the analysis are as above mentioned, can i interpret that glycated hemoglobin increases by 0.268 in the presence of smoking status over time (1 visit unit) than in the absence of smoking?