App. Stats. sLM fertig

This commit is contained in:
henrydatei 2019-03-16 15:50:53 +00:00
parent 8f40dae57d
commit ebb6856c30
3 changed files with 855 additions and 2 deletions

View file

@ -75,7 +75,7 @@
Y_i &\overset{i.i.d}{\sim}Normal(\beta_0+\beta_1x_i,\sigma) \notag \\
Y &\sim Normal(X\beta,\mathbbm{1}\sigma) \notag
\end{align}
Since the mean of the response is a linear function of the explanatory variables, there are often called simple linear models.
Since the mean of the response is a linear function of the explanatory variables, there are often called \begriff{simple linear models}.
\end{enumerate}
\end{definition}
@ -129,4 +129,34 @@ where $SS_{xx}=\sum(x_i-\bar{x})^2$ and $s^2=\frac{\sum (Y_i-\hat{Y_i})^2}{n-2}$
\begin{align}
t = \frac{\hat{\beta_1}-\text{hypothesised value}}{\frac{s}{\sqrt{SS_{xx}}}} \notag
\end{align}
with degrees of freedom based on the number of data points and model parameters. In practice, software will does this for us!
with degrees of freedom based on the number of data points and model parameters. In practice, software will does this for us!
As an alternative for interference on parameter estimates, we can also compute confidence intervals. The $(1-\alpha)100\%$ confidence interval for the gradient $\beta_1$ is
\begin{align}
\hat{\beta_1}\pm t_{\nicefrac{\alpha}{2}}s_{\hat{\beta_1}}\notag
\end{align}
where $s_{\hat{\beta_1}} = \frac{s}{\sqrt{SS_{xx}}}$ and $t_{\nicefrac{\alpha}{2}}$ is based on $n-2$ degrees of freedom. $t_{\nicefrac{\alpha}{2}}$ is obtained from the \person{Stundent}'s t-distribution in the usual way. Some statistical software provides these values by default, but often (e.g. in MATLAB), only the standard errors for parameter estimates are provided.
\subsection{Estimation and prediction for simple linear models}
\begin{definition}[estimation]
\begriff[simple linear models!]{Estimation}: estimate mean value of $Y$ over many data points
\end{definition}
\begin{definition}[prediction]
\begriff[simple linear models!]{Prediction}: predict $Y$ for a particular value of $x$. This leads to higher error bounds (add error in mean to variation around mean).
\end{definition}
\input{./TeX_files/materials/estimation_prediction_slms}
\textcolor{red}{Be careful with predictions far away from mean of explanatory variable or outside of region covered by data.}
It's good practise to always check the fit visually\footnote{If you don't believe that have a look at \url{https://en.wikipedia.org/wiki/Anscombe\%27s_quartet}}. Looking at residual plots is also useful.
\begin{definition}[Coefficient of Determination]
The \begriff{Coefficient of Determination}, $R^2$, is defined as
\begin{align}
R^2 = \frac{SS_{yy}-SSE}{SS_{yy}} \notag
\end{align}
where $SS_{yy}=\sum(Y_i-\bar{Y})^2$ and $SSE=\sum(Y_i-\hat{Y_i})^2$. $R^2$ can be interpreted as the proportion of the variance in the response variable that is explained by (or attributed to) the explanatory variable. There are other measures, similar to $R^2$ and there are a few issues making it problematic for assessing goodness of fit. We'll revisit this later in the course.
\end{definition}

View file

@ -0,0 +1,823 @@
\begin{center}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=400, xlabel=$x$,
ymin=0, ymax=14, ylabel=$y$,
axis x line=middle,
axis y line=middle,
domain=0:400,
samples=400
]
\addplot[thick, blue] {0.014*x+4.8};
\addlegendentry {fit};
\addplot[red,dashed] coordinates {
(0.00,3.37)
(1.00,3.39)
(2.00,3.41)
(3.00,3.43)
(4.00,3.45)
(5.00,3.47)
(6.00,3.49)
(7.00,3.51)
(8.00,3.53)
(9.00,3.55)
(10.00,3.56)
(11.00,3.58)
(12.00,3.60)
(13.00,3.62)
(14.00,3.64)
(15.00,3.66)
(16.00,3.68)
(17.00,3.70)
(18.00,3.72)
(19.00,3.74)
(20.00,3.76)
(21.00,3.78)
(22.00,3.80)
(23.00,3.82)
(24.00,3.84)
(25.00,3.86)
(26.00,3.88)
(27.00,3.89)
(28.00,3.91)
(29.00,3.93)
(30.00,3.95)
(31.00,3.97)
(32.00,3.99)
(33.00,4.01)
(34.00,4.03)
(35.00,4.05)
(36.00,4.07)
(37.00,4.09)
(38.00,4.11)
(39.00,4.13)
(40.00,4.15)
(41.00,4.16)
(42.00,4.18)
(43.00,4.20)
(44.00,4.22)
(45.00,4.24)
(46.00,4.26)
(47.00,4.28)
(48.00,4.30)
(49.00,4.32)
(50.00,4.34)
(51.00,4.36)
(52.00,4.38)
(53.00,4.39)
(54.00,4.41)
(55.00,4.43)
(56.00,4.45)
(57.00,4.47)
(58.00,4.49)
(59.00,4.51)
(60.00,4.53)
(61.00,4.55)
(62.00,4.57)
(63.00,4.58)
(64.00,4.60)
(65.00,4.62)
(66.00,4.64)
(67.00,4.66)
(68.00,4.68)
(69.00,4.70)
(70.00,4.72)
(71.00,4.73)
(72.00,4.75)
(73.00,4.77)
(74.00,4.79)
(75.00,4.81)
(76.00,4.83)
(77.00,4.85)
(78.00,4.87)
(79.00,4.88)
(80.00,4.90)
(81.00,4.92)
(82.00,4.94)
(83.00,4.96)
(84.00,4.98)
(85.00,5.00)
(86.00,5.01)
(87.00,5.03)
(88.00,5.05)
(89.00,5.07)
(90.00,5.09)
(91.00,5.11)
(92.00,5.13)
(93.00,5.14)
(94.00,5.16)
(95.00,5.18)
(96.00,5.20)
(97.00,5.22)
(98.00,5.24)
(99.00,5.25)
(100.00,5.27)
(101.00,5.29)
(102.00,5.31)
(103.00,5.33)
(104.00,5.34)
(105.00,5.36)
(106.00,5.38)
(107.00,5.40)
(108.00,5.42)
(109.00,5.44)
(110.00,5.45)
(111.00,5.47)
(112.00,5.49)
(113.00,5.51)
(114.00,5.53)
(115.00,5.54)
(116.00,5.56)
(117.00,5.58)
(118.00,5.60)
(119.00,5.61)
(120.00,5.63)
(121.00,5.65)
(122.00,5.67)
(123.00,5.68)
(124.00,5.70)
(125.00,5.72)
(126.00,5.74)
(127.00,5.75)
(128.00,5.77)
(129.00,5.79)
(130.00,5.81)
(131.00,5.82)
(132.00,5.84)
(133.00,5.86)
(134.00,5.88)
(135.00,5.89)
(136.00,5.91)
(137.00,5.93)
(138.00,5.95)
(139.00,5.96)
(140.00,5.98)
(141.00,6.00)
(142.00,6.01)
(143.00,6.03)
(144.00,6.05)
(145.00,6.06)
(146.00,6.08)
(147.00,6.10)
(148.00,6.11)
(149.00,6.13)
(150.00,6.15)
(151.00,6.16)
(152.00,6.18)
(153.00,6.20)
(154.00,6.21)
(155.00,6.23)
(156.00,6.25)
(157.00,6.26)
(158.00,6.28)
(159.00,6.30)
(160.00,6.31)
(161.00,6.33)
(162.00,6.35)
(163.00,6.36)
(164.00,6.38)
(165.00,6.39)
(166.00,6.41)
(167.00,6.43)
(168.00,6.44)
(169.00,6.46)
(170.00,6.47)
(171.00,6.49)
(172.00,6.51)
(173.00,6.52)
(174.00,6.54)
(175.00,6.55)
(176.00,6.57)
(177.00,6.58)
(178.00,6.60)
(179.00,6.61)
(180.00,6.63)
(181.00,6.64)
(182.00,6.66)
(183.00,6.68)
(184.00,6.69)
(185.00,6.71)
(186.00,6.72)
(187.00,6.74)
(188.00,6.75)
(189.00,6.77)
(190.00,6.78)
(191.00,6.80)
(192.00,6.81)
(193.00,6.82)
(194.00,6.84)
(195.00,6.85)
(196.00,6.87)
(197.00,6.88)
(198.00,6.90)
(199.00,6.91)
(200.00,6.93)
(201.00,6.94)
(202.00,6.96)
(203.00,6.97)
(204.00,6.98)
(205.00,7.00)
(206.00,7.01)
(207.00,7.03)
(208.00,7.04)
(209.00,7.05)
(210.00,7.07)
(211.00,7.08)
(212.00,7.10)
(213.00,7.11)
(214.00,7.12)
(215.00,7.14)
(216.00,7.15)
(217.00,7.16)
(218.00,7.18)
(219.00,7.19)
(220.00,7.20)
(221.00,7.22)
(222.00,7.23)
(223.00,7.24)
(224.00,7.26)
(225.00,7.27)
(226.00,7.28)
(227.00,7.30)
(228.00,7.31)
(229.00,7.32)
(230.00,7.34)
(231.00,7.35)
(232.00,7.36)
(233.00,7.37)
(234.00,7.39)
(235.00,7.40)
(236.00,7.41)
(237.00,7.43)
(238.00,7.44)
(239.00,7.45)
(240.00,7.46)
(241.00,7.48)
(242.00,7.49)
(243.00,7.50)
(244.00,7.51)
(245.00,7.52)
(246.00,7.54)
(247.00,7.55)
(248.00,7.56)
(249.00,7.57)
(250.00,7.59)
(251.00,7.60)
(252.00,7.61)
(253.00,7.62)
(254.00,7.63)
(255.00,7.65)
(256.00,7.66)
(257.00,7.67)
(258.00,7.68)
(259.00,7.69)
(260.00,7.70)
(261.00,7.72)
(262.00,7.73)
(263.00,7.74)
(264.00,7.75)
(265.00,7.76)
(266.00,7.77)
(267.00,7.79)
(268.00,7.80)
(269.00,7.81)
(270.00,7.82)
(271.00,7.83)
(272.00,7.84)
(273.00,7.85)
(274.00,7.87)
(275.00,7.88)
(276.00,7.89)
(277.00,7.90)
(278.00,7.91)
(279.00,7.92)
(280.00,7.93)
(281.00,7.94)
(282.00,7.95)
(283.00,7.96)
(284.00,7.98)
(285.00,7.99)
(286.00,8.00)
(287.00,8.01)
(288.00,8.02)
(289.00,8.03)
(290.00,8.04)
(291.00,8.05)
(292.00,8.06)
(293.00,8.07)
(294.00,8.08)
(295.00,8.09)
(296.00,8.11)
(297.00,8.12)
(298.00,8.13)
(299.00,8.14)
(300.00,8.15)
(301.00,8.16)
(302.00,8.17)
(303.00,8.18)
(304.00,8.19)
(305.00,8.20)
(306.00,8.21)
(307.00,8.22)
(308.00,8.23)
(309.00,8.24)
(310.00,8.25)
(311.00,8.26)
(312.00,8.27)
(313.00,8.28)
(314.00,8.29)
(315.00,8.30)
(316.00,8.31)
(317.00,8.32)
(318.00,8.33)
(319.00,8.34)
(320.00,8.35)
(321.00,8.36)
(322.00,8.37)
(323.00,8.38)
(324.00,8.39)
(325.00,8.40)
(326.00,8.41)
(327.00,8.42)
(328.00,8.43)
(329.00,8.44)
(330.00,8.45)
(331.00,8.46)
(332.00,8.47)
(333.00,8.48)
(334.00,8.49)
(335.00,8.50)
(336.00,8.51)
(337.00,8.52)
(338.00,8.53)
(339.00,8.54)
(340.00,8.55)
(341.00,8.56)
(342.00,8.57)
(343.00,8.58)
(344.00,8.59)
(345.00,8.60)
(346.00,8.61)
(347.00,8.62)
(348.00,8.63)
(349.00,8.64)
(350.00,8.65)
(351.00,8.66)
(352.00,8.67)
(353.00,8.68)
(354.00,8.69)
(355.00,8.70)
(356.00,8.71)
(357.00,8.72)
(358.00,8.73)
(359.00,8.74)
(360.00,8.75)
(361.00,8.76)
(362.00,8.77)
(363.00,8.78)
(364.00,8.78)
(365.00,8.79)
(366.00,8.80)
(367.00,8.81)
(368.00,8.82)
(369.00,8.83)
(370.00,8.84)
(371.00,8.85)
(372.00,8.86)
(373.00,8.87)
(374.00,8.88)
(375.00,8.89)
(376.00,8.90)
(377.00,8.91)
(378.00,8.92)
(379.00,8.93)
(380.00,8.94)
(381.00,8.95)
(382.00,8.95)
(383.00,8.96)
(384.00,8.97)
(385.00,8.98)
(386.00,8.99)
(387.00,9.00)
(388.00,9.01)
(389.00,9.02)
(390.00,9.03)
(391.00,9.04)
(392.00,9.05)
(393.00,9.06)
(394.00,9.07)
(395.00,9.08)
(396.00,9.08)
(397.00,9.09)
(398.00,9.10)
(399.00,9.11)
};
\addlegendentry {95\% estimation limits};
\addplot[green,dotted] {x*-5.7*10^-6*x+0.017*x+1.4};
\addlegendentry {95\% prediction limits};
\addplot[red,dashed] coordinates {
(0.00,6.21)
(1.00,6.22)
(2.00,6.23)
(3.00,6.24)
(4.00,6.25)
(5.00,6.26)
(6.00,6.27)
(7.00,6.27)
(8.00,6.28)
(9.00,6.29)
(10.00,6.30)
(11.00,6.31)
(12.00,6.32)
(13.00,6.33)
(14.00,6.34)
(15.00,6.35)
(16.00,6.36)
(17.00,6.37)
(18.00,6.38)
(19.00,6.39)
(20.00,6.40)
(21.00,6.40)
(22.00,6.41)
(23.00,6.42)
(24.00,6.43)
(25.00,6.44)
(26.00,6.45)
(27.00,6.46)
(28.00,6.47)
(29.00,6.48)
(30.00,6.49)
(31.00,6.50)
(32.00,6.51)
(33.00,6.52)
(34.00,6.53)
(35.00,6.54)
(36.00,6.55)
(37.00,6.56)
(38.00,6.57)
(39.00,6.58)
(40.00,6.58)
(41.00,6.59)
(42.00,6.60)
(43.00,6.61)
(44.00,6.62)
(45.00,6.63)
(46.00,6.64)
(47.00,6.65)
(48.00,6.66)
(49.00,6.67)
(50.00,6.68)
(51.00,6.69)
(52.00,6.70)
(53.00,6.71)
(54.00,6.72)
(55.00,6.73)
(56.00,6.74)
(57.00,6.75)
(58.00,6.76)
(59.00,6.77)
(60.00,6.78)
(61.00,6.79)
(62.00,6.80)
(63.00,6.81)
(64.00,6.82)
(65.00,6.83)
(66.00,6.84)
(67.00,6.85)
(68.00,6.86)
(69.00,6.87)
(70.00,6.88)
(71.00,6.89)
(72.00,6.90)
(73.00,6.91)
(74.00,6.92)
(75.00,6.93)
(76.00,6.94)
(77.00,6.95)
(78.00,6.96)
(79.00,6.97)
(80.00,6.98)
(81.00,6.99)
(82.00,7.00)
(83.00,7.01)
(84.00,7.02)
(85.00,7.03)
(86.00,7.04)
(87.00,7.05)
(88.00,7.06)
(89.00,7.07)
(90.00,7.08)
(91.00,7.09)
(92.00,7.10)
(93.00,7.11)
(94.00,7.12)
(95.00,7.13)
(96.00,7.14)
(97.00,7.15)
(98.00,7.16)
(99.00,7.17)
(100.00,7.18)
(101.00,7.20)
(102.00,7.21)
(103.00,7.22)
(104.00,7.23)
(105.00,7.24)
(106.00,7.25)
(107.00,7.26)
(108.00,7.27)
(109.00,7.28)
(110.00,7.29)
(111.00,7.30)
(112.00,7.31)
(113.00,7.32)
(114.00,7.33)
(115.00,7.35)
(116.00,7.36)
(117.00,7.37)
(118.00,7.38)
(119.00,7.39)
(120.00,7.40)
(121.00,7.41)
(122.00,7.42)
(123.00,7.43)
(124.00,7.45)
(125.00,7.46)
(126.00,7.47)
(127.00,7.48)
(128.00,7.49)
(129.00,7.50)
(130.00,7.51)
(131.00,7.52)
(132.00,7.54)
(133.00,7.55)
(134.00,7.56)
(135.00,7.57)
(136.00,7.58)
(137.00,7.59)
(138.00,7.60)
(139.00,7.62)
(140.00,7.63)
(141.00,7.64)
(142.00,7.65)
(143.00,7.66)
(144.00,7.68)
(145.00,7.69)
(146.00,7.70)
(147.00,7.71)
(148.00,7.72)
(149.00,7.74)
(150.00,7.75)
(151.00,7.76)
(152.00,7.77)
(153.00,7.78)
(154.00,7.80)
(155.00,7.81)
(156.00,7.82)
(157.00,7.83)
(158.00,7.85)
(159.00,7.86)
(160.00,7.87)
(161.00,7.88)
(162.00,7.90)
(163.00,7.91)
(164.00,7.92)
(165.00,7.93)
(166.00,7.95)
(167.00,7.96)
(168.00,7.97)
(169.00,7.98)
(170.00,8.00)
(171.00,8.01)
(172.00,8.02)
(173.00,8.04)
(174.00,8.05)
(175.00,8.06)
(176.00,8.08)
(177.00,8.09)
(178.00,8.10)
(179.00,8.12)
(180.00,8.13)
(181.00,8.14)
(182.00,8.16)
(183.00,8.17)
(184.00,8.18)
(185.00,8.20)
(186.00,8.21)
(187.00,8.22)
(188.00,8.24)
(189.00,8.25)
(190.00,8.27)
(191.00,8.28)
(192.00,8.29)
(193.00,8.31)
(194.00,8.32)
(195.00,8.34)
(196.00,8.35)
(197.00,8.36)
(198.00,8.38)
(199.00,8.39)
(200.00,8.41)
(201.00,8.42)
(202.00,8.44)
(203.00,8.45)
(204.00,8.47)
(205.00,8.48)
(206.00,8.49)
(207.00,8.51)
(208.00,8.52)
(209.00,8.54)
(210.00,8.55)
(211.00,8.57)
(212.00,8.58)
(213.00,8.60)
(214.00,8.61)
(215.00,8.63)
(216.00,8.64)
(217.00,8.66)
(218.00,8.67)
(219.00,8.69)
(220.00,8.71)
(221.00,8.72)
(222.00,8.74)
(223.00,8.75)
(224.00,8.77)
(225.00,8.78)
(226.00,8.80)
(227.00,8.81)
(228.00,8.83)
(229.00,8.85)
(230.00,8.86)
(231.00,8.88)
(232.00,8.89)
(233.00,8.91)
(234.00,8.93)
(235.00,8.94)
(236.00,8.96)
(237.00,8.97)
(238.00,8.99)
(239.00,9.01)
(240.00,9.02)
(241.00,9.04)
(242.00,9.06)
(243.00,9.07)
(244.00,9.09)
(245.00,9.10)
(246.00,9.12)
(247.00,9.14)
(248.00,9.15)
(249.00,9.17)
(250.00,9.19)
(251.00,9.20)
(252.00,9.22)
(253.00,9.24)
(254.00,9.25)
(255.00,9.27)
(256.00,9.29)
(257.00,9.31)
(258.00,9.32)
(259.00,9.34)
(260.00,9.36)
(261.00,9.37)
(262.00,9.39)
(263.00,9.41)
(264.00,9.42)
(265.00,9.44)
(266.00,9.46)
(267.00,9.48)
(268.00,9.49)
(269.00,9.51)
(270.00,9.53)
(271.00,9.55)
(272.00,9.56)
(273.00,9.58)
(274.00,9.60)
(275.00,9.62)
(276.00,9.63)
(277.00,9.65)
(278.00,9.67)
(279.00,9.69)
(280.00,9.70)
(281.00,9.72)
(282.00,9.74)
(283.00,9.76)
(284.00,9.78)
(285.00,9.79)
(286.00,9.81)
(287.00,9.83)
(288.00,9.85)
(289.00,9.87)
(290.00,9.88)
(291.00,9.90)
(292.00,9.92)
(293.00,9.94)
(294.00,9.96)
(295.00,9.97)
(296.00,9.99)
(297.00,10.01)
(298.00,10.03)
(299.00,10.05)
(300.00,10.06)
(301.00,10.08)
(302.00,10.10)
(303.00,10.12)
(304.00,10.14)
(305.00,10.16)
(306.00,10.17)
(307.00,10.19)
(308.00,10.21)
(309.00,10.23)
(310.00,10.25)
(311.00,10.27)
(312.00,10.28)
(313.00,10.30)
(314.00,10.32)
(315.00,10.34)
(316.00,10.36)
(317.00,10.38)
(318.00,10.40)
(319.00,10.41)
(320.00,10.43)
(321.00,10.45)
(322.00,10.47)
(323.00,10.49)
(324.00,10.51)
(325.00,10.53)
(326.00,10.55)
(327.00,10.56)
(328.00,10.58)
(329.00,10.60)
(330.00,10.62)
(331.00,10.64)
(332.00,10.66)
(333.00,10.68)
(334.00,10.70)
(335.00,10.72)
(336.00,10.73)
(337.00,10.75)
(338.00,10.77)
(339.00,10.79)
(340.00,10.81)
(341.00,10.83)
(342.00,10.85)
(343.00,10.87)
(344.00,10.89)
(345.00,10.90)
(346.00,10.92)
(347.00,10.94)
(348.00,10.96)
(349.00,10.98)
(350.00,11.00)
(351.00,11.02)
(352.00,11.04)
(353.00,11.06)
(354.00,11.08)
(355.00,11.10)
(356.00,11.11)
(357.00,11.13)
(358.00,11.15)
(359.00,11.17)
(360.00,11.19)
(361.00,11.21)
(362.00,11.23)
(363.00,11.25)
(364.00,11.27)
(365.00,11.29)
(366.00,11.31)
(367.00,11.33)
(368.00,11.35)
(369.00,11.37)
(370.00,11.38)
(371.00,11.40)
(372.00,11.42)
(373.00,11.44)
(374.00,11.46)
(375.00,11.48)
(376.00,11.50)
(377.00,11.52)
(378.00,11.54)
(379.00,11.56)
(380.00,11.58)
(381.00,11.60)
(382.00,11.62)
(383.00,11.64)
(384.00,11.66)
(385.00,11.68)
(386.00,11.69)
(387.00,11.71)
(388.00,11.73)
(389.00,11.75)
(390.00,11.77)
(391.00,11.79)
(392.00,11.81)
(393.00,11.83)
(394.00,11.85)
(395.00,11.87)
(396.00,11.89)
(397.00,11.91)
(398.00,11.93)
(399.00,11.95)
};
\addplot[green,dotted] {x*5.7*10^-6*x+0.012*x+8.2};
\end{axis}
\end{tikzpicture}
\end{center}