I have following type of associated data. The following example step to generate associated variable. p number of variables and n is number of observations.
p = 500
n = 200
mat <- matrix(NA, ncol = 500, nrow = 200)
for (i in 1:p){
if(i ==1){
fs <- sample (c("AA", "AB", "AB", "BB"), n, replace=TRUE)
mat[,i] <- fs
fs1 <- fs
}
rechr <- sample(1:n, 1)
fs1[rechr] <- sample (c("AA", "AB", "AB", "BB"), 1)
mat[,i] <- fs1
}
dim(mat)
mat[1:10,1:20]
The above data is complete, but in real dataset I have missing values (which are randomly distributed within each variables).
I would like to predict them using random forest (or any other appropriate algorithms). Let's randomly put 10% missing values (the approximate number of variables) to the above data.
rowind <- sample(1:n, 20)
colind <- sample(1:p, 20)
for (i in 1:length(rowind)){
mat[rowind[i],colind[i]] <- NA
}
mat[1:20,1:10]
How can do this and what issues I need to think up in doing so - considering categorical variables, number of observations and variables ?
Edit: As all variables are correlated and none are response (but can serve as response) while prediction. for example mat[,1] missing value prediction can be based on rest of variables, mat[,2] prediction can be based on prediction of rest of variables. So the objective here is prediction all missing values in all variables (all of them are categorical).
Edit 2
I am interested in multiple imputation of this data so that I can perform other analysis that requires complete dataset without missing value.