View source: R/seqgen.missing.R
seqgen.missing | R Documentation |
The function assigns missing values (nr
attribute of the object, which is "*"
by default) to randomly selected positions in randomly selected cases.
seqgen.missing(seqdata, p.cases = 0.1, p.left = 0.2, p.gaps = 0, p.right = 0.3,
mt.left="nr", mt.gaps="nr", mt.right="nr")
seqdata |
A state sequence object. |
p.cases |
Proportion of cases with missing values. |
p.left |
Proportion of left missing values. |
p.gaps |
Proportion of gap missing values. |
p.right |
Proportion of right missing values. |
mt.left |
Type of left missing. One of |
mt.gaps |
Type of gap missing. One of |
mt.right |
Type of right missing. One of |
The aim of the function is essentially pedagogical. It may serve to illustrate how results of a sequential analysis may be affected by the presence of random missing states.
States in the sequences are randomly replaced with missing values. For each selected sequence, first, a random proportion between 0 and p.gaps
of gaps are randomly inserted, then a random proportion between 0 and p.left
of positions from the start of the sequence are set as missing, and finally a random proportion between 0 and p.right
of positions from the end of the sequence are set as missing. Left missing values may possibly overlap gaps, and right missing values may overlap gaps and/or right missing values.
The resulting state sequence object.
This function needs further testing.
Gilbert Ritschard
seqdef
## create the biofam.seq state sequence object from the biofam data.
data(biofam)
biofam.seq <- seqdef(biofam[1:100,10:25])
## Generate missing states within 60% of the sequences.
biofamm.seq <- seqgen.missing(biofam.seq, p.cases=.6,
p.left=.4, p.gaps=.2, p.right=.5)
## compare the rendering of the sequences before and after
## introducing missing states.
par(mfrow=c(2,2))
seqIplot(biofam.seq, sortv="from.end", with.legend=FALSE)
seqIplot(biofamm.seq, sortv="from.end", with.legend=FALSE)
seqdplot(biofam.seq, with.missing=TRUE, border=NA, with.legend=FALSE)
seqdplot(biofamm.seq, with.missing=TRUE, border=NA, with.legend=FALSE)
dev.off()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.