Extract the data from a multistate model fitted with msm
.
1 2 3 4  ## S3 method for class 'msm'
model.frame(formula, agg=FALSE, ...)
## S3 method for class 'msm'
model.matrix(object, model="intens", state=1, ...)

formula 
A fitted multistate model object, as returned by

agg 
Return the model frame in the efficient aggregated form
used to calculate the likelihood internally for nonhidden Markov
models. This has one row for each unique combination of fromstate,
tostate, time lag, covariate value and observation type. The
variable named 
object 
A fitted multistate model object, as returned by

model 

state 
State corresponding to the required covariate design matrix in a hidden Markov model. 
... 
Further arguments (not used). 
model.frame
returns a data frame with all the original
variables used for the model fit, with any missing data removed (see
na.action
in msm
). The state, time, subject,
obstype
and obstrue
variables are named
"(state)"
, "(time)"
, "(subject)"
,
"(obstype)"
and "(obstrue)"
respectively (note the
brackets). A variable called "(obs)"
is the observation number
from the original data before any missing data were dropped.
The variable "(pcomb)"
is used for computing the likelihood for hidden
Markov models, and identifies
which distinct time difference, obstype
and covariate values
(thus which distinct interval transition probability matrix) each observation
corresponds to.
The model frame object has some other useful attributes, including
"usernames"
giving the user's original names for these
variables (used for model refitting, e.g. in bootstrapping or cross
validation) and "covnames"
identifying which ones are covariates.
model.matrix
returns a design matrix for a part of the
model that includes covariates. The required part is indicated by the
"model"
argument.
For timeinhomogeneous models fitted with "pci"
, these datasets
will have imputed observations at each time change point, indicated
where the variable "(pci.imp)"
in the model frame is 1. The
model matrix for intensities will have factor contrasts for the
timeperiod
covariate.
C. H. Jackson chris.jackson@mrcbsu.cam.ac.uk
msm
, model.frame
, model.matrix
.
Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.