draw_lm_cov_latent: Draw samples from LM model with covariaates in the latent...

Description Usage Arguments Value Author(s) Examples

View source: R/draw_lm_cov_latent.R

Description

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

The function is no longer maintained. Please look at drawLMlatent function.

Usage

1
draw_lm_cov_latent(X1, X2, param = "multilogit", Psi, Be, Ga, fort = TRUE)

Arguments

X1

desing matrix for the covariates on the initial probabilities (n x nc1)

X2

desing matrix for the covariates on the transition probabilities (n x TT-1 x nc2)

param

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)

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

fort

to use fortran routine when possible (FALSE for not use fortran)

Value

Y

matrix of response configurations unit by unit (n x TT x r)

U

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

Author(s)

Francesco Bartolucci, Silvia Pandolfi, University of Perugia (IT), http://www.stat.unipg.it/bartolucci

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 

# draw a sample for 1000 units, 10 response variable and 2 covariates
n <- 1000
TT <- 5
k <- 2
nc <- 2 #number of covariates
r <- 10 #number of response variables
mb <- 2 #maximum number of response categories
fort <- TRUE


Psi <- matrix(c(0.9,0.1,0.1,0.9), mb, k)
Psi <- array(Psi, c(mb, k, r))
Ga <- matrix(c(-log(0.9/0.1),0.5,1), (nc+1)*(k-1), k)
Be <- array(c(0,0.5,1), (nc+1)*(k-1))
#Simulate covariates
X1 <- matrix(0, n, nc)
for(j in 1:nc) X1[,j] <- rnorm(n)
X2 <- array(0,c(n, TT-1, nc))
for (t in 1:(TT-1)) for(j in 1:nc){
	if(t==1){
		X2[,t,j] <- 0.5*X1[,j] + rnorm(n)
	}else{
		X2[,t,j] <- 0.5 *X2[,t-1,j] + rnorm(n)
	}
}

out <- draw_lm_cov_latent(X1, X2, Psi = Psi, Be = Be, Ga = Ga, fort = fort)

## End(Not run)

LMest documentation built on Oct. 10, 2021, 1:09 a.m.