drawLMlatent {LMest} | R Documentation |
Draw samples from LM model with covariates in the latent model
Description
Function that draws samples from the LM model with individual covariates with specific parameters.
Usage
drawLMlatent(Psi, Be, Ga, latentFormula, data, index,
paramLatent = c("multilogit","difflogit"), est = NULL,
format = c("long","matrices"), fort = TRUE, seed = NULL)
Arguments
Psi |
array of conditional response probabilities (mb x k x r) |
Be |
parameters affecting the logit for the initial probabilities |
Ga |
parametes affecting the logit for the transition probabilities |
latentFormula |
a symbolic description of the model to be fitted. Detailed description is given in |
data |
a data frame in long format, with rows corresponding to observations and columns corresponding to variables, a column corresponding to time occasions and a column containing the unit identifier |
index |
a character vector with two elements indicating the name of the "id" column as first element and the "time" column as second element |
paramLatent |
type of parametrization for the transition probabilities ("multilogit" = standard multinomial logit for every row of the transition matrix, "difflogit" = multinomial logit based on the difference between two sets of parameters) |
est |
object of class |
format |
character string indicating the format of final responses matrix |
fort |
to use fortran routine when possible (FALSE for not use fortran) |
seed |
an integer value with the random number generator state |
Value
Y |
matrix of response configurations |
U |
matrix containing the sequence of latent states (n x TT) |
Psi |
array of conditional response probabilities (mb x k x r) |
Be |
parameters affecting the logit for the initial probabilities |
Ga |
parametes affecting the logit for the transition probabilities |
latentFormula |
a symbolic description of the model to be fitted. Detailed description is given in |
data |
a data frame in long format, with rows corresponding to observations and columns corresponding to variables, a column corresponding to time occasions and a column containing the unit identifier |
est |
object of class |
Author(s)
Francesco Bartolucci, Silvia Pandolfi, Fulvia Pennoni, Alessio Farcomeni, Alessio Serafini
Examples
## Not run:
data(data_SRHS_long)
dataSRHS <- data_SRHS_long
data_SRHS_long$srhs <- 5 - data_SRHS_long$srhs
est <- lmest(responsesFormula = srhs ~ NULL,
latentFormula = ~
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),
index = c("id","t"),
data = data_SRHS_long,
k = 2,
paramLatent = "multilogit",
start = 0)
out <- drawLMlatent(est = est,format = "matrices",seed = 4321)
out1 <- drawLMlatent(Psi = est$Psi,Be = est$Be,Ga = est$Ga,
data = data_SRHS_long, index = c("id","t"),
latentFormula = ~
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),
paramLatent = "multilogit", format = "matrice",
seed = 4321)
## End(Not run)