-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated page "look" using quarto.
- Loading branch information
Showing
379 changed files
with
11,433 additions
and
36,311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
.Rhistory | ||
.RData | ||
.Ruserdata | ||
|
||
/.quarto/ |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"hash": "2a7be4d1a1afd35526b7fe1678bde179", | ||
"result": { | ||
"markdown": "---\ntitle: \"Comparing variances: Fisher's F-test\"\neditor_options: \n chunk_output_type: console\n---\n\n\n*Last modified on 2022-09-12*\n\n\n::: {.cell}\n\n:::\n\n::: {.cell}\n\n:::\n\n\n\n\nThe test of variances requires that the two sampled population be normally distributed and that the samples are randomly selected from their respective populations.\n\n# Introduction\n\nThe method is simple; it consists of taking the ratio between the larger population variance, $\\sigma_1^2$, and the smaller population variance, $\\sigma_2^2$, then looking up the ratio on an $F$-distribution curve. The null hypothesis states that the ratio equal 1,\n\n$$\nH_o: \\frac{\\sigma_1^2}{\\sigma_2^2} = 1\n$$\n\nand the alternate hypothesis states that the ratio differs from 1 (i.e. the variances differ),\n\n$$\nH_a: \\frac{\\sigma_1^2}{\\sigma_2^2} \\neq 1\n$$\n\nor is greater than 1 (i.e. $\\sigma_1^2$ is significantly bigger than $\\sigma_2^2$),\n\n$$\nH_a: \\frac{\\sigma_1^2}{\\sigma_2^2} \\gt 1\n$$\n\n\nSince the larger variance is assigned to the numerator by convention, we do not have a situation where the ratio is less than 1.\n\nSince we are working with samples, we work with the sample variances $s_1^2$ and $s_2^2$ and compute the test statistic $F$ as follows:\n\n$$\nF = \\frac{s_1^2}{s_2^2}\n$$\n\n\nThe shape of the $\\pmb F$**-distribution** curve is defined by both sample's $df$'s, i.e. $(n_1-1)$ and $(n_2-1)$. Like the $\\chi^2$ distribution, the $F$ distribution tends to be skewed to the right, especially for large $df$'s.\n\n# Example 1\n\nIn one of the examples in the _$z$ and $t$ test_ [tutorial](z_t_tests.html#example-1), we seek to compare the concentration of sulfates between background sites and a contaminated well (data taken from Millard _et al._, p. 418). Did the two samples have equal variances? The table of concentrations is reproduced here.\n\nContaminated Background\n--------------- -------------------\n600 560\n590 550\n570 570\n570 550\n565 570\n580 590\n 550\n 580\n\n## Solution to example 1\n\nThe variances for both samples are $s_{Ref}^2 = 712.5$ and $s_{Cont}^2 = 336.7$. Since $s_{Ref}^2 > s_{Cont}^2$, the value $s_{Ref}^2$ will be in the numerator giving us the following test statistic:\n\n\n$$\nF = \\frac{s_{Ref}^2}{s_{Cont}^2} = \\frac{712.5}{336.7} = 2.12\n$$\n\n\nNext, we must determine where the $F$ statistic lies along the $F$-distribution curve. This requires that we compute the two $df$'s from the samples to define the shape of the $F$ distribution:\n\n$$\ndf_{Ref} = 8 - 1 = 7\n$$\n\n$$\ndf_{Cont} = 6 - 1 =5\n$$\n\n\nNow that we have the shape of the $F$-distribution defined, we can look up the probability of getting an $F$ statistic as extreme as ours, An F-distribution table can be used, or the value can be computed exactly using the function `pf()`:\n\n\n::: {.cell}\n\n```{.r .cell-code}\npf(2.12, 7, 5, lower.tail=FALSE)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] 0.2126279\n```\n:::\n:::\n\n::: {.cell}\n::: {.cell-output-display}\n![](F_test_files/figure-html/unnamed-chunk-3-1.png){width=672}\n:::\n:::\n\n\nThe $F$ values associated with a probability of 0.025 and 0.975 (associated with rejection regions for a two-tailed $\\alpha$ of 0.05) are displayed on the curve in grey dashed vertical lines.\n\nThe probability of getting an $F$ as large as ours is about 0.21 (or 21%). Since $H_a$ represents _both_ sides of the distribution, we double the probability to give us the chance of getting a test statistic as great or as small as ours, so for a two-tailed test, $P=0.42$. With such a high $P$-value, we cannot reject the null and therefore can state that for all intents and purposes, the variances between both populations are the same (i.e. the observed variability between both $s$ can be explain by chance alone).\n\nThe following figure shows the observed $P$ values in both tails.\n\n\n::: {.cell}\n::: {.cell-output-display}\n![](F_test_files/figure-html/unnamed-chunk-4-1.png){width=672}\n:::\n:::\n\n\nThis can be easily executed in `R` as a two-tailed test as shown in the following code block:\n\n\n::: {.cell}\n\n```{.r .cell-code}\nRef <- c(560, 530, 570, 490, 510, 550, 550, 530)\nCont <- c(600, 590, 590, 630, 610, 630)\nvar.test(Ref, Cont, alternative=\"two.sided\")\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n\n\tF test to compare two variances\n\ndata: Ref and Cont\nF = 2.1163, num df = 7, denom df = 5, p-value = 0.4263\nalternative hypothesis: true ratio of variances is not equal to 1\n95 percent confidence interval:\n 0.3088156 11.1853404\nsample estimates:\nratio of variances \n 2.116337 \n```\n:::\n:::\n\n\nNote that the `var.test()` computes the $F$ ratio using the first variable name in the list as the numerator. For example, had we reversed the order of variables (i.e. `var.test(Cont, Ref, alternative=\"two-sided\")`), the returned $F$ value would be the inverse of the original $F$ value, or $1/2.12 = 0.47$. The $P$ value would have stayed the same however.\n\n# Example 2\n\nAn investor is concerned that stock 1 is a riskier investment than stock 2 because its variation in daily prices is greater. The following table provides summary statistics for a sample of 25 daily price changes. \n\n Stock 1 Stock 2\n------------------- --------- --------\nSample size 25 25\nStandard deviation .76 .46\n\nIs stock 1's variability significantly greater than that of stock 2, or is the observed difference due to chance? \n_[This example is adapted from McCLave et al. page 461]_\n\n## Solution to example 2\n\nWe are asked to test the hypothesis, $H_o$, that the two stock have equal variances and that any observed difference is due to chance (i.e. $\\sigma_1^2 = \\sigma_2^2$). The alternate hypothesis, $H_a$, states that stock 1 has greater variability than stock 2 (i.e. $\\sigma_1^2 > \\sigma_2^2$).\n\nSince we are given summary statistics of the samples and not the full dataset, we cannot use the `var.test()` function which requires the full dataset as input. Instead, we will compute the $F$ ratio and observed probabilities separately.\n\nThe $F$ ratio is:\n\n$$\nF = \\frac{(.76)^2}{(.46)^2} = 2.73\n$$\n\n\nThe degrees of freedom are $(25 - 1) = 24$ for both samples.\n\nThe probability of getting a test statistic as extreme as ours can be computed using the `pf()` function:\n\n\n::: {.cell}\n\n```{.r .cell-code}\npf( 2.73, 24, 24, lower.tail = FALSE)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n[1] 0.008502252\n```\n:::\n:::\n\n\nNote that we are using the `lower.tail = FALSE` option since our alternate hypothesis is that $\\sigma_1^2 > \\sigma_2^2$. This gives us a probability of $0.008$, in other words, if the difference between stock 1 and stock 2 were explained by chance variability alone, there would be lest than a 1% chance of computing a $F$ ratio as extreme as ours. We can safely reject $H_o$ and state that the observed difference is real and that stock 1 has greater daily variability than stock 2.\n\n\n::: {.cell}\n::: {.cell-output-display}\n![](F_test_files/figure-html/unnamed-chunk-7-1.png){width=672}\n:::\n:::\n\n\n\n# References\n\nFreedman D.A., Robert Pisani, Roger Purves. _Statistics_, 4th edition, 2007. \nMcClave J.T., Dietrich F.H., _Statistics_, 4th edition, 1988. \n\n-----\n\n**Session Info**:\n\n\n::: {.cell-output-display}\n**R version 4.2.1 (2022-06-23 ucrt)**\n\n**Platform:** x86_64-w64-mingw32/x64 (64-bit) \n\n\n**attached base packages:** \n_stats_, _graphics_, _grDevices_, _utils_, _datasets_, _methods_ and _base_\n\n**loaded via a namespace (and not attached):** \n_Rcpp(v.1.0.9)_, _digest(v.0.6.29)_, _Rttf2pt1(v.1.3.8)_, _jsonlite(v.1.8.0)_, _magrittr(v.2.0.3)_, _evaluate(v.0.16)_, _rlang(v.1.0.4)_, _stringi(v.1.7.8)_, _cli(v.3.3.0)_, _rstudioapi(v.0.14)_, _extrafontdb(v.1.0)_, _rmarkdown(v.2.16)_, _extrafont(v.0.18)_, _tools(v.4.2.1)_, _pander(v.0.6.5)_, _stringr(v.1.4.1)_, _xfun(v.0.32)_, _yaml(v.2.3.5)_, _fastmap(v.1.1.0)_, _compiler(v.4.2.1)_, _htmltools(v.0.5.3)_ and _knitr(v.1.40)_\n:::\n\n\n\n[1]: http://www.amstat.org/sections/srms/pamphlet.pdf\n", | ||
"supporting": [ | ||
"F_test_files" | ||
], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"headings":["introduction","how-a-one-way-anova-is-calculated","the-variance-ratio-method","an-example-in-r","computing-anova-the-hard-way","computing-anova-the-easy-way","anova-as-a-regression","assumptions-of-anova","identifying-which-levels-are-different","bonferroni","tukeys-hsd","assumptions-of-the-post-hoc-test","another-working-example","two-way-anova","checking-for-interaction-non-additive-model","extracting-effects-for-each-level","references"],"entries":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"headings":["introduction","estimate-of-a-population-statistic-from-many-samples","estimate-of-a-population-statistic-from-a-single-sample","a-universal-approach-to-computing-the-standard-error-the-bootstrap","confidence-intervals","references"],"entries":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"headings":["introduction","estimate-of-a-population-statistic-from-many-samples","estimate-of-a-population-statistic-from-a-single-sample","a-universal-approach-to-computing-the-standard-error-the-bootstrap","confidence-intervals","references"],"entries":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"entries":[],"headings":["introduction","single-factor-classification","example","problem","solution","the-chi2-curve-explained","can-the-chi2-value-be-too-good","two-factor-classification","example-1","problem-1","solution-1","three-or-more-factor-classification","inferences-about-population-variance","computing-confidence-intervals-for-variances","example-2","solution-2","test-hypotheses-on-population-variances","example-3","solution-3","references"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"headings":["introduction","example-1","solution-to-example-1","example-2","solution-to-example-2","references"],"entries":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"entries":[],"headings":["introduction","the-logistic-regression-model","assessing-the-fit-with-a-pseudo-r2","alternative-pseudo-r2","assessing-the-significance","model-significance","parameter-significance","multi-variable-model"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"headings":[],"entries":[]} |
Oops, something went wrong.