### Example with data on drug use in wide format
data("data_drug")
long <- data_drug[,-6]
# add labels referred to the identifier
long <- data.frame(id = 1:nrow(long),long)
# reshape data from the wide to the long format
long <- reshape(long,direction = "long",
idvar = "id",
varying = list(2:ncol(long)))
out <- lmestSearch(data = long,
index = c("id","time"),
version = "categorical",
k = 1:3,
weights = data_drug[,6],
modBasic = 1,
seed = 123)
out
summary(out$out.single[[3]])
if (FALSE) {
### Example with data on self rated health
# LM model with covariates in the measurement model
data("data_SRHS_long")
SRHS <- data_SRHS_long[1:1000,]
# Categories rescaled to vary from 1 (“poor”) to 5 (“excellent”)
SRHS$srhs <- 5 - SRHS$srhs
out1 <- lmestSearch(data = SRHS,
index = c("id","t"),
version = "categorical",
responsesFormula = srhs ~ -1 +
I(gender - 1) +
I( 0 + (race == 2) + (race == 3)) +
I(0 + (education == 4)) +
I(0 + (education == 5)) + I(age - 50) +
I((age-50)^2/100),
k = 1:2,
out_se = TRUE,
seed = 123)
summary(out1)
summary(out1$out.single[[2]])
}
Run the code above in your browser using DataLab