[R] Function for testing

a.b.carter a.b.carter at hotmail.com
Thu Jun 21 15:24:16 CEST 2012


Hi all,

I want to create a sample called x, with length 10 from a N(0,1)
distribution. Next to that I want to create a sample called y, with length
10 from a N(0.5 ,1) distribution. Both samples are undergoing a t.test.
The outcome must be that I can see how many times for x H0 was rejected. The
same for y. I am testing under a confidence level of 0.05
Down below is the function I must use:

pv=function(n=10,N=100,m=1,...){
resx=numeric(N)
resy=numeric(N)
for (i in 1:N){
x=rnorm(n)
y=rnorm(n,m)
resx[i]=t.test(x,...)[[3]]
resy[i]=t.test(y,...)[[3]]
}
z=list(resx,resy)
names(z)=c("px","py")
z}

So I compute pv(10,100,0.5) which gives me p-values in px and py. But
somewhere I must give a statement (I think at the ... but that gives me
errors) that px<0.05 so I can see how many times H0 was rejected. Thus, the
values that are computed must be compared with the statement <0.05.

--
View this message in context: http://r.789695.n4.nabble.com/Function-for-testing-tp4634109.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list