Displaying 2 results from an estimated 2 matches for "idmiss".
Did you mean:
amiss
2011 Jun 03
3
Not missing at random
...lt;- 30 ####percent of missing values
N <- dim(x)[1] ####number of cases
candidate<-which(x[,1]<3 | x[,2]<3 | x[,3]<3 | x[,4]<3 | x[,5]<3 | x[,6]<3 |
x[,7]<3) #### I want to sample all cases with at least 1 value lower than 3,
so I have to find candidates
idMiss <- sample(candidate, N * p / 100) #### I sampled cases
Any suggestion?
Thanks,
Blaž
[[alternative HTML version deleted]]
2011 Jun 01
1
Missing completely at random
...ng completely at random). I managed to
sample cases and variables, but I don’t know how to set them as NA.
R code:
N <- 1000 ####number of cases
n <- 12 ####number of variables
X <- matrix(rnorm(N * n), N, n) ####matrix
pMiss <- 0.05 ####percent of missing values
idMiss <- sample(1:N, N * pMiss) ####sample cases
nMiss <- length(idMiss)
m <- 3 ####maximum number of missing variables within selected cases
howmanyMiss <- sapply(idMiss, function(x) sample(1:m, 1))
howmanyMiss
lapply(howmanyMiss, function(x) sample(1:n, x))
Any suggestion?
Thanks,
B...