data(data_SRHS_long)
names(data_SRHS_long)
# Formula with response srhs and covariates for both initail and transition:
# gender,race,educational,age.
## LM model with covariates on the latent model
# and with intercepts on the initial and transition probabilities
fm <- lmestFormula(data = data_SRHS_long,
response = "srhs",
LatentInitial = 3:6, LatentTransition = 3:6)
fm
## LM model with covariates on the latent model
# and without intercepts on the initial and transition probabilities
fm <- lmestFormula(data = data_SRHS_long,
response = "srhs",
LatentInitial = 3:6, LatentTransition = 3:6,
AddInterceptInitial = FALSE,AddInterceptTransition = FALSE)
fm
######
data(data_criminal_sim)
str(data_criminal_sim)
# Formula with only the responses from y1 to y10
fm <- lmestFormula(data = data_criminal_sim,response = "y")$responsesFormula
fm
# Formula with only the responses from y1 to y10 and intercept for manifest
fm <- lmestFormula(data = data_criminal_sim,
response = "y",AddInterceptManifest = TRUE)$responsesFormula
fm
## LM model for continous responses
data(data_long_cont)
names(data_long_cont)
# Formula with response Y1, Y2, no covariate for manifest,
# X1 covariates for initail and X2 covariate for transition
fm <- lmestFormula(data = data_long_cont,
response = c("Y"),
LatentInitial = "X",
LatentTransition = "X2")
fm
## Wrong model specification since two variable start with X.
# Check the starts arguments.
# For the right model:
fm <- lmestFormula(data = data_long_cont,
response = c("Y"),
LatentInitial = "X1",LatentTransition = "X2")
fm
## or
fm <- lmestFormula(data = data_long_cont,
response = c("Y"),
LatentInitial = 6,LatentTransition = "X2",
LatentInitialStart = FALSE)
fm
if (FALSE) {
data(data_criminal_sim)
data_criminal_sim <- data.frame(data_criminal_sim)
# Mixed LM model for females
responsesFormula <- lmestFormula(data = data_criminal_sim,
response = "y")$responsesFormula
out <- lmest(responsesFormula = responsesFormula,
index = c("id","time"),
data = data_criminal_sim,
k = 2)
}
Run the code above in your browser using DataLab