Hi, I am trying to write R code to produce a power curve to show how the power of a Wilcoxon-test varies depending on the mean, with data generated from a uniform distribution. Any ideas how I should go about this?Louisa _________________________________________________________________ Amazing prizes every hour with Live Search Big Snap [[alternative HTML version deleted]]
Louisa Hay <louisahay <at> msn.com> writes:> > > Hi, > I am trying to write R code to produce a power curve to show > how the power of a > Wilcoxon-test varies depending on the mean, with data > generated from a uniform > distribution. Any ideas > how I should go about this?LouisaHere's a brute-force approach that seems to work reasonably well. Adapt to suit yourself ... wilcox.pval <- function(m2,m1=0,n=20) { x1 <- runif(n,m1-0.5,m1+0.5) x2 <- runif(n,m2-0.5,m2+0.5) wilcox.test(x1,x2)$p.value } wilcox.pow <- function(m2,m1=0,n=20, alpha=0.05, N=500) { pvals <- replicate(N,wilcox.pval(m2,m1,n)) sum(pvals<alpha)/N } mvec <- seq(0,0.5,by=0.05) powvec <- sapply(mvec,wilcox.pow) plot(mvec,powvec)
On 4/14/2008 8:59 AM, Louisa Hay wrote:> Hi, > I am trying to write R code to produce a power curve to show how the power of a > Wilcoxon-test varies depending on the mean, with data generated from a uniform distribution. Any ideas how I should go about this?LouisaI think I gave you enough of a hint to do this one in my previous response to you. Did you read it? (Are we doing your homework for you?) Duncan Murdoch