TraMineRextras (version 0.6.0)

seqgen.missing: Generate random missing states within a state sequence object

Description

The function assigns missing values (nr attribute of the object, which is "*" by default) to randomly selected positions in randomly selected cases.

Usage

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

Arguments

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 "nr" (non response state) or "void"

mt.gaps

Type of gap missing. One of "nr" (non response state) or "void"

mt.right

Type of right missing. One of "nr" (non response state) or "void"

Value

The resulting state sequence object.

Warning

This function needs further testing.

Details

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.

See Also

seqdef

Examples

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

Run the code above in your browser using DataLab