LatentStage: Discrete heterogeneity model with multiple stages

Description Usage Arguments Details Value Examples

Description

Discrete heterogeneity model is applicable to scenario in which each subject is assigned a latent class, and fixed parameters are used across subjects in the same class. Multiple stages simply mean that more than one responses are allowed in fitting this model. Typically, one response is nested with another, but it does not have to be this case to fit the model.

Usage

1
LatentStage(nclass, ...)

Arguments

nclass

numbers of class for all subjects, this determines how many groups of different parameters will be obtained

...

X1: A covariate matrix of the first stage, similar for X2, X3, ...; y1: A vector of response variables for the first stage, similar for y2, y3, ...; id1: A vector of subject IDs of the first stage, similar for id2, id3, ...

Details

Arbitrary number of covariates, repsonses and subject ids can be given in the argument list. However, their number must be the same, i.e. equal to the number of stages in this model. Furthermore, dimensions must match, i.e. row(X1) = length(y1) = length(id1).

Value

A list object containing both arguments and results. lambda is the estimate of class proportions, which sum up to 1. beta contains estimates, SEs and p-values for all linear parameters. posteriorz lists the probability of each subject belonging to a specific group, the estimated class id is determined by which class maximizes the probability. all.loglik lists log-likelihood in each iteration. y is a list object of responses of all stages. id is a list object of subject ids of all stages. x is a list object of covariates of all stages. AIC is the AIC for current model. BIC is the BIC for current model. These two can be used for class number selection. runtime is the whole elapsed time to fit the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(threestage)
attach(threestage)
mod <- LatentStage(5, X1=stage1[, 4:7],
       y1=stage1$Y1, id1=stage1$Person,
       X2=stage2[, 4:7],
       y2=stage2$Y2, id2=stage2$Person,
       X3=stage3[, 4:7],
       y3=stage3$Y3, id3=stage3$Person)

data(dating)
attach(dating)
nonmiss <- !is.na(wrote)
mod <- LatentStage(3, y1 = browsed, y2 = wrote[nonmiss],
                   id1 = respid, id2 = respid[nonmiss],
                   X1 = agedif, X2 = agedif[nonmiss])

tinyleap/LatentStage documentation built on May 12, 2019, 4:27 p.m.