Description Usage Arguments Details Author(s) References See Also Examples
Provides a graphical indication of goodness of fit of a multi-state model
computed by msm
using observed and expected prevalences.
It also computes a rough indicator of where the data depart from the estimated
Markov model.
1 |
x |
A |
prev.obj |
A list computed by |
exacttimes |
If |
M |
If |
ci |
If |
When M = TRUE
, a rough indicator of the deviance from the
Markov model is computed according to Titman and Sharples (2008).
A comparison at a given time t_i of a patient k in the state
s between observed counts O_{is} with expected ones E_{is}
is build as follows:
(O_{is} - E_{is})^2 / E_{is}
The plot of the deviance M is returned together with the standard prevalence plot in the second row. This is not editable by the user.
Francesco Grossetti francesco.grossetti@unibocconi.it.
Titman, A. and Sharples, L.D. (2010). Model diagnostics for
multi-state models, Statistical Methods in Medical Research, 19,
621-651.
Titman, A. and Sharples, L.D. (2008). A general goodness-of-fit test for
Markov and hidden Markov models, Statistics in Medicine, 27,
2177-2195.
Gentleman RC, Lawless JF, Lindsey JC, Yan P. (1994). Multi-state Markov
models for analysing incomplete disease data with illustrations for HIV
disease. Statistics in Medicine, 13:805-821.
Jackson, C.H. (2011). Multi-State Models for Panel Data:
The msm Package for R. Journal of Statistical Software, 38(8), 1-29.
URL https://www.jstatsoft.org/v38/i08/.
plot.prevalence.msm
msm
prevalence.msm
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 32 33 34 35 36 37 | ## Not run:
data( hosp )
# augmenting the data
hosp_augmented = augment( data = hosp, data_key = subj, n_events = adm_number,
pattern = label_3, t_start = dateIN, t_end = dateOUT,
t_cens = dateCENS )
# let's define the initial transition matrix for our model
Qmat = matrix( data = 0, nrow = 3, ncol = 3, byrow = TRUE )
Qmat[ 1, 1:3 ] = 1
Qmat[ 2, 1:3 ] = 1
colnames( Qmat ) = c( 'IN', 'OUT', 'DEAD' )
rownames( Qmat ) = c( 'IN', 'OUT', 'DEAD' )
# attaching the msm package and running the model using
# gender and age as covariates
library( msm )
msm_model = msm( status_num ~ augmented_int, subject = subj,
data = hosp_augmented, covariates = ~ gender + age,
exacttimes = TRUE, gen.inits = TRUE, qmatrix = Qmat,
method = 'BFGS', control = list( fnscale = 6e+05, trace = 0,
REPORT = 1, maxit = 10000 ) )
# defining the times at which compute the prevalences
t_min = min( hosp_augmented$augmented_int )
t_max = max( hosp_augmented$augmented_int )
steps = 100L
# computing prevalences
prev = prevalence.msm( msm_model, covariates = 'mean', ci = 'normal',
times = seq( t_min, t_max, steps ) )
# and plotting them using prevplot()
gof = prevplot( x = msm_model, prev.obj = prev, ci = TRUE, M = TRUE )
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.