Learn R Programming

LMest (version 3.1.2)

drawLMlatentcont: Draw samples from LM model for continuous outcomes with covariates in the latent model

Description

Function that draws samples from the LM model for continuous outcomes with individual covariates with specific parameters.

Usage

drawLMlatentcont(Mu, Si, Be, Ga, latentFormula, data, index,
                 paramLatent = c("multilogit","difflogit"), est = NULL,
                 format = c("long","matrices"), fort = TRUE, seed = NULL)

Value

Y

array of continuous outcomes (n x TT x r)

U

matrix containing the sequence of latent states (n x TT)

Mu

array of conditional means for the response variables (r x k)

Si

var-cov matrix common to all states (r 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. A detailed description is given in lmestCont

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 LMlatentcont (LMlatentcont-class)

Arguments

Mu

array of conditional means for the response variables (r x k)

Si

var-cov matrix common to all states (r 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. A detailed description is given in lmestCont

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 LMlatentcont (LMlatentcont-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

Author

Francesco Bartolucci, Silvia Pandolfi, Fulvia Pennoni, Alessio Farcomeni, Alessio Serafini

Examples

Run this code

if (FALSE) {
data(data_long_cont)

est <- lmestCont(responsesFormula = Y1 + Y2 + Y3~ NULL,
                 latentFormula = ~ X1 + X2,
                 index = c("id", "time"),
                 data = data_long_cont,
                 k = 3)

out <- drawLMlatentcont(est = est,format = "matrices", seed = 4321)
out1 <- drawLMlatentcont(latentFormula = ~ X1 + X2, data = data_long_cont,
                         index = c("id", "time"),
                         Mu = est$Mu,Si = est$Si,
                         Be = est$Be,Ga = est$Ga, fort=TRUE, seed = 4321, format = "matrices")

}

Run the code above in your browser using DataLab