An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120520/3d2b815a/attachment.pl>
question about sign test
2 messages · T Bal, Joshua Wiley
Hi, That seems a reasonable enough approach to me. (p <- pnorm(0, mean = 1, sd = .5)) is the probability of a value being less than or up to 0 from the distribution you specified. Using that, lets repeat your little test 1000 times using your code, and then using ribnom() where the probability that a value is 1 is 1 - p (i.e., if p is the probability <= 0, then 1 - p is the probability of > 0). res1 <- replicate(1000, binom.test(sum(rnorm(15, 1, 0.5) > 0), 15, p = 0.5, alternative="two")$p.value) res2 <- replicate(1000, binom.test(sum(rbinom(15, 1, 1 - p)), 15, p = 0.5, alternative="two")$p.value) now we can look at the average p-value from both techniques: mean(res1) mean(res2) they are quite similar. I ran each of them with 100,000 replicates for stability and got:
mean(res1)
[1] 0.0007627936
mean(res2)
[1] 0.0007608844 I hope this helps, Josh
On Sun, May 20, 2012 at 9:34 AM, T Bal <studenttbal at gmail.com> wrote:
Hi, I want to compute p value of sign test for sample size=15 from normal distr., sd=0.5, mean=1, alternative should be two sided. Is this code correct in this situation? ?binom.test(sum(rnorm(15,1,0.5)>0),15,p=0.5,alternative="two")$p.value Or should I use another code (function) e.g. rbinom? Thank you very much. kind regards, T. Bal ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/