Checking and accounting for autocorrelation in lcmm package R

20 Views Asked by At

I need to check for autocorrelation and if in existence account for such in a Latent Class Mixture Model fitted using the lcmm package in R.

I have fit a latent class mixture model on some population data using the lcmm package in R as follows. Model gmm1_b represents a 1-class GMM allowing for both random intercepts and slopes and gmm2_b the two-class model. Data represents Value as a dependent variable (continuous numeric variable ranging from 4.1 to 16.2) and jrtime as a time variable (1:13). There are 150 individuals within the study (identified by ID), with the total dataframe consisting of 1950 observations in total.

gmm1_b <- hlme(Value ~ jrtime, subject = "ID", random=~jrtime, ng = 1, data = rec)

gmm2_b <- gridsearch(rep = 1500, maxiter = 100, minit = gmm1_b, hlme(Value ~ jrtime, subject = "ID", random=~jrtime, ng = 2, data = rec, mixture = ~ jrtime,nwg=T))

After fitting the model I need to check for the existence of autocorrelation and have done so by adapting a similar approach to that which I would use for any other regression based upon ACF plots:

# Extract residuals from the model
residuals <- residuals(gmm2_b)

# Check autocorrelation of residuals using ACF
acf_res <- acf(residuals, lag.max = 13, main = "ACF of Residuals")

plot(acf_res)

pacf_res <- pacf(residuals, lag.max = 13, main = "ACF of Residuals")

plot(pacf_res)

I wanted advice as to whether the above was the right approach when using latent class mixture models? The outcome suggests the existence of autocorrelation as shown in the below image:

ACF plot

If the autocorrelation method is correct, is there a way of accounting for such by adjusting the initial code?

0

There are 0 best solutions below