misstify | R Documentation |
Insert missing values into data simulated by rhmm
.
misstify(y, nafrac, fep = NULL)
y |
A data set (vector or matrix with one or two columns, whose
entries consitute discrete data, or a list of such vectors
or matrices) or a list of such data sets (objects of class
|
nafrac |
A numeric vector, some entries of which could be ignored. (See below.) Those which do not get ignored must be probabilities strictly less than 1. (Having everything missing makes no sense!) The vector Note that replication discards entries that are not needed to
make up the required length, and such entries are thereby ignored.
E.g. The fraction(s) of missing values in a given data set may be
determined by |
fep |
“First entry present”. A list with one or two
entries, the first being a logical scalar (which might be named
For bivariate data, If the data are univariate or if |
An object with a structure similar to that of y
, containing
the same data as y
but with some of these data having been
replaced by missing values (NA
). In particular, if y
is of class "multipleHmmDataSets"
then so is the returned
value.
Note that rhmm()
calls upon misstify()
to effect
the replacement of a certain fraction of the simulated observations
by missing values. If rhmm()
is applied to a fitted model,
then by default, this “certain fraction” is determined, using
nafracCalc()
, from the data set to which the model was fitted.
Rolf Turner
r.turner@auckland.ac.nz
rhmm()
nafracCalc()
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) y1 <- rhmm(ylengths=lll,nsim=1,tpm=P,Rho=R) y1m <- misstify(y1,nafrac=0.5,fep=list(TRUE)) y2 <- rhmm(ylengths=lll,nsim=5,tpm=P,Rho=R) set.seed(127) y2m <- misstify(y2,nafrac=0.5,fep=list(TRUE)) nafracCalc(y2m) # A list all of whose entries are close to 0.5. set.seed(127) y2ma <- lapply(y2,misstify,nafrac=0.5,fep=list(TRUE)) ## Not run: nafracCalc(y2ma) # Throws an error. ## End(Not run) sapply(y2ma,nafracCalc) # Effectively the same as nafracCalc(y2m).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.