Skip to content

Commit

Permalink
correct description of CIs for MLR
Browse files Browse the repository at this point in the history
Confidence intervals for coefficients with multiple explanatory variables workflow did not include the point estimates. Removed the hypothesize() command and set generate() to type = "bootstrap" fix the problem. Also removed alternative method for generating null_dist2.
  • Loading branch information
wmorgan485 authored Nov 1, 2023
1 parent 2d11770 commit fe3d3fc
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions vignettes/observed_stat_examples.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1692,41 +1692,30 @@ obs_fit <- gss %>%
fit()
```

Generating a distribution of fits with the response variable permuted,

```{r}
null_dist <- gss %>%
specify(hours ~ age + college) %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
fit()
```

Alternatively, generating a distribution of fits where each explanatory variable is permuted independently,
Then, generating a bootstrap distribution,

```{r}
null_dist2 <- gss %>%
boot_dist <- gss %>%
specify(hours ~ age + college) %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute", variables = c(age, college)) %>%
generate(reps = 1000, type = "bootstrap") %>%
fit()
```

Calculating confidence intervals from the null fits,
Use the bootstrap distribution to find a confidence interval,

```{r}
conf_ints <-
get_confidence_interval(
null_dist,
boot_dist,
level = .95,
point_estimate = obs_fit
)
```

Visualizing the observed fit alongside the null fits,
Visualizing the observed statistic alongside the distribution,

```{r}
visualize(null_dist) +
visualize(boot_dist) +
shade_confidence_interval(endpoints = conf_ints)
```

Expand Down

0 comments on commit fe3d3fc

Please sign in to comment.