
LMest
functionsBulding formulas for lmest
, lmestCont
, lmestMixed
, and lmestMc
.
lmestFormula(data,
response, manifest = NULL,
LatentInitial = NULL, LatentTransition = NULL,
AddInterceptManifest = FALSE,
AddInterceptInitial = TRUE,
AddInterceptTransition = TRUE, responseStart = TRUE,
manifestStart = TRUE, LatentInitialStart = TRUE,
LatentTransitionStart = TRUE)
Returns a list with responsesFormula
and latentFormula
objects.
a data.frame or a matrix of data
a numeric or character vector indicating the column indices or the names for the response variables
a numeric or character vector indicating the column indices or the names for the covariates affecting the measurement model
a numeric or character vector indicating the column indices or the names for the covariates affecting the initial probabilities
a numeric or character vector indicating the column indices or the names for the covariates affecting the transition probabilities
a logical value indicating whether the intercept is added to the covariates affecting the measurement model
a logical value indicating whether the intercept is added to covariates affecting the initial probabilities
a logical value indicating whether the intercept is added to covariates affecting the transition probabilities
a logical value indicating whether the response variables names start with response
argument
a logical value indicating whether the covariates names start with manifest
argument
a logical value indicating whether the covariates names start with LatentInitial
argument
a logical value indicating whether the covariates names start with LatentTransition
argument
Francesco Bartolucci, Silvia Pandolfi, Fulvia Pennoni, Alessio Farcomeni, Alessio Serafini
Generates formulas for responsesFormula
and latentFormula
to use in lmest
, lmestCont
, lmestMixed
, and lmestMc
.
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