Here I made some longitudinal data. Variable result is biomarker level from patients. Variable visit represent visit labels. Variable time means days from baseline t1. There are two response status, 'yes' and 'no'. What I want to find out is whether there is any difference in biomarker level between responder and non-responder over the time-course.
I use linear mix model for the analysis.
#generate data
df = data.frame(result = rnorm(200)+2,
visit = rep(c('t1', 't2', 't3', 't4', 't5'), 40),
time = rep(c(0, 8, 14, 30, 60), 40),
response = rep(c('yes', 'no'), each=100),
id = rep(1:40, each=5) )
# run lme model
library(lme4)
library(lmerTest)
lmer(result~time*response+(1|id),data=df)
lmer(result~factor(visit)*response+(1|id), data=df)
lmer(result~factor(visit, ordered=TRUE)*response+(1|id), data=df)
My question is:
1. In this analysis,should I use time(continuous) or visit (factor)?
2. If I use visit(factor), should it be ordered or unordered?
Is there any guideline in terms of choosing what type time variable to use (factor vs continuous)?
thanks a lot.