forked from PeterKDunn/SRM-Textbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
52-App-Symbols.Rmd
244 lines (195 loc) · 8.89 KB
/
52-App-Symbols.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# Symbols, formulas, statistics and parameters {#StatisticsAndParameters}
## Symbols and standard errors {#Symbols}
(ref:DEFSamplingDistributionPhat) Def. \@ref(def:DEFSamplingDistributionPhat)
(ref:DEFSamplingDistributionPhatKnown) Def. \@ref(def:SamplingDistProp)
(ref:DEFSamplingDistributionXbar) Def. \@ref(def:DEFSamplingDistributionXbar)
(ref:DEFSamplingDistributionDbar) Def. \@ref(def:DEFSamplingDistributionDbar)
```{r ParametersStatistics}
ParStat <- array( dim = c(11, 4))
colnames(ParStat) <- c("Parameter",
"Statistic",
"Standard error",
"S.E. formula reference")
rownames(ParStat) <- c("Proportion (CI)",
"Proportion (Test)",
"Mean",
"Standard deviation",
"Mean difference",
"Diff. between means",
"Odds ratio",
"Correlation",
"Slope of regression line",
"Intercept of regression line",
"R-squared")
ParStat[1, ] <- c("$p$",
"$\\hat{p}$",
"$\\displaystyle\\text{s.e.}(\\hat{p}) = \\sqrt{\\frac{ \\hat{p} \\times (1 - \\hat{p})}{n}}$",
"(ref:DEFSamplingDistributionPhat)")
ParStat[2, ] <- c("$p$",
"$\\hat{p}$",
"$\\displaystyle\\text{s.e.}(\\hat{p}) = \\sqrt{\\frac{ p \\times (1 - p)}{n}}$",
"(ref:DEFSamplingDistributionPhatKnown)")
ParStat[3, ] <- c("$\\mu$",
"$\\bar{x}$",
"$\\displaystyle\\text{s.e.}(\\bar{x}) = \\frac{s}{\\sqrt{n}}$",
"(ref:DEFSamplingDistributionXbar) ")
ParStat[4, ] <- c("$\\sigma$",
"$s$",
"",
"")
ParStat[5, ] <- c("$\\mu_d$",
"$\\bar{d}$",
"$\\displaystyle\\text{s.e.}(\\bar{d}) = \\frac{s_d}{\\sqrt{n}}$",
"(ref:DEFSamplingDistributionDbar)")
ParStat[6, ] <- c("$\\mu_1 - \\mu_2$",
"$\\bar{x}_1 - \\bar{x}_2$",
"$\\displaystyle\\text{s.e.}(\\bar{x}_1 - \\bar{x}_2)$",
"Value given")
ParStat[7, ] <- c("Pop. OR",
"Sample OR",
"", # $\\displaystyle\\text{s.e.}(\\text{sample OR})$",
"Value given")
ParStat[8, ] <- c("$\\rho$",
"$r$",
"",
"")
ParStat[9, ] <- c("$\\beta_1$",
"$b_1$",
"$\\text{s.e.}(b_1)$",
"Value given")
ParStat[10, ] <- c("$\\beta_0$",
"$b_0$",
"$\\text{s.e.}(b_0)$",
"Value given")
ParStat[11, ] <- c("",
"$R^2$",
"",
"")
if( knitr::is_latex_output() ) {
kable( ParStat,
format = "latex",
booktabs = TRUE,
escape = FALSE,
align = c("c", "c", "c", "c"),
linesep = "\\addlinespace\\addlinespace",
#linesep = c("", "", "\\addlinespace", "\\addlinespace", "", "", "", ""), # Else adds a space every 5 lines...
caption = "Some sample statistics used to estimate population parameters. Empty table cells means that these are not studied in this textbook. For statistics with standard errors given, the sampling distribution is approximately normally distributed under certain (statistical validity) conditions."
) %>%
row_spec(0, bold = TRUE) %>%
kable_styling(font_size = 10) %>% # Columns headings in bold
column_spec(column = 1, width = "33mm") %>%
column_spec(column = 2, width = "14mm") %>%
column_spec(column = 3, width = "15mm") %>%
column_spec(column = 4, width = "39mm") %>%
column_spec(column = 5, width = "23mm")
}
if( knitr::is_html_output() ) {
kable( ParStat,
format = "html",
booktabs = TRUE,
align = c("c", "c", "c", "c"),
caption = "Some sample statistics used to estimate population parameters. Empty table cells means that these are not studied in this textbook. For statistics with standard errors given, the sampling distribution is approximately normally distributed under certain (statistical validity) conditions.") %>%
row_spec(0, bold = TRUE)
}
```
\pagebreak
## Confidence intervals {#FormulasCI}
**Confidence intervals** have the form
\[
\text{statistic} \pm ( \text{multiplier} \times \text{s.e.}(\text{statistic})).
\]
when the sampling distribution has an approximate normal distribution.
**Notes:**
* The multiplier is *approximately* 2 for an *approximate* 95% CI (based on the 68--95--99.7 rule).
* $\text{multiplier} \times \text{s.e.}(\text{statistic})$ is called the *margin of error*.
* When the sampling distribution for the statistic does not have an approximate normal distribution (e.g., for *odds ratios* and *correlation coefficients*), **this formula does not apply**.
## Hypothesis testing {#FormulasTest}
For **hypothesis tests**, the *test statistic* is a $t$-score, which has the form:
\[
t = \frac{\text{statistic} - \text{parameter}}{\text{s.e.}(\text{statistic})}.
\]
when the sampling distribution has an approximate normal distribution.
**Notes:**
* Since $t$-scores are a little like $z$-scores, the 68--95--99.7 rule can be used to *approximate* $P$-values.
* Tests involving *odds ratios* do not use $t$-scores, so **this formula does not apply for tests involving odds ratios**.
* When the sampling distribution for the statistic does not have an approximate normal distribution (e.g., for *odds ratios* and *correlation coefficients*), **this formula does not apply**.
* A hypothesis test about **odds ratios** uses a $\chi^2$ test statistic, whose value is approximately like a $z$-score with a value of
\[
\sqrt{\frac{\chi^2}{\text{df}}}.
\]
where $\text{df}$ is the 'degrees of freedom' given in the software output.
(ref:AboutHypotheses) Sect. \@ref(AboutHypotheses)
(ref:TestStatObs) Sect. \@ref(TestStatObs)
(ref:AboutCIs) Chap. \@ref(AboutCIs)
(ref:StandardError) Def. \@ref(def:StandardError)
\pagebreak
## Sample size estimation {#FormulasSampleSize}
* To estimate the sample size needed (Sect. \@ref(SampleSizeProportions)) for **estimating a proportion**:
\[
n = \frac{1}{(\text{Margin of error})^2}.
\]
* To estimate the sample size needed (Sect. \@ref(SampleSizeOneMean)) for **estimating a mean**:
\[
n = \left( \frac{2\times s}{\text{Margin of error}}\right)^2.
\]
* To estimate the sample size needed (Sect. \@ref(SampleSizeMeanDifferences)) for **estimating a mean difference**:
\[
n = \left( \frac{2 \times s_d}{\text{Margin of error}}\right)^2.
\]
**Notes:**
* In **sample size calculations**, always **round up** the sample size found from the above formulas.
## Other formulas {#FormulasOther}
* To calculate $z$-scores (Sect. \@ref(z-scores)): $\displaystyle z = \frac{x - \mu}{\sigma}$ or, more generally,\bigskip
\[
z = \frac{\text{value of variable} - \text{mean of distribution}}{\text{standard deviation of distribution}}.
\]
* The **unstandardizing formula** (Sect. \@ref(Unstandardising)): $x = \mu + (z\times \sigma)$.
**Notes:**
* $t$-scores are like $z$-scores, except that the standard deviation of the distribution includes some values estimated from the sample.
\pagebreak
## Other symbols used
```{r OtherSymbols}
SymbolsTab <- array( dim = c(7, 3))
colnames(SymbolsTab) <- c("Symbol",
"Meaning",
"Reference")
SymbolsTab[1, ] <- c("$H_0$",
"Null hypothesis",
"(ref:AboutHypotheses)")
SymbolsTab[2, ] <- c("$H_1$",
"Alternative hypothesis",
"(ref:AboutHypotheses)")
SymbolsTab[3, ] <- c("df",
"Degrees of freedom",
"(ref:TestStatObs)")
SymbolsTab[4, ] <- c("CI",
"Confidence interval",
"(ref:AboutCIs) ")
SymbolsTab[5, ] <- c("s.e.",
"Standard error" ,
"(ref:StandardError)")
SymbolsTab[6, ] <- c("$n$",
"Sample size", "")
SymbolsTab[7, ] <- c("$\\chi^2$",
"The chi-squared test statistic",
"(ref:TestStatObs) ")
if( knitr::is_latex_output() ) {
kable( SymbolsTab,
format = "latex",
booktabs = TRUE,
escape = FALSE,
align = c("c", "l", "c"),
linesep = c("", "", "\\addlinespace", "\\addlinespace", "", "", "")) %>% # Else adds a space every 5 lines...
# caption = "Some symbols used") %>%
row_spec(0, bold = TRUE) %>%
kable_styling(font_size = 11)
}
if( knitr::is_html_output() ) {
kable( SymbolsTab,
format = "html",
booktabs = TRUE,
align = c("c", "l", "c")) %>%
#caption = "Some symbols used")
row_spec(0, bold = TRUE)
}
```