## ================
## plot biofam data
## ================
data(biofam)
lab <- c("Parent","Left","Married","Left+Marr","Child","Left+Child",
"Left+Marr+Child","Divorced")
## plot state sequences in STS representation
## ==========================================
## creating the weighted state sequence object.
biofam.seq <- seqdef(data = biofam[,10:25], labels = lab,
weights = biofam$wp00tbgs)
## select the first 20 weighted sequences (sum of weights = 18)
biofam.seq <- biofam.seq[1:20, ]
par(mar=c(4,8,2,2))
seqpcplot(seqdata = biofam.seq, order.align = "time")
## .. or
seqplot(seqdata = biofam.seq, type = "pc", order.align = "time")
## Distinct successive states (DSS)
## ==========================================
seqplot(seqdata = biofam.seq, type = "pc", order.align = "first")
## .. or (equivalently)
biofam.DSS <- seqdss(seqdata = biofam.seq) # prepare format
seqpcplot(seqdata = biofam.DSS)
## plot TSE data converted from state sequences
## ============================================
## conversion
biofam.TSE <- seqformat(data = biofam.seq, from = "STS", to = "TSE",
tevent = seqetm(biofam.seq, method = "state"))
biofam.TSE$event <- factor(biofam.TSE$event, levels = lab) # define alphabet
biofam.TSE$time <- biofam.TSE$time + 15 # correct age
seqpcplot(seqdata = biofam.TSE, order.align = "time")
## plot event sequences
## ====================
biofam.seqe <- seqecreate(biofam.seq, tevent = "state") # prepare data
## plot the time in the x-axis
seqpcplot(seqdata = biofam.seqe, order.align = "time", alphabet = lab)
## ordering of events
seqpcplot(seqdata = biofam.seqe, order.align = "first", alphabet = lab)
## ... or
plot(biofam.seqe, order.align = "first", alphabet = lab)
## additional arguments
## ====================
## non-embeddable sequences
seqpcplot(seqdata = biofam.seqe, ltype = "non-embeddable",
order.align = "first", alphabet = lab)
## align on last event
par(mar=c(4,8,2,2))
seqpcplot(seqdata = biofam.seqe, order.align = "last", alphabet = lab)
## use group variables
seqpcplot(seqdata = biofam.seqe, group = biofam$sex[1:20],
order.align = "first", alphabet = lab)
## color patterns (Parent)-(Married) and (Parent)-(Left+Marr+Child)
par(mfrow = c(1, 1))
seqpcplot(seqdata = biofam.seqe,
filter = list(type = "sequence",
value=c("(Parent)-(Married)",
"(Parent)-(Left+Marr+Child)")),
alphabet = lab, order.align = "first")
## color subsequence pattern (Parent)-(Left)
seqpcplot(seqdata = biofam.seqe,
filter = list(type = "subsequence",
value = "(Parent)-(Left)"),
alphabet = lab, order.align = "first")
## color sequences over 10% (within group) (function method)
seqpcplot(seqdata = biofam.seqe,
filter = list(type = "function",
value = "minfreq",
level = 0.1),
alphabet = lab, order.align = "first", seed = 1)
## .. same result using the convenience functions
seqpcplot(seqdata = biofam.seqe,
filter = 0.1,
alphabet = lab, order.align = "first", seed = 1)
seqpcplot(seqdata = biofam.seqe,
filter = seqpcfilter("minfreq", 0.1),
alphabet = lab, order.align = "first", seed = 1)
## highlight the 50% most frequent sequences
seqpcplot(seqdata = biofam.seqe,
filter = list(type = "function",
value = "cumfreq",
level = 0.5),
alphabet = lab, order.align = "first", seed = 2)
## .. same result using the convenience functions
seqpcplot(seqdata = biofam.seqe,
filter = seqpcfilter("cumfreq", 0.5),
alphabet = lab, order.align = "first", seed = 2)
## linear gradient
seqpcplot(seqdata = biofam.seqe,
filter = list(type = "function",
value = "linear"),
alphabet = lab, order.align = "first", seed = 2)
seqpcplot(seqdata = biofam.seqe,
filter = seqpcfilter("linear"),
alphabet = lab, order.align = "first", seed = 1)
Run the code above in your browser using DataLab