Solution (source code)

= Solution

For the gamma <variance function>, the <Pearson dispersion estimator> is
$$
\widehat\phi=\frac1{57}\sum_{i=1}^{61}\frac{(Y_i-\widehat\mu_i)^2}{\widehat\mu_i^2},
$$
using $61-4=57$ <residual degrees of freedom>. Under a specified null dispersion $\phi_0$, the scaled statistic based on squared <Pearson residuals> $57\widehat\phi/\phi_0$ has an approximate $\chi^2_{57}$ distribution under the usual residual approximation.

Thus `test1` corresponds to $H_0:\phi=1$, equivalently gamma shape $\alpha=1$, the <exponential distribution>. `test2` corresponds to $H_0:\phi=1/3$, equivalently shape $\alpha=3$. \b[The null hypotheses concern dispersion or shape, not whether the regression coefficients vanish.]

The code computes lower-tail probabilities. Used as one-sided tests, the alternatives are $\phi<1$ and $\phi<1/3$, respectively, equivalently shapes larger than one and three. At the 5% level the first null is rejected because the lower-tail probability is $1.199504\times10^{-7}$, while the second is not rejected because its probability is $0.3768748$. If the intended alternatives are two-sided, $\phi\ne\phi_0$, these displayed numbers must not be called two-sided <p-values>: doubling the smaller tail gives approximately $2.40\times10^{-7}$ and $0.75375$, with the same decisions. The <chi-squared distribution> approximation is not an exact finite-sample gamma identity.