state_occupation_probability.nhm: Compute state occupation probabilities from a fitted nhm...

View source: R/state_occupancy_routines.R

state_occupation_probability.nhmR Documentation

Compute state occupation probabilities from a fitted nhm model

Description

Outputs the state occupation probabilities from a non-homogeneous Markov or misclassification type hidden Markov multi-state model fitted using nhm.

Usage

state_occupation_probability.nhm(model, covvalue=NULL, time0 = 0, times = NULL, 
initp = NULL, ltrunc = NULL,  rtol = 1e-06, atol = 1e-06, ci = TRUE, sim = FALSE, 
mode = "main", B = 1000, coverage = 0.95, statemerge = FALSE)

Arguments

model

Fitted model object produced using nhm.

covvalue

Vector of covariate vectors (should be given in the order specified in the covariate option in nhm). If omitted the function will use the mean values of the covariates.

time0

Starting time from which to compute the state occupation probabilities. Defaults to 0.

times

Optional vector of times at which to compute the transition probabilities. If omitted, the probabilities will be computed at a sequence of times from time0 to the maximum observed time in the data.

initp

optional vector of initial state occupation probabilities. If NULL then will use the estimates from the model. If original model was left-truncated will assume probabilities at tstart correspond to those implied by the left-truncation model. If ltrunc supplied will similarly calculate based on left-truncation from the value of t0 supplied. If model does not include misclassification, will assume entry in state 1.

ltrunc

Optional list containing ltruncation_time and ltruncation_states. If supplied will replace the values in the original model fit object.

rtol

Relative tolerance parameter to be used by lsoda when solving the differential equations

atol

Absolute tolerance parameter to be used by lsoda when solving the differential equations

ci

Logical for whether confidence intervals should be calculated for the quantities.

sim

Logical for whether simulation-based (parametric bootstrap) confidence intervals should be used (TRUE) or delta method-based intervals (FALSE).

mode

Argument for internal use to faciliate parametric bootstrapping: default "main" ensures standard errors and calculated, if mode="boot" then standard errors are not calculated.

B

Integer specifying the number of bootstrap replicates to perform if sim=TRUE. Defaults to 1000.

coverage

Nominal coverage proportion required for confidence intervals. Defaults to 0.95 implying two-sided 95% confidence intervals.

statemerge

Logical to determine whether latent states should be merged for models fitted using the phasemap option. If TRUE will return estimates for the number of observable states.

Details

The state occupation probabilities are computed by summing over the transition probabilites from time0 with respect to the initial state occupation probabilities.

For models with left-truncation, if time0 is greater than the time origin in the model (ltruncation_time) then the function will calculate the state occupation probabilites at time0 assuming subjects are sampled conditional on being in the ltruncation_states

Value

#out <- list(times= times, ests=ests, ests_cov = ests_cov, ests_low=ests_low, ests_high=ests_high, initp=initp)

Returns a list with the following components:

times

The set of times at which the state occupation probabilities are computed.

ests

Matrix of state occupation probability estimates

ests_cov

Array of variance-covariance estimates of the state occupation probability estimates at each time.

ests_low

Lower limits of component-wise confidence intervals

ests_high

Upper limits of component-wise confidence intervals

initp

Value of the initial probability vector at time tstart calculated from the model.

Author(s)

Andrew Titman a.titman@lancaster.ac.uk

See Also

expected_hitting_time, state_life_expectancy


nhm documentation built on Sept. 1, 2025, 1:08 a.m.