MEDseq (version 1.2.0)

MEDseq_meantime: 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)

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

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 the first column of the output is not affected by the value of weighted.

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.

Value

A matrix with sequence category and cluster-specific mean times, giving clusters on the rows, corresponding cluster sizes in the first column, and sequence categories in the remaining columns.

Details

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

References

Murphy, K., Murphy, T. B., Piccarreta, R., and Gormley, I. C. (2019). Clustering longitudinal life-course sequences using mixtures of exponential-distance models. To appear. <arXiv:1908.07963>.

See Also

MEDseq_fit, MEDseq_control

Examples

Run this code
# NOT RUN {
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")

round(MEDseq_meantime(mod), 2)
round(MEDseq_meantime(mod, prop=TRUE), 2)
MEDseq_meantime(mod, MAP=TRUE, norm=FALSE)
# }

Run the code above in your browser using DataCamp Workspace