# Bootstrap: How to do a Confidence interval for the difference of two means? (Different sample distributions) [duplicate]

Can I apply a bootstrap from 2 samples that have different non-parametric distributions to get their mean difference?

Can I do that with 2 group of data, that are non-parametric and have different distribution? Because in the other questionexample, it didn't say if the 2 samples had the same distribution or not.

EDIT:

I'm trying to do it with this code, but my concern is that I don't know if I can do it on this case. (2 non-parametric distribution that are different)

Code:

    bt <- function(data1,data2,n){
btr<<- c()
for(i in 1:n) {
m1 <- mean(sample(data1,length(data1), replace=TRUE, prob=NULL))
m2 <- mean(sample(data2,length(data2), replace=TRUE, prob=NULL))
btr[i] <<- m1-m2
}
quantile(btr, .500) # median
quantile(btr, .025) # 2.5th percentile
quantile(btr, .975) # 97.5th percentile
}


## marked as duplicate by Michael Chernick, Carl, kjetil b halvorsen, John, Nick CoxFeb 10 '17 at 7:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• I'm not sure what you are trying to do, but you might want to do a 2-sample t-test which is kind of similar. You can yield a significance value that would be useful in figuring out if the two samples are from the same distribution or not. – user1367204 Feb 9 '17 at 23:34
• I would just sample with replacement each original sample. After each sampling I would calculate difference of means. Then I would collect these differences in 1 distribution. From this distribution it is easy to obtain CI. I am not good in R. If you wish I may post MATLAB code – zlon Feb 9 '17 at 23:44
• Your question is more about the answer to another question rather than in independent question in its own right. What the other answer says is to resample with replacement in both populations simultaneously, and make paired differences. – Carl Feb 9 '17 at 23:48
• Thank you for you comments. Basically, I have to 2 group of data, non-normal and that has different distribution. How can I do a test of mean difference? So, I was thinking of bootstrap to conclude in CI to see if there is any significance in the mean difference. – Slobodanip Feb 9 '17 at 23:56
• @Carl Yes, indeed. But my question is, Can I do that with 2 group of data, that are non-parametric and have different distribution? Because in the other question, it didn't say if the 2 samples had the same distribution or not... – Slobodanip Feb 10 '17 at 0:20