@@ -1291,6 +1291,56 @@ visualize(sampling_dist) +
1291
1291
1292
1292
Note that the ` t ` distribution is recentered and rescaled to lie on the scale of the observed data.
1293
1293
1294
+ ` infer ` also provides functionality to calculate ratios of means. The workflow looks similar to that for ` diff in means ` .
1295
+
1296
+ Finding the observed statistic,
1297
+
1298
+ ``` {r}
1299
+ d_hat <- gss %>%
1300
+ specify(hours ~ college) %>%
1301
+ calculate(stat = "ratio of means", order = c("degree", "no degree"))
1302
+ ```
1303
+
1304
+ Alternatively, using the ` observe() ` wrapper to calculate the observed statistic,
1305
+
1306
+ ``` {r}
1307
+ d_hat <- gss %>%
1308
+ observe(hours ~ college,
1309
+ stat = "ratio of means", order = c("degree", "no degree"))
1310
+ ```
1311
+
1312
+ Then, generating a bootstrap distribution,
1313
+
1314
+ ``` {r}
1315
+ boot_dist <- gss %>%
1316
+ specify(hours ~ college) %>%
1317
+ generate(reps = 1000, type = "bootstrap") %>%
1318
+ calculate(stat = "ratio of means", order = c("degree", "no degree"))
1319
+ ```
1320
+
1321
+ Use the bootstrap distribution to find a confidence interval,
1322
+
1323
+ ``` {r}
1324
+ percentile_ci <- get_ci(boot_dist)
1325
+ ```
1326
+
1327
+ Visualizing the observed statistic alongside the distribution,
1328
+
1329
+ ``` {r}
1330
+ visualize(boot_dist) +
1331
+ shade_confidence_interval(endpoints = percentile_ci)
1332
+ ```
1333
+
1334
+ Alternatively, use the bootstrap distribution to find a confidence interval using the standard error,
1335
+
1336
+ ``` {r}
1337
+ standard_error_ci <- boot_dist %>%
1338
+ get_ci(type = "se", point_estimate = d_hat)
1339
+
1340
+ visualize(boot_dist) +
1341
+ shade_confidence_interval(endpoints = standard_error_ci)
1342
+ ```
1343
+
1294
1344
### One numerical variable, one categorical (2 levels) (t)
1295
1345
1296
1346
Finding the standardized point estimate,
0 commit comments