nhm: Fit a non-homogeneous Markov model using maximum likelihood

View source: R/main.R

nhmR Documentation

Fit a non-homogeneous Markov model using maximum likelihood

Description

Fit a continuous-time Markov or hidden Markov multi-state model by maximum likelihood. Observations of the process can be made at arbitrary times, or the exact times of transition between states can be known. Covariates can be fitted to the Markov chain transition intensities or to the hidden Markov observation process.

Usage

nhm(model_object, initial=NULL, gen_inits=FALSE,
control, score_test=FALSE, fixedpar=NULL)

Arguments

model_object

Model object created using model.nhm

initial

Vector of initial parameter values

gen_inits

If TRUE, then initial values for the transition intensities are generated automatically using the method in crudeinits.msm from the msm package. This is not available for models with misclassified states. If FALSE a BHHH algorithm implemented using maxLik is used.

control

Object of class nhm.control specifying various settings for the solution of the KFEs and the optimization. See nhm.control for default settings.

score_test

If TRUE just the gradient and Fisher information at the supplied values will be computed to allow score tests to be performed.

fixedpar

Numerical vector indicating which parameters are taken as fixed at the value specified by initial.

Details

For more details about the methodology behind the nhm package, see Titman (2011) and the package vignette.

Value

By default returns an object of class nhm containing model output data such as the estimated parameters, maximized likelihood value, information matrix etc. The object can be used with print, predict, plot and anova.

If score.test=TRUE then returns an object of class nhm_score. See print.nhm_score for more details.

Author(s)

Andrew Titman a.titman@lancaster.ac.uk

References

Titman AC. Flexible Nonhomogeneous Markov Models for Panel Observed Data. Biometrics, 2011. 67, 780-787.

See Also

model.nhm, nhm.control, plot.nhm, predict.nhm, print.nhm_score

Examples

### Example dataset
### For further examples, see the vignette
trans <- rbind(c(0,1,0,0),c(0,0,2,0),c(0,0,0,3),rep(0,4))
nonh <- rbind(c(0,1,0,0),c(0,0,2,0),c(0,0,0,3),rep(0,4))
gomp_model <- model.nhm(state~time, data=example_data1, subject = id,
                        type="gompertz",trans=trans,nonh=nonh)
initial_val <- c(-0.65,-0.45,-0.55,0,0,0)
gomp_fit <- nhm(gomp_model,initial=initial_val,control=nhm.control(obsinfo=FALSE))
gomp_fit
plot(gomp_fit)
plot(gomp_fit,what="intensities")

nhm documentation built on Nov. 3, 2023, 1:12 a.m.

Related to nhm in nhm...