Section10.6Simulation-based inference for multiple linear regression
Subsection10.6.1Confidence intervals for the partial slopes using infer
Weβll now use the simulation-based methods you previously learned in Chapters 8 and 9 to compute ranges of plausible values for partial slopes with multiple linear regression. Recall that simulation-based methods provide an alternative to the theory-based methods in that they do not rely on the assumptions of normality or large sample sizes. Weβll use the infer package as we did with simple linear regression in SectionΒ 10.3, but this time using the fit() function.
Subsubsection10.6.1.1Getting the observed fitted model
We will revisit using our full model on the coffee_data with the factor of continent_of_origin and three numerical regressors in aroma, flavor, and moisture_percentage. As we did with hypothesis testing in Chapter 9 and in SubsectionΒ 10.3.2, we can retrieve the observed statistic. In this case, we get the observed coefficients of the model using the specify() function on our full model with formula syntax combined with fit():
# A tibble: 7 Γ 2
term estimate
<chr> <dbl>
1 intercept 37.3214
2 aroma 1.73160
3 flavor 4.31600
4 moisture_percentage -0.00807976
5 continent_of_originAsia -0.392936
6 continent_of_originNorth America -0.273427
7 continent_of_originSouth America -0.478137
These values match the regression table for mod_mult as shown in TableΒ 10.6.1. The observed_fit values will be our point estimates for the partial slopes in the confidence intervals.
Subsubsection10.6.1.2Bootstrap distribution for the partial slopes
We will now find the bootstrap distribution for the partial slopes using the infer workflow. Just like in SubsectionΒ 10.3.1, we are now resampling entire rows of values to construct the bootstrap distribution for the fitted partial slopes using our full sample of 207 coffees:
specify() the variables of interest in coffee_data with the formula: total_cup_points ~ aroma + flavor + moisture_percentage + continent_of_origin.
generate() replicates by using bootstrap resampling with replacement from the original sample of 207 coffees. We generate reps = 1000 replicates using type = "bootstrap" for a total of \(207 \cdot 1000 = 207{,}000\) rows.
Since we have 7 coefficients in our model corresponding to the intercept, three levels of continent_of_origin, aroma, flavor, and moisture_percentage, we have 7 rows for each replicate. This results in a total of 7000 rows in the boot_distribution_mlr data frame. We can visualize the bootstrap distribution for the partial slopes in FigureΒ 10.6.2.
Subsubsection10.6.1.3Confidence intervals for the partial slopes
As we did in SubsectionΒ 10.3.1, we can construct 95% confidence intervals for the partial slopes. Here, we focus on using the percentile-based method with the get_confidence_interval() function and type = "percentile" to construct these intervals.
In reviewing the confidence intervals, we note that the confidence intervals for aroma and flavor do not include 0. This suggests that they are statistically significant. This indicates that aroma and flavor have a meaningful and reliable impact on the response variable in the presence of other predictors.
We also note that 0 is included in the confidence interval for moisture_percentage. This again provides evidence that it might not be a useful regressor in this multiple linear regression model. This implies that moisture_percentage does not significantly contribute to explaining the variability in the response variable after accounting for other predictors in the model.
Subsection10.6.2Hypothesis testing for the partial slopes using infer
We can also conduct hypothesis tests for the partial slopes in multiple linear regression. We use the permutation test to test the null hypothesis \(H_0: \beta_i = 0\) versus the alternative hypothesis \(H_A: \beta_i \neq 0\) for each of the partial slopes. The infer package constructs the null distribution of the partial slopes under the null hypothesis of independence.
We can also compute the null distribution for the partial slopes using the infer workflow. We will shuffle the values of the response variable total_cup_points across the values of the regressors continent_of_origin, aroma, flavor, and moisture_percentage in the coffee_data dataset. This is done under the assumption of independence between the response and the regressors. The syntax is similar to constructing the bootstrap distribution, but we use type = "permute" and set hypothesize to null = "independence". We set our pseudo-random number generation seed to 2024 in order for the reader to get the same results with the shuffling.
We can now conduct hypothesis tests for the partial slopes in multiple linear regression. We can use the permutation test to test the null hypothesis \(H_0: \beta_i = 0\) versus the alternative hypothesis \(H_A: \beta_i \neq 0\) for each of the partial slopes. Letβs use a significance level of \(\alpha = 0.05\text{.}\) We can visualize the \(p\)-values in the null distribution by comparing them to the observed test statistics. We do this by adding a shade_p_value() layer to visualize().
From these visualizations in FigureΒ 10.6.4, we can surmise that aroma and flavor are statistically significant, as their observed test statistics fall far to the right of the null distribution. On the other hand, moisture_percentage is not statistically significant, as its observed test statistic falls within the null distribution. We can also compute the numerical \(p\)-values using the get_p_value() function.
null_distribution_mlr |>
get_p_value(obs_stat = observed_fit, direction = "two-sided")
# A tibble: 7 Γ 2
term p_value
<chr> <dbl>
1 aroma 0.034
2 continent_of_originAsia 0.332
3 continent_of_originNorth America 0.56
4 continent_of_originSouth America 0.352
5 flavor 0
6 intercept 0
7 moisture_percentage 0.918
These results match up with our findings from the visualizations of the shaded \(p\)-values with the null distribution and in the regression table in TableΒ 10.5.3. We reject the null hypothesis \(H_0: \beta_i = 0\) for aroma and flavor, but fail to reject it for moisture_percentage.
B. Bootstrap resampling approximates the sampling distribution of each partial slope, allowing confidence intervals to be constructed without strong distributional assumptions.
A. If the 95% CI for a partial slope includes 0, we cannot rule out the possibility that \(\beta_j = 0\text{,}\) meaning the variable may not have a statistically significant relationship with the response.
In hypothesis testing for the partial slopes using permutation tests, what does it mean if an observed test statistic falls far to the right of the null distribution?
C. If the observed test statistic falls far outside the null distribution, there is strong evidence against the null hypothesis, suggesting the partial slope is significantly different from zero.