Description Usage Arguments Details Author(s) References See Also Examples
Provides a graphical indication of goodness of fit of a multistate model
computed by msm
using observed and expected prevalences.
It also computes a rough indicator of where the data depart from the fitted
Markov model.
1 2 3 4 5 6 7  prevplot(x, prev.obj, M = FALSE, exacttimes = TRUE, ci = FALSE,
grid = 100L, x.lab.grid = 500L, xlab = "Time",
ylab = "Prevalence (%)", lty.fit = 1, lwd.fit = 1, col.fit = "red",
lty.ci.fit = 2, lwd.ci.fit = 1, col.ci.fit = col.fit, lwd.obs = 1,
lty.obs = 1, col.obs = "darkblue", legend.pos = "topright",
par.col = 3, plot.width = 10, plot.height = 5, max.m = 0.1,
devnew = TRUE, verbose = TRUE)

x 
A 
prev.obj 
A list computed by 
M 
If 
exacttimes 
If 
ci 
If 
grid 
Define how many points should be used to build the x axis. Defaul is 100. 
x.lab.grid 
Define the interval on the x axis at which draw tick marks. Default is 500. 
xlab 
x axis label. 
ylab 
y axis label. 
lty.fit 
Line type for the expected prevalences.
See 
lwd.fit 
Line width for the expected prevalences.
See 
col.fit 
Line color for the expected prevalences.
See 
lty.ci.fit 
Line type for the expected prevalences confidence limits.
See 
lwd.ci.fit 
Line width for the expected prevalences confidence limits.
See 
col.ci.fit 
Line color for the expected prevalences confidence limits.
See 
lwd.obs 
Line width for the observed prevalences.
See 
lty.obs 
Line type for the observed prevalences.
See 
col.obs 
Line color for the observed prevalences.
See 
legend.pos 
Where to position the legend. Default is 
par.col 
The number of columns of the plot. Default is 3. 
plot.width 
Width of new graphical device. Default is 7.
See 
plot.height 
Height of new graphical device. Default is 7.
See 
max.m 
If 
devnew 
Set the graphical device where to plot. By default,

verbose 
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}
Francesco Grossetti francesco.grossetti@unibocconi.it.
Titman, A. and Sharples, L.D. (2010). Model diagnostics for
multistate models, Statistical Methods in Medical Research, 19,
621651.
Titman, A. and Sharples, L.D. (2008). A general goodnessoffit test for
Markov and hidden Markov models, Statistics in Medicine, 27,
21772195.
Gentleman RC, Lawless JF, Lindsey JC, Yan P. (1994). Multistate Markov
models for analysing incomplete disease data with illustrations for HIV
disease. Statistics in Medicine, 13:805821.
Jackson, C.H. (2011). MultiState Models for Panel Data:
The msm Package for R. Journal of Statistical Software, 38(8), 129.
URL http://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()
prevplot( msm_model, prev, ci = TRUE, devnew = FALSE, verbose = FALSE )
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.