MEDseq_meantime: Compute the mean time spent in each sequence category

MEDseq_meantimeR Documentation

Compute the mean time spent in each sequence category

Description

Computes the mean time (per cluster) spent in each sequence category (i.e. state value) for a fitted MEDseq model.

Usage

MEDseq_meantime(x,
                MAP = FALSE,
                weighted = TRUE, 
                norm = TRUE,
                prop = FALSE, 
                map.size = FALSE,
                wt.size = FALSE,
                SPS = FALSE)

## S3 method for class 'MEDseqMeanTime'
print(x,
      digits = 3L,
      ...)

Arguments

x

An object of class "MEDseq" generated by MEDseq_fit or an object of class "MEDseqCompare" generated by MEDseq_compare.

MAP

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.

weighted

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).

norm

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.

prop

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.

map.size

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.

wt.size

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).

SPS

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.

digits

Minimum number of significant digits to be printed in values.

...

Catches unused arguments.

Details

Models with weights, covariates, &/or a noise component are also accounted for.

Value

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.

Note

The function plot.MEDseq with the option type="mt" can be used to visualise the mean times (by cluster). However, the results displayed therein (at present) always assume norm=TRUE, prop=FALSE, and wt.size=TRUE, while the MAP argument is renamed to soft, where MAP=!soft.

Author(s)

Keefe Murphy - <keefe.murphy@mu.ie>

References

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. <doi:10.1111/rssa.12712>.

See Also

MEDseq_fit, MEDseq_control, plot.MEDseq

Examples

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)

MEDseq documentation built on Dec. 28, 2022, 2:35 a.m.