How does one calculate the non-centrality parameter (t-distribution) in R?
I’m trying to calculate this parameter to perform a power analysis. I want to know the power to detect a future hypothetical 30% increase in a continuous variable (density). I think my alternative=”less than”, but R returns a warning saying the ncp can’t be positive when alternative hypothesis is “less”, so I think my calculation of ncp may be incorrect. I’m using the pwrss::power.t.test and my ncp formula = mean2(the 30% increase of the mean) x sqrt(n) which I got from here: https://stats.stackexchange.com/questions/92993/noncentrality-parameter-what-is-it-what-does-it-do-what-would-be-a-suggested
mean1=0.38
mean2 (30% increase) = 0.4940
sample size per group = 47
1 Expert Answer
Nicholas V. answered 11/20/23
expert computer science tutor
The warning you're encountering in R is due to a misunderstanding of the role of the noncentrality parameter (ncp) in the context of your hypothesis testing and the direction of the alternative hypothesis.
When conducting a power analysis for a t-test with `power.t.test` in R, the `ncp` (non-centrality parameter) is used to specify the effect size you're interested in detecting. This parameter essentially shifts the mean of the distribution under the alternative hypothesis away from the null hypothesis mean, allowing you to determine the power to detect this difference.
However, the direction of this shift must align with your alternative hypothesis. Since you've set `alternative = "less"`, R expects a negative shift (i.e., you are testing for a decrease), but your `ncp` calculation suggests an increase (a positive shift), hence the warning.
Given your scenario where you expect a 30% increase, your alternative hypothesis should be `alternative = "greater"` (testing for an increase). Here's how you can adjust your `power.t.test` function:
1. Change the `alternative` parameter to `"greater"`.
2. Calculate the `ncp` as the difference between the means (mean2 - mean1), multiplied by the square root of the sample size.
Let's modify your code accordingly and calculate the power:
This should provide you with the correct power analysis for detecting a 30% increase in the density variable.
Nathan L.
Awesome, thank you!11/24/23
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Nathan L.
I also want to calculate the power of detecting a 30% decrease, and in both cases, my ncp calculation was positive. Therefore, even if my current question should be "greater" instead of "less" (which fixes the current issue), I still have to deal with the warning for calculating the power to detect a decline.11/14/23