hmm.discnp (version 2.1-5)

misstify: Insert missing values.

Description

Insert missing values into data simulated by rhmm.

Usage

misstify(X, nafrac, fep = NULL)

Arguments

X

A data set (list of matrices with one or two columns, or list of such list) generated by rhmm().

nafrac

A scalar probability or a vector of two such probabilities if the data are bivariate. The values should in all cases be numbers between zero and 1. These values represent the fraction of missing values in the data (or in the respective components of the data if the model is bivariate). If the data are bivariate nafrac is duplicated if it is of length 1. If an entry of nafrac is equal to 1, an error is thrown. (Having everything missing makes no sense!)

The fraction(s) of missing values in a given data set may be determined by nafracCalc().

fep

“First entry present”. A list with one or two entries, the first being a logical scalar (which might be named "present". If there is a second entry it should be a scalar probability (which might be named "p2"). In an application of interest, observation sequences always begin at an observed event, i.e. at a time point at which the “emission” has at least one non-missing value. If fep[[1]] is TRUE the NAs will be inserted in such a way that the resulting data have this characteristic. If fep is left NULL then its first (possibly only) entry is set to TRUE.

For bivariate data, fep[[2]] specifies the probabilty that both values of the initial pair of observations are non-missing. In this case one of the entries of the initial pair is chosen to be “potentially” missing, with probabilities nafrac/sum(nafrac). This entry is left non-missing with probability fep[[2]]. (The other entry is always left non-missing.)

If the data are univariate or if fep[[1]] is FALSE, then fep[[2]] is ignored. If the data are bivariate and fep[[2]] is not specified, it defaults to the (estimated) conditional probability that both entries of the initial pair of observations are present given that at least one is present, under the assumption of independence of these events. I.e. it is set equal to prod(1-nafrac)/(1-prod(1-nafrac)).

Value

A list, like that returned by rhmm(). The latter function calls upon misstify() to effect the replacement of observations by the appropriate (or specified) fraction of missing values.

See Also

rhmm() nafracCalc()

Examples

Run this code
# NOT RUN {
P <- matrix(c(0.7,0.3,0.1,0.9),2,2,byrow=TRUE)
R <- matrix(c(0.5,0,0.1,0.1,0.3,
              0.1,0.1,0,0.3,0.5),5,2)
set.seed(42)
lll   <- sample(250:350,20,TRUE)
y     <- rhmm(ylengths=lll,nsim=1,tpm=P,Rho=R,drop=TRUE)
y     <- misstify(y,nafrac=0.5,fep=list(present=TRUE))
# }

Run the code above in your browser using DataCamp Workspace