X-Git-Url: https://code.communitydata.science/stats_class_2020.git/blobdiff_plain/f4cc27882266caedc2bc151dc4fab03345934b93..031b7bd587ecb01c5628cc1a282ca121b06c381c:/os_exercises/ch8_exercises_solutions.html diff --git a/os_exercises/ch8_exercises_solutions.html b/os_exercises/ch8_exercises_solutions.html new file mode 100644 index 0000000..ce2da90 --- /dev/null +++ b/os_exercises/ch8_exercises_solutions.html @@ -0,0 +1,1695 @@ + + + + +
+ + + + + + + + + + +All exercises taken from the OpenIntro Statistics textbook, \(4^{th}\) edition, Chapter 8.
+y_bar = 3.91 + .78 * 28
+
+y_bar
+## [1] 25.75
+The test statistic for this can be calculated as a t-score as follows:
+\[T = \frac{0.78 - 0}{.35} = 2.23\]
+We can look up a p-value for this in a t-table for \(df = 23\) or we can figure it out in R. The pt(q,df)
function gives the proportion of the T-distribution which is less than q
with df
degrees of freedom.
(1 - pt(q = 2.23, df = 23)) * 2 # To get 2-tailed p-value, we multiply this by 2
+## [1] 0.03579437
+pt(q = 2.23, df = 23, lower.tail = FALSE) * 2 # Alternatively, we can get the area of the upper tail and multiply that by 2 (multiplying by 2 works because t-distributions are symmetrical)
+## [1] 0.03579437
+The p-value is less than 0.05, so with a traditional \(\alpha = 0.05\) we would reject \(H_0\) and conclude that there is substantial evidence of an association between gestational age and head circumference for low birth-weight babies (the true slope parameter is unlikely to be zero).
+Here are the hypotheses:
+\[H_0:~ \beta_{body\_weight} = 0\] \[H_A:~ \beta_{body\_weight} \neq 0\]
The estimate is large (and positive) with a small standard error, resulting in a large test-statistic and a correspondingly small p-value. This is likely lower than whatever critical value was selected for the significance level, so the data provide compelling evidence in support of the alternative hypothesis that the true slope parameter for body weight is not equal to zero, and is positively associated with heart weight in cats.
The confidence interval for the parameter can be calculated like this:
\[b_{body\_weight} \pm t^* \times SE\] Plugging in values from the model estimates and 1.98 for the value of \(t^*\): \[4.034 \pm 1.98 \times 0.250\] \[(3.539, 4.529)\]
+In words, this model indicates that for each additional kilogram in a catâs weight we can be 95% confident that the wight of itâs heart will increase by 3.539 to 4.529 grams on average.
b_1 = (3.9983-4.010) / -0.0883
+b_1
+## [1] 0.1325028
+The null hypothesis is that \(H_0:~\beta_1 = 0\). With a t-score of 4.13 and a p-value of ~0.00 there is strong evidence of a positive relationship between beauty and teaching scores (we would reject the null hypothesis).