1

I am working with longitudinal continuous data that reflect the linguistic abilities of children. In that regard I seek to make a Latent Transition Model, more exact a Latent Markov Model using the LMest package in R. As far as I have understood this means creating both a measurement model and subsequently a latent model, both in which covariates (X) can be reduced, however I fail when I try to add them to the measurement model. Can anyone tell me why?

##### SIMULATED DATA OF THE SAME NATURE 
ID <- c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3)
time <-  c(0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8,0,1,2,3,4,5,6,7,8)
gender <- c(1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1)
response_y <- c(NA, 0.15, 0.2, 0.4, 0.64, NA, 0.85, 0.89, NA, 0.02, NA, 0.01, 0.11, 0.35, 0.63, NA, NA, NA, NA, 0.3, NA, 0.56, 0.84, 0.81, 0.9, NA, NA)
response_y1 <- c(NA, 0.1, 0.3, 0.5, NA, NA, 0.7, 0.89, NA, NA, NA, 0.01, 0.11, 0.35, NA, NA, NA, NA, NA, 0.3, NA, 0.56, 0.84, NA, 0.9, 0.91, NA)

d = data.frame(ID, time, gender, response_y)

I have so far tried to model it like this:

library(LMest)

## COVARIATES INTRODUCED TO THE MEASUREMENT MODEL (gives error)
lmestCont(responsesFormula = response_y + response_y1 ~ gender, latentFormula = NULL, index = c("ID", "time"), k = 1:5, data = dt$data, modBasic = 1, output = TRUE, tol = 10^-5, out_se = TRUE)

But keep getting this error:

Warning: multivariate data are not allowed; only the first response variable is considered Steps of EM: 1...2...3...4...5...6...7...8...9...10...11...12...13...14...15...16...17...18...19...20...21...22...23...24...25...26...27...28...29...30...31...32...33...34...35...36...37...38...39...40...41...42...43...44... Missing data in the dataset. imp.mix function (mix package) used for imputation. Error in aicv[kv] <- out[[kv]]$aic : replacement has length zero

When introducing the covariates to the latent model it works, and looks like this:

## COVARIATES INTRODUCED TO THE LATENT MODEL (RUNS)
mod_con <- lmestCont(responsesFormula = response_y+ response_y1 ~ NULL, latentFormula = ~ gender | gender, index = c("ID", "time"), k = 1:5, data = dt$data, modBasic = 1, output = TRUE, tol = 10^-5, out_se = TRUE)

All kinds of advise are happily received - also on the LMest in general, maybe I have misunderstood something!!! thanks

  • From the LMest package, they refer to the measurement model as the manifest class and the latent model as the latent class. For continuous data, there is no manifest class in this package. I'm not sure if that's due to the type of model or just a limitation of the package. [Read more here](https://cran.r-project.org/web/packages/LMest/LMest.pdf). – Kat Nov 18 '22 at 16:18

0 Answers0