Learn R Programming

LMest (version 3.1.2)

est_lm_basic: Estimate basic LM model

Description

Main function for estimating the basic LM model.

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

Usage

est_lm_basic(S, yv, k, start = 0, mod = 0, tol = 10^-8, maxit = 1000,
	                  out_se = FALSE, piv = NULL, Pi = NULL, Psi = NULL)

Value

lk

maximum log-likelihood

piv

estimate of initial probability vector

Pi

estimate of transition probability matrices

Psi

estimate of conditional response probabilities

np

number of free parameters

aic

value of AIC for model selection

bic

value of BIC for model selection

lkv

log-likelihood trace at every step

V

array containing the posterior distribution of the latent states for each response configuration and time occasion

sepiv

standard errors for the initial probabilities

sePi

standard errors for the transition probabilities

sePsi

standard errors for the conditional response probabilities

call

command used to call the function

Arguments

S

array of available configurations (n x TT x r) with categories starting from 0 (use NA for missing responses)

yv

vector of frequencies of the available configurations

k

number of latent states

start

type of starting values (0 = deterministic, 1 = random, 2 = initial values in input)

mod

model on the transition probabilities (0 for time-heter., 1 for time-homog., from 2 to (TT-1) partial homog. of that order)

tol

tolerance level for convergence

maxit

maximum number of iterations of the algorithm

out_se

to compute the information matrix and standard errors

piv

initial value of the initial probability vector (if start=2)

Pi

initial value of the transition probability matrices (k x k x TT) (if start=2)

Psi

initial value of the conditional response probabilities (mb x k x r) (if start=2)

Author

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

References

Bartolucci, F., Farcomeni, A. and Pennoni, F. (2013) Latent Markov Models for Longitudinal Data, Chapman and Hall/CRC press.

Examples

Run this code
if (FALSE) {
# Example of drug consumption data

# load data
data(data_drug)
data_drug <- as.matrix(data_drug)
S <- data_drug[,1:5]-1
yv <- data_drug[,6]

# fit of the Basic LM model
k <- 3
out <- est_lm_basic(S, yv, k, mod = 1)
summary(out)

# Example based on criminal data

# load criminal 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

# fit basic LM model with increasing number of states to select the most suitable
Res0 <- vector("list", 7)
for(k in 1:7){
    Res0[[k]] <- est_lm_basic(YY, freq, k, mod = 1, tol = 10^-4)
    save(list <- ls(), file = "example_criminal_temp.RData")
}
out1 <- Res0[[6]]
}

Run the code above in your browser using DataLab