* Load the Theil textile data set with the DEMO command. ?DEMO * COMPUTING THE POWER OF A TEST * For an OLS regression, calculate a power function for testing the * null hypothesis that the coefficient on log income is one against * a 2-sided alternative. sample 1 17 * Convert data to base 10 logs as implemented by Theil. genr lconsume=log(consume)/2.3026 genr lincome=log(income)/2.3026 genr lprice=log(price)/2.3026 * Run OLS and save the coefficients. Assume these are the true coefficients. ols lconsume lincome lprice / coef=beta * Assume the OLS sigma**2 is the true value. gen1 sig2=$sig2 sample 1 1 * Set a 5% significance level. genr alpha=.05 * Find the critical value for the rejection of the null hypothesis. distrib alpha / type=f df1=1 df2=14 inverse genr cr=$crit * Dimension room for 11 values of the power function. dim p 11 b 11 * Turn off the DO-loop echoing of commands. set nodoecho nooutput do #=1,11 * Let the "true" income coefficient (beta:1) vary between .5 and 1.5. * The other coefficients are unchanged. genr beta:1=.4+.1*# * Store the hypothesised values of the income coefficient in the vector b. genr b:#=beta:1 sample 1 17 * Calculate OLS regression results using the "true" beta and sig2. * These results are then used as input for the TEST command that follows. ols lconsume lincome lprice / incoef=beta insig2=sig2 test lincome=1 * Temporary variables available from the TEST command are the * degrees of freedom saved in $df1 and $df2 and the chi-square * test statistic saved in $chi. The latter is used as the * non-centrality parameter. sample 1 1 distrib cr / type=f df1=$df1 df2=$df2 c=$chi cdf=cdf * p is the power (the probability of rejecting the false null hypothesis). genr p:#=1-cdf endo * List the power function sample 1 11 print b p graph p b / lineonly stop