+1 vote
560 views
in Report bugs/errors by José (130 points)

Hello, I cannot calculate the number of clusters needed in a Cluster randomized trial, using wp.crt2arm in R. I don't know if it's a software problem. The message is as follows:

> wp.crt2arm(f=0.6,n=30,J=NULL, icc=.2,power=.8)

Error in nuniroot(function(J) eval(p.body) - power, ifelse(is.null(interval),: Please provide an interval with two values such as c(0,1).

by betsy (110 points)

To add to this, I am re-running code that I believe worked in July 2020 but now throws this same error. When I seek power as the answer (by leaving it NULL), wp.crt2arm works fine, but if I'm running it looking for J, then it gives this interval error.

I'm not sure exactly what function is being solved by nuniroot under the hood, so I don't know what interval it should search for this root. If I attempt to specify an interval it still returns the same error (even if I try very different intervals):

> wp.crt2arm(f = effect, n = 800, J=NULL,  icc = 0.06, alpha = alpha, power = 0.8, interval=c(0,1))

Error in nuniroot(function(J) eval(p.body) - power, ifelse(is.null(interval),  : 

  Please provide an interval with two values such as c(0,1).

The three-arm version seems to run fine, e.g.

wp.crt3arm(f = effect, n = 40, icc = 0.06, alpha = alpha, power = 0.8, type = c("main"))

by Rosaly (100 points)
I came across this post when using the command myself. Do you know if the 'f' effect size here is Cohen's f or Cohen's d? F would make more sense to me as they call it f, but sometimes I see examples with an effect size that would be very big for it to be Cohen's f.

Also, were you able to solve this error; I am getting the same error?

1 Answer

0 votes
by johnny (3.3k points)

It worked fine on my computer, see the output. I am using WebPower version 0.5.2.

> wp.crt2arm(f=0.6,n=30,J=NULL, icc=.2,power=.8)

Cluster randomized trials with 2 arms

           J  n   f icc power alpha

    21.86552 30 0.6 0.2   0.8  0.05

NOTE: n is the number of subjects per cluster.

URL: http://psychstat.org/crt2arm

...