mc_to_sc_data: Merge Multiple Sequence Objects into One (from Multichannel...

Description Usage Arguments See Also Examples

View source: R/mc_to_sc_data.R

Description

Function mc_to_sc_data combines observed states of multiple sequence objects into one, time point by time point.

Usage

1
mc_to_sc_data(data, combine_missing = TRUE, all_combinations = FALSE)

Arguments

data

A list of state sequence objects (stslists) created with the seqdef function.

combine_missing

Controls whether combined states of observations at time t are coded missing (coded with * in stslists) if one or more of the channels include missing information at time t. Defaults to TRUE. FALSE keeps missing states as they are, producing more states in data; e.g. single/childless/* where the observation in channel 3 is missing.

all_combinations

Controls whether all possible combinations of observed states are included in the single channel representation or only combinations that are found in the data. Defaults to FALSE, i.e. only actual observations are included.

See Also

mc_to_sc for transforming multichannel hmm or mhmm objects into single-channel representations; ssplot for plotting multiple sequence data sets in the same plot; and seqdef for creating state sequence objects.

Examples

 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
# Load three-channel sequence data
data("biofam3c")

# Building sequence objects
marr_seq <- seqdef(biofam3c$married, start = 15,
  alphabet = c("single", "married", "divorced"))
child_seq <- seqdef(biofam3c$children, start = 15,
  alphabet = c("childless", "children"))
left_seq <- seqdef(biofam3c$left, start = 15,
  alphabet = c("with parents", "left home"))

# Define colors
attr(marr_seq, "cpal") <- c("violetred2", "darkgoldenrod2", "darkmagenta")
attr(child_seq, "cpal") <- c("darkseagreen1", "coral3")
attr(left_seq, "cpal") <- c("lightblue", "red3")

# Converting multichannel data to single-channel data
sc_data <- mc_to_sc_data(list(marr_seq, child_seq, left_seq))

# 10 combined states
alphabet(sc_data)

# Colors for combined states
attr(sc_data, "cpal") <- colorpalette[[14]][1:10]

# Plotting sequences for the first 10 subjects
ssplot(list("Marriage" = marr_seq, "Parenthood" = child_seq, 
  "Residence" = left_seq, "Combined" = sc_data), type = "I",
  tlim = 1:10)


# Including all combinations (whether or not available in data)
sc_data_all <- mc_to_sc_data(list(marr_seq, child_seq, left_seq),
  all_combinations = TRUE)

# 12 combined states, 2 with no observations in data
seqstatf(sc_data_all)

seqHMM documentation built on May 10, 2018, 5:04 p.m.