0
$\begingroup$

I have the following data (R code):

rm(list=ls())
sampleA<-c(20,30,NA,50,50,30,10,NA)
sampleB<-c(NA,30,40,50,NA,60,20,30)
par(mfrow=c(1,2))
plot(sampleA,xlim=c(0,11),ylim=c(0,60))
plot(sampleB,xlim=c(0,11),ylim=c(0,60))

Is there a way I can infer the NA values with a given degree of confidence?

$\endgroup$
0
$\begingroup$

Not sure how helpful this is with a small sample size but you could infer the NA values with a median call:

median(na.omit(sampleA))
[1] 30

To set NAs to medians you would do something akin to this:

sampleA[is.na(sampleA)] <- median(na.omit(sampleA))
sampleA
[1] 20 30 30 50 50 30 10 30

If you have any other grouping for each sample you could grouped median/means for each of the NA values that belong to a particular group.

$\endgroup$
  • $\begingroup$ Thank you for the answer. I do not think that swapping NA values for the mean or median is appropiate for my data. I was thinking about obtaining the probability density distribution and follow/interpolate in the curve or something like that. Not sure if that is correct though. $\endgroup$ – Charly Nov 27 '17 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.