李俊杰
2007-May-21 03:47 UTC
[R] How to conduct a hypothesis test : Ho:|E(X)|=|E(Y)|<->H1:otherwise NOT R question
Dear R-list,
I am sorry for my shortage of stat knowlege. I want know how to conduct a
hypothesis test : Ho:|E(X)|=|E(Y)|<->H1:otherwise.
Actually, in my study, X and Y is two observations of bias,
where bias=u^hat-u, u is a parameter I concerned. Given X=(u^hat_xi - u) and
Y=(u^hat_yi - u), I want to know which bias is smaller, or the absolute
expection of which is smaller. Due to limit of sample size, I think we
cannot make a conclusion by comparing the absolute mean value of each
sample. So I turn to a means of hypothesis testing as I post in the title.
Now my strategy is using permutation test. Like this:
permutation.test.bias=function(x,y,mc=1000){
n1=length(x)
n2=length(y)
n=n1+n2
xy=c(x,y)
dbar=abs(abs(mean(x))-abs(mean(y)))
z=c()
for(i in 1:mc){
mn=sample(1:n,n1)
z[i]=abs(mean(xy[mn]))-abs(mean(xy[-mn]))
}
p.value=sum(abs(z)>dbar)/mc
p.value
}
Although it seems plausible, this function doesn't
work> n=1000
> x=rnorm(n)+10
> y=rnorm(n)-10
> permutation.test.bias(x,y)
[1] 0
I think there should be other test methods for this problem.
Thanks for any suggestion/solution.
--
Junjie Li, klijunjie@gmail.com
Undergranduate in DEP of Tsinghua University,
[[alternative HTML version deleted]]
Maybe Matching Threads
- How to compare linear models with intercept and those without intercept using minimizing adjs R^2 strategy
- There might be something wrong with cv.lm(DAAG)
- R2 always increases as variables are added?
- Is this a bug in cv.lm(DAAG) ?
- model seleciton by leave-one-out cross-validation
