From 0694a8f02701f84270c3f14fa1d7cc6bd99e49d0 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sat, 24 Feb 2018 22:26:29 +0000 Subject: [PATCH] Moved small solution to solutions book --- section5.1.ipynb | 63 +++++++++++---------------------------- section5.1solutions.ipynb | 39 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/section5.1.ipynb b/section5.1.ipynb index 5a8ef2e..864aff1 100644 --- a/section5.1.ipynb +++ b/section5.1.ipynb @@ -63,7 +63,7 @@ "outputs": [], "source": [ "rubber <- read.csv('rubber.csv')\n", - "rubber" + "head(rubber)" ] }, { @@ -108,17 +108,6 @@ "# print(cbind(af,PctExp=afss/sum(afss)*100))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# ggplot(rubber, aes(x=hardness, y=loss)) + \n", - "# geom_point() +\n", - "# stat_smooth(method = \"lm\", col = \"red\")" - ] - }, { "cell_type": "code", "execution_count": null, @@ -138,9 +127,13 @@ }, "source": [ "### Exercise 5.1\n", - "Now repeat the for the regression of abrasion loss on tensile strength.\n", + "Now repeat the for the regression of abrasion loss on tensile strength. Create the model, look at how well it does, and generate the regression scatterplots.\n", + "\n", + "Place the new regression model in a variable called `fit.s`. \n", "\n", - "Enter your solution in the cell below." + "Enter your solution in the cell below.\n", + "\n", + "The solution is in the [Section 5.1 solutions](section5.1solutions.ipynb) notebook." ] }, { @@ -152,38 +145,6 @@ "# Your solution here" ] }, - { - "cell_type": "markdown", - "metadata": { - "heading_collapsed": true - }, - "source": [ - "### Solution" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "hidden": true, - "solution2": "hidden" - }, - "outputs": [], - "source": [ - "fit.s <- lm(loss ~ strength, data = rubber)\n", - "summary(fit.s)\n", - "anova(fit.s)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ggplotRegression(fit.s)" - ] - }, { "cell_type": "markdown", "metadata": { @@ -247,6 +208,16 @@ "Associated with each estimated parameter, GenStat gives a standard error (details of the calculation of which need not concern us now) and hence a _t_-statistic (estimate divided by standard error) to be compared with the distribution on `d.f. (Residual)`=27 degrees of freedom. GenStat makes the comparison and gives _p_ values, which in this case are all very small, suggesting strong evidence for the non-zeroness (and hence presence) of each parameter, $\\alpha$, $\\beta_1$ and $\\beta_2$, individually." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# In case you've not completed exercise 5.1\n", + "fit.s <- lm(loss ~ strength, data = rubber)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/section5.1solutions.ipynb b/section5.1solutions.ipynb index 1858975..c6cf696 100644 --- a/section5.1solutions.ipynb +++ b/section5.1solutions.ipynb @@ -45,6 +45,45 @@ "source('plot_extensions.R')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exercise 5.1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rubber <- read.csv('rubber.csv')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "hidden": true, + "solution2": "hidden" + }, + "outputs": [], + "source": [ + "fit.s <- lm(loss ~ strength, data = rubber)\n", + "summary(fit.s)\n", + "anova(fit.s)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ggplotRegression(fit.s)" + ] + }, { "cell_type": "markdown", "metadata": {}, -- 2.34.1