#create a stochastic impuation function to easily create results over different missing rates StochasticImpute_rep <- function(data, missing_rate) { X.raw=data #create dataframe that is just the marker data X=X.raw#create a copy of the dataframe to work on #Set variables to be used to randomize missing values n=nrow(X.raw) #rows of data m=ncol(X.raw) #columns of data dp=m*n #dp gives the total # of data points - use for % calculation later uv=runif(dp) #uniform variable #We are now ready to set each missing rate mr1=missing_rate# missing rate (how much percentage of data is NA) #Converts each uniform vector into a series of TRUE/FALSE where each TRUE is a missing variable missing1=uv