;
> Xmiss <- X
>
> Xmiss[ids] <- NA
>
> Xmiss
>
> ____
> From: Joshua Wiley
> To: Blaz Simcic
> Cc: r-help@r-project.org
> Sent: Mon, June 6, 2011 10:34:38 PM
> Subject: Re: [R] Not missing at random
>
> Hi Blaz,
>
>
Hi Blaz,
See below.
x <-
matrix(c(1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,3,3,3,4),
nrow = 7, ncol=7, byrow=TRUE) matrix
pMiss <- 30 percent of missing values
N <- dim(x)[1] number of cases
candidate <- which(x[,1]<3 | x[,2]<
Hello!
Â
I would like to sample 30 % of cases (with at least 1 value lower than 3 - in
the row) and among them I want to set all values lower than 3 (within selected
cases) as NA (NMAR- Not missing at random). I managed to sample cases, but I
donât know how to set values (lower than 3) as N
Hi:
Try this:
x <- matrix(c(rep(1:5, 9), rep(3, 3), 4), ncol = 7, byrow = TRUE)
## indices of x for which the value is less than 3
candidates <- which(x < 3, arr.ind = TRUE)# generates 18 candidates
grabs <- sample(nrow(candidates), 15) # 15/49 ~ 0.3
x2 <- x# copy x
x2[candidates
Hello!
Â
I would like to sample 30 % of cases (with at least 1 value lower than 3) and
among them I want to set all values lower than 3 (within selected cases) as NA
(NMAR- Not missing at random). I managed to sample cases, but I donât know
how
to set values (lower than 3) as NA.
Â
R code:
5 matches
Mail list logo