Modeling time trends with R (mixed model)

Viewed 38

I have a problem and just can't seem to solve it.

I have data from about 2000 different VPN. At four points in time I asked them about their state of mind ("Psychisch"). If I look at the different data in the scatter plot, you can see very well that there are very different progressions. As there are so many people I only look at about 50 at the same time, but they always seem to show different progressions (from negative, over no, to positive associations with time).

Now I first calculated an intercept only model and that worked well. Then I added the time factor as a covariate (first fixed). This model also worked.

If I now try to make the slopes for the time variable a random factor there is the following error message:

boundary (singular) fit: see help('isSingular') 

or

Error: number of observations (=6676) <= number of random effects (=6676) for term (1 + Zeit.n | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable 

depending on how I transform the time variable. Am I supposed to transform the time variable into a numeric or factor variable? I would have assumed factor, as it is just those four timepoints, but when I make it a factor I get another error message.

I already read through a lot of other posts about this problem, but can't seem to figure out why my dataset has that same problem. I have four observations per Person and I just want to look at the variance of the regression coefficients for time for each person. I'm sure that there is variance, so the estimated variance being very small doesn't make sense for me.

I can't figure out what I'm doing wrong. Can anyone help me out?

Here is my dataset: https://wetransfer.com/downloads/feba9b0316850cecf78dcb161a7c08ec20220307010300/4f9b39

and my syntax:

df <- read.csv2("Data.csv")
library(lmerTest)

colnames(df) <- c("id","ART","Zeit","Phy","Psy")

df$id <- as.factor(df$id)
df$Zeit.n <- as.factor(df$Zeit)
df$Psy.c <- scale(df$Psy,scale=F)


mod0 <- lmer(Psy.c ~ 1 + (1|id),data=df)
summary(mod0)


mod1 <- lmer(Psy.c ~ 1+Zeit + (1|id),df)
summary(mod1)


mod2 <- lmer(Psy.c ~ 1+Zeit + (1+Zeit|id),df)
summary(mod2)

mod3 <- lmer(Psy.c ~ 1+Zeit.n + (1+Zeit.n|id),df)

Kind regards!

0 Answers
Related