# Load three-channel sequence data
data("biofam3c")
# Building sequence objects
marr_seq <- seqdef(biofam3c$married,
start = 15,
alphabet = c("single", "married", "divorced"),
cpal = c("violetred2", "darkgoldenrod2", "darkmagenta")
)
child_seq <- seqdef(biofam3c$children,
start = 15,
alphabet = c("childless", "children"),
cpal = c("darkseagreen1", "coral3")
)
left_seq <- seqdef(biofam3c$left,
start = 15,
alphabet = c("with parents", "left home"),
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
stacked_sequence_plot(
list(
"Marriage" = marr_seq, "Parenthood" = child_seq,
"Residence" = left_seq, "Combined" = sc_data
),
type = "i",
ids = 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)
Run the code above in your browser using DataLab