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

peter dalgaard pdalgd at gmail.com
Thu Oct 2 00:46:33 CEST 2014


On 01 Oct 2014, at 14:29 , Stephen Kennedy <stephen at prollenium.com> wrote:

> 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?

Power.t.test was written for scalar arguments. If it happens to work with vector arguments, it is entirely coincidental. The essence of what you observe is that power is calculated by pt() which vectorizes, but n is calculated by numerical solution using uniroot() which does not vectorize. 

If you need a vectorized version, check out Vectorize().

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list