[R] power.t.test threading on 'power'

Stephen Kennedy stephen at prollenium.com
Wed Oct 1 14:29:16 CEST 2014


Simple question.  A vector of ‘number of observations’ can be input to power.t.test, and a vector of ‘power’ s is output.  But, inputting a vector of powers generates an error.  Am I missing something?

Vector of ’n’ s

power.t.test(n=c(28,29,30), delta=2, sd=3, sig.level=0.05, type="two.sample", alternative="one.sided")

     Two-sample t test power calculation 

              n = 28, 29, 30
          delta = 2
             sd = 3
      sig.level = 0.05
          power = 0.7933594, 0.8058963, 0.8177506
    alternative = one.sided

NOTE: n is number in *each* group



Vector of ‘power’ s

power.t.test(power=c(0.7,0.8,0.9), delta=2, sd=3, sig.level=0.05, type="two.sample", alternative="one.sided")
Error in uniroot(function(n) eval(p.body) - power, c(2, 1e+07)) : 
  f() values at end points not of opposite sign
In addition: Warning messages:
1: In if (is.na(f.lower)) stop("f.lower = f(lower) is NA") :
  the condition has length > 1 and only the first element will be used
2: In if (is.na(f.upper)) stop("f.upper = f(upper) is NA") :
  the condition has length > 1 and only the first element will be used



Thanks,

Steve


More information about the R-help mailing list