[R] power.t.test threading on 'power'
Stephen Kennedy
stephen at prollenium.com
Thu Oct 2 03:46:05 CEST 2014
Thanks. I only use R on occasion, but I knew I could work around it easily (and in fact some other users were nice enough to send some code).
When it only worked when inputting n, I thought it might be just an accident, but thought I would ask.
Thanks for the explanation.
Best,
Steve
On Oct 1, 2014, at 6:46 PM, peter dalgaard <pdalgd at gmail.com> wrote:
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