Which R package for Estimating sample size for regression problems
Hello. I am currently taking an online short course that attempts to estimate the sample size. Currently I am trying to estimate the sample size for simple linear regression and multiple regression problems. The course focuses on other software packages to estimate the sample size (Lenth’s applet, Power and Precicion, nQuery, etc.). However, I would like to use R since I am trying to become familer with it and I am still somewhat of a newbie. My question is if anyone knows of any R packages that I could use to estimate the sample size for regression problems?
For example, in one problem in the course notes the sample size should be calculated for a simple linear regression with an R2 = 0.5, significance level = 0.05, and power is 0.8. However, I cannot find an acceptable R package/program where I can estimate the sample size and test statistic (so I can determine if the Wetz criterion is met)?
Also another problem using a multiple regression problem with 3 regressors and trying to estimate the sample size if the objective is to show an R2 = 0.7 with a power of 0.9 (ignoring Wetz criterion) .
Thanks for any help so I can try to answer these questions with R.
• You have power level and error, and need to figure out sample sizes…
Doing some quick research, I found something that may interest you: http://www.ats.ucla.edu/stat/R/dae/t_test_power3.htm
One particular section notes:
In R, it is fairly straightforward to perform a power analysis for the paired sample t-test using R’s pwr.t.test function.
For the calculation of Example 1, we can set the power at different levels and calculate the sample size for each level. For example, we can set the power to be at the .80 level at first, and then reset it to be at the .85 level, and so on. First, we specify the two means, the mean for the null hypothesis and the mean for the alternative hypothesis. Then we specify the standard deviation for the difference in the means. The default significance level (alpha level) is set at .05, so we will not specify it for the initial runs. Last, we tell R that we are performing a paired-sample t-test.
Paired t test power calculation
n = 9.93785
d = 1
sig.level = 0.05
power = 0.8
alternative = two.sided
NOTE: n is number of *pairs*
Granted, you are looking for regression rather than a paired t-test. But I believe this should be very close to what you have in mind. All you’d need to do at that point is switch t-test for the regression you’re trying to perform.
There is a whole package of power functions that you can use to find power or sample size. One of those functions (pwr.f2.test) will do the power for all general models, hence, for example, for regression.
NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!