Computes the mean time (per cluster) spent in each sequence category (i.e. state value) for a fitted MEDseq
model.
MEDseq_meantime(x,
MAP = FALSE,
weighted = TRUE,
norm = TRUE,
prop = FALSE,
map.size = FALSE,
wt.size = FALSE,
SPS = FALSE)# S3 method for MEDseqMeanTime
print(x,
digits = 3L,
...)
A matrix with sequence category and cluster-specific mean times, giving clusters on the rows, corresponding cluster sizes (or weighted cluster sizes) in the first column, and sequence categories in the remaining columns.
An object of class "MEDseq"
generated by MEDseq_fit
or an object of class "MEDseqCompare"
generated by MEDseq_compare
.
A logical indicating whether to use the MAP classification in the computation of the averages, or the `soft' clustering assignment probabilities given by x$z
. Defaults to FALSE
, but is always TRUE
for models fitted by the CEM algorithm (see MEDseq_control
). See weighted
for incorporating the sampling weights (regardless of the value of MAP
). See map.size
below.
A logical indicating whether the sampling weights (if used during model fitting) are used to compute the weighted averages. These can be used alone (when MAP
is TRUE
) or in conjunction with the `soft' clustering assignment probabilities (when MAP
is FALSE
). Defaults to TRUE
. Note that, by default, the first column of the output is not affected by the value of weighted
(see wt.size
).
A logical indicating whether the mean times (outputted values after the first column) are normalised to sum to the sequence length within each cluster (defaults to TRUE
). Otherwise, when FALSE
, entries beyond the first column give the total (weighted) number of times a given sequence category was observed in a given cluster.
A logical (defaulting to FALSE
and only invoked when norm
is also TRUE
) which further normalises the output to give the proportions of time spent in each state on average instead of the absolute values.
A logical (defaulting to FALSE
, unless the model was fitted by the CEM algorithm (see MEDseq_control
)) which overrides MAP
in the Size
column (or Weighted.Size
column, see wt.size
) of the output, e.g. if MAP=FALSE
and map.size=TRUE
, the MAP classification is used to determine the cluster sizes but the soft cluster-membership probabilities are used to calculate quantities in remaining columns. Only relevant when MAP=FALSE
or wt.size=TRUE
.
A logical (defaults to FALSE
and only invoked when when weighted
is also TRUE
) which toggles whether the weights are also used in the computation of the cluster sizes in the first column of the output (regardless of the values of MAP
or map.size
).
A logical indicating whether the output should be labelled according to the state-permanence-sequence representation of the central sequences. Defaults to FALSE
. See MEDseq_clustnames
and seqformat
.
Minimum number of significant digits to be printed in values.
Catches unused arguments.
Keefe Murphy - <keefe.murphy@mu.ie>
Models with weights, covariates, &/or a noise component are also accounted for.
Murphy, K., Murphy, T. B., Piccarreta, R., and Gormley, I. C. (2021). Clustering longitudinal life-course sequences using mixtures of exponential-distance models. Journal of the Royal Statistical Society: Series A (Statistics in Society), 184(4): 1414-1451. <tools:::Rd_expr_doi("10.1111/rssa.12712")>.
MEDseq_fit
, MEDseq_control
, plot.MEDseq
data(biofam)
seqs <- seqdef(biofam[10:25] + 1L,
states = c("P", "L", "M", "L+M", "C",
"L+C", "L+M+C", "D"))
mod <- MEDseq_fit(seqs, G=10, modtype="UUN")
MEDseq_meantime(mod)
MEDseq_meantime(mod, prop=TRUE)
MEDseq_meantime(mod, map.size=TRUE)
MEDseq_meantime(mod, MAP=TRUE, norm=FALSE, SPS=TRUE)
Run the code above in your browser using DataLab