
Main function for estimating the mixed LM model with discrete random effect in the latent model. The function is no longer maintained. Please look at lmestMixed
function
est_lm_mixed(S, yv = rep(1,nrow(S)), k1, k2, start = 0, tol = 10^-8, maxit = 1000,
out_se = FALSE)
array of available response configurations (n x TT x r) with categories starting from 0
vector of frequencies of the available configurations
number of latent classes
number of latent states
type of starting values (0 = deterministic, 1 = random)
tolerance level for convergence
maximum number of iterations of the algorithm
to compute standard errors
estimate of the mass probability vector (distribution of the random effects)
estimate of initial probabilities
estimate of transition probability matrices
estimate of conditional response probabilities
maximum log-likelihood
posterior probabilities of the random effect
number of free parameters
value of BIC for model selection
command used to call the function
Bartolucci, F., Farcomeni, A. and Pennoni, F. (2013) Latent Markov Models for Longitudinal Data, Chapman and Hall/CRC press.
# NOT RUN {
# Example based of criminal data
# load data
data(data_criminal_sim)
out <- long2wide(data_criminal_sim, "id", "time", "sex",
c("y1","y2","y3","y4","y5","y6","y7","y8","y9","y10"), aggr = T, full = 999)
XX <- out$XX
YY <- out$YY
freq <- out$freq
n1 <- sum(freq[XX[,1] == 1])
n2 <- sum(freq[XX[,1] == 2])
n <- sum(freq)
# fit mixed LM model only for females
YY <- YY[XX[,1] == 2,,]
freq <- freq[XX[,1] == 2]
k1 <- 2
k2 <- 2
res <- est_lm_mixed(YY, freq, k1, k2, tol = 10^-8)
summary(res)
# }
Run the code above in your browser using DataLab