[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:01.67,0:00:04.14,Default,,0000,0000,0000,,Hi. In this video we are going to continue Dialogue: 0,0:00:04.14,0:00:05.76,Default,,0000,0000,0000,,to talk about inference. Dialogue: 0,0:00:05.76,0:00:09.45,Default,,0000,0000,0000,,But now we're going to be talking about\Nhow you can conduct hypothesis Dialogue: 0,0:00:09.45,0:00:12.43,Default,,0000,0000,0000,,tests in AR. Dialogue: 0,0:00:12.43,0:00:15.66,Default,,0000,0000,0000,,So the general hypothesis\Ntesting procedure Dialogue: 0,0:00:15.76,0:00:19.65,Default,,0000,0000,0000,,is we always state hypotheses\Nabout your parameter. Dialogue: 0,0:00:20.31,0:00:23.29,Default,,0000,0000,0000,,We collect some data. Dialogue: 0,0:00:24.15,0:00:27.13,Default,,0000,0000,0000,,We construct a test statistic. Dialogue: 0,0:00:29.25,0:00:33.59,Default,,0000,0000,0000,,We then apply a decision rule\Nso we can either Dialogue: 0,0:00:34.60,0:00:37.58,Default,,0000,0000,0000,,do that through a critical value Dialogue: 0,0:00:37.74,0:00:41.22,Default,,0000,0000,0000,,or with p values\Nor like a critical region, excuse me. Dialogue: 0,0:00:41.22,0:00:43.85,Default,,0000,0000,0000,,Or with p values. Dialogue: 0,0:00:43.85,0:00:45.67,Default,,0000,0000,0000,,And then we will draw Dialogue: 0,0:00:45.67,0:00:48.65,Default,,0000,0000,0000,,conclusions in context. Dialogue: 0,0:00:49.25,0:00:52.69,Default,,0000,0000,0000,,So the first research question\Nwe're going to talk about Dialogue: 0,0:00:52.69,0:00:56.98,Default,,0000,0000,0000,,today is we're going to continue\Nusing the idea of iris flowers. Dialogue: 0,0:00:57.44,0:00:59.36,Default,,0000,0000,0000,,And see like we're interested in one. Dialogue: 0,0:00:59.36,0:01:03.60,Default,,0000,0000,0000,,And try to hypothesize\Nthat we think that the average Dialogue: 0,0:01:03.96,0:01:07.19,Default,,0000,0000,0000,,petal length for iris flowers Dialogue: 0,0:01:08.35,0:01:11.33,Default,,0000,0000,0000,,is four centimeters. So, Dialogue: 0,0:01:12.54,0:01:15.52,Default,,0000,0000,0000,,our null hypothesis would be Dialogue: 0,0:01:16.94,0:01:19.51,Default,,0000,0000,0000,,that average, Dialogue: 0,0:01:19.51,0:01:22.80,Default,,0000,0000,0000,,petal length is equal to four centimeters. Dialogue: 0,0:01:23.10,0:01:27.09,Default,,0000,0000,0000,,And our alternative will be average Dialogue: 0,0:01:27.29,0:01:31.49,Default,,0000,0000,0000,,petal length is not equal\Nto four centimeters. Dialogue: 0,0:01:32.24,0:01:33.96,Default,,0000,0000,0000,,Okay. Dialogue: 0,0:01:33.96,0:01:35.63,Default,,0000,0000,0000,,The data we are going to use Dialogue: 0,0:01:35.63,0:01:38.91,Default,,0000,0000,0000,,is the iris petal length data. Dialogue: 0,0:01:39.12,0:01:41.14,Default,,0000,0000,0000,,So it's from the iris dataset. Dialogue: 0,0:01:41.14,0:01:43.76,Default,,0000,0000,0000,,And this is the petal length and variable. Dialogue: 0,0:01:43.76,0:01:47.40,Default,,0000,0000,0000,,Just to kind of remind us it is just 150 Dialogue: 0,0:01:47.40,0:01:50.38,Default,,0000,0000,0000,,observations of different irises. Dialogue: 0,0:01:51.64,0:01:54.62,Default,,0000,0000,0000,,To construct our test statistic Dialogue: 0,0:01:55.13,0:01:58.72,Default,,0000,0000,0000,,we will first need an exposure value, Dialogue: 0,0:02:00.03,0:02:02.20,Default,,0000,0000,0000,,which we can find by taking Dialogue: 0,0:02:02.20,0:02:05.18,Default,,0000,0000,0000,,the mean of our sample. Dialogue: 0,0:02:06.34,0:02:09.38,Default,,0000,0000,0000,,So the mean of the iris of petal length. Dialogue: 0,0:02:11.90,0:02:14.78,Default,,0000,0000,0000,,Which will be 3.758. Dialogue: 0,0:02:14.78,0:02:19.33,Default,,0000,0000,0000,,We also are going to need\Nthe hypothesized value Dialogue: 0,0:02:19.33,0:02:24.08,Default,,0000,0000,0000,,that we are wanting to hypothesize,\Nwhich is four centimeters. Dialogue: 0,0:02:24.08,0:02:28.67,Default,,0000,0000,0000,,So I'm going to just call that mu\Nbecause that's the parameter of interest. Dialogue: 0,0:02:28.67,0:02:30.19,Default,,0000,0000,0000,,We're going to say it's equal to four. Dialogue: 0,0:02:31.91,0:02:33.12,Default,,0000,0000,0000,,We also need to know Dialogue: 0,0:02:33.12,0:02:36.76,Default,,0000,0000,0000,,the sample standard deviation s. Dialogue: 0,0:02:37.11,0:02:40.09,Default,,0000,0000,0000,,And so you can get that by doing this\Nstandard deviation Dialogue: 0,0:02:40.34,0:02:43.32,Default,,0000,0000,0000,,of the variable. Dialogue: 0,0:02:43.68,0:02:46.66,Default,,0000,0000,0000,,That value is 1.765. Dialogue: 0,0:02:47.11,0:02:49.79,Default,,0000,0000,0000,,And then we also need to know\Nthe number of observations. Dialogue: 0,0:02:49.79,0:02:53.02,Default,,0000,0000,0000,,So and so we will reduce\Nthe length function. Dialogue: 0,0:02:53.43,0:02:57.12,Default,,0000,0000,0000,,And then I'll count\Nhow many observations are in your data set Dialogue: 0,0:02:57.12,0:03:00.15,Default,,0000,0000,0000,,which is 50. Dialogue: 0,0:03:00.45,0:03:02.42,Default,,0000,0000,0000,,Now once we have all of those Dialogue: 0,0:03:02.42,0:03:06.11,Default,,0000,0000,0000,,individual pieces\Nwe can build the test statistic. Dialogue: 0,0:03:06.36,0:03:10.80,Default,,0000,0000,0000,,Since we are doing a hypothesis test\Nfor a mean, we will be constructing Dialogue: 0,0:03:10.80,0:03:15.91,Default,,0000,0000,0000,,what is known as like a\Nt, a test statistic for a t distribution. Dialogue: 0,0:03:16.82,0:03:19.80,Default,,0000,0000,0000,,So I'm going to call it t test stat. Dialogue: 0,0:03:21.06,0:03:22.58,Default,,0000,0000,0000,,And how we create Dialogue: 0,0:03:22.58,0:03:26.62,Default,,0000,0000,0000,,that is we do x bar\Nminus mu in the numerator Dialogue: 0,0:03:27.48,0:03:31.82,Default,,0000,0000,0000,,divided by I'm\Njust gonna put this in parentheses Dialogue: 0,0:03:31.82,0:03:36.82,Default,,0000,0000,0000,,as well S divided by the square root of n. Dialogue: 0,0:03:37.53,0:03:41.01,Default,,0000,0000,0000,,So thankfully we have all of these pieces\Nalready x bar mu Dialogue: 0,0:03:41.01,0:03:44.80,Default,,0000,0000,0000,,as an n, s and an x bar\Nall come from the data. Dialogue: 0,0:03:45.41,0:03:48.84,Default,,0000,0000,0000,,Mu is the value\Nwe specified in our null hypothesis. Dialogue: 0,0:03:49.35,0:03:52.53,Default,,0000,0000,0000,,And this will compute\Nour test statistic for us, Dialogue: 0,0:03:53.100,0:03:54.91,Default,,0000,0000,0000,,which is Dialogue: 0,0:03:54.91,0:04:00.92,Default,,0000,0000,0000,,-1.67897. So. Dialogue: 0,0:04:05.52,0:04:07.44,Default,,0000,0000,0000,,We'll. Dialogue: 0,0:04:07.44,0:04:09.20,Default,,0000,0000,0000,,So our next step Dialogue: 0,0:04:09.20,0:04:12.18,Default,,0000,0000,0000,,is to apply a decision rule. Dialogue: 0,0:04:16.18,0:04:19.16,Default,,0000,0000,0000,,So we have two different ways\Nwe can do that. Will Dialogue: 0,0:04:19.76,0:04:21.53,Default,,0000,0000,0000,,we will use a significance level Dialogue: 0,0:04:21.53,0:04:25.02,Default,,0000,0000,0000,,or an alpha of 0.05. Dialogue: 0,0:04:25.37,0:04:28.40,Default,,0000,0000,0000,,So I'm just going to go ahead\Nand set that. Dialogue: 0,0:04:31.63,0:04:32.69,Default,,0000,0000,0000,,And then if we want to Dialogue: 0,0:04:32.69,0:04:35.68,Default,,0000,0000,0000,,calculate a rejection region Dialogue: 0,0:04:35.83,0:04:38.71,Default,,0000,0000,0000,,because there's two different\Nkinds of decision rules we can do. Dialogue: 0,0:04:38.71,0:04:40.12,Default,,0000,0000,0000,,Rejection region. Dialogue: 0,0:04:40.12,0:04:43.10,Default,,0000,0000,0000,,We can find which critical value Dialogue: 0,0:04:43.20,0:04:47.50,Default,,0000,0000,0000,,will give us a tail probability of 0.0. Dialogue: 0,0:04:48.46,0:04:50.88,Default,,0000,0000,0000,,Or since we're doing a two sided\Nhypothesis test, Dialogue: 0,0:04:50.88,0:04:53.91,Default,,0000,0000,0000,,we'll do our alpha divided by two. Dialogue: 0,0:04:54.26,0:04:55.22,Default,,0000,0000,0000,,I'll kind of show you. Dialogue: 0,0:04:55.22,0:04:58.26,Default,,0000,0000,0000,,So our rejection region Dialogue: 0,0:04:58.56,0:05:01.89,Default,,0000,0000,0000,,is we're going to try\Nwe're going to find the critical value Dialogue: 0,0:05:01.89,0:05:07.20,Default,,0000,0000,0000,,that, fits the t distribution,\Nwhere the probability in the tail Dialogue: 0,0:05:08.61,0:05:11.04,Default,,0000,0000,0000,,is equal to alpha over two. Dialogue: 0,0:05:11.04,0:05:14.72,Default,,0000,0000,0000,,Because we're doing a two sided interval\Nhypothesis test. Dialogue: 0,0:05:15.53,0:05:19.88,Default,,0000,0000,0000,,Our degrees of freedom is needed\Nfor the t test, which is n minus one. Dialogue: 0,0:05:20.84,0:05:27.15,Default,,0000,0000,0000,,And since we are our test statistic\Nwith a negative value, Dialogue: 0,0:05:27.40,0:05:30.54,Default,,0000,0000,0000,,meaning that it's on the left side of the, Dialogue: 0,0:05:31.30,0:05:34.22,Default,,0000,0000,0000,,of the mean on the curve, Dialogue: 0,0:05:34.22,0:05:37.71,Default,,0000,0000,0000,,we will go ahead and say\Nlower that tail equals true Dialogue: 0,0:05:38.16,0:05:43.12,Default,,0000,0000,0000,,because we want the lower tailed like\Nor the smaller the tail end probability. Dialogue: 0,0:05:43.47,0:05:48.32,Default,,0000,0000,0000,,If this is a positive number 1.67\Nwe would then do lower dot Dialogue: 0,0:05:48.37,0:05:51.91,Default,,0000,0000,0000,,tail equals false\Nbecause we want the upper tail Dialogue: 0,0:05:53.12,0:05:56.05,Default,,0000,0000,0000,,we want kind of the extremes. Dialogue: 0,0:05:56.05,0:05:59.94,Default,,0000,0000,0000,,So anything from where\Nour test statistic is and more extreme. Dialogue: 0,0:06:00.100,0:06:03.12,Default,,0000,0000,0000,,So what this will tell us Dialogue: 0,0:06:03.12,0:06:06.15,Default,,0000,0000,0000,,is our oh Alpha not found. Dialogue: 0,0:06:06.15,0:06:08.63,Default,,0000,0000,0000,,I forgot to run that line. There we go. Dialogue: 0,0:06:10.85,0:06:11.41,Default,,0000,0000,0000,,Okay. Dialogue: 0,0:06:11.41,0:06:17.37,Default,,0000,0000,0000,,So our rejection value is one -1.976. Dialogue: 0,0:06:18.07,0:06:21.96,Default,,0000,0000,0000,,So what this is telling us\Nis that if our test statistic Dialogue: 0,0:06:21.96,0:06:26.61,Default,,0000,0000,0000,,is equal to -1.976 or less, Dialogue: 0,0:06:27.47,0:06:32.88,Default,,0000,0000,0000,,or if it's greater than positive 1.976, Dialogue: 0,0:06:33.38,0:06:36.41,Default,,0000,0000,0000,,then we will reject our null hypothesis. Dialogue: 0,0:06:39.44,0:06:43.28,Default,,0000,0000,0000,,And in this case, since our test Dialogue: 0,0:06:43.28,0:06:48.28,Default,,0000,0000,0000,,statistic is not in the extreme,\Nit's actually greater than this value, Dialogue: 0,0:06:48.64,0:06:51.62,Default,,0000,0000,0000,,we will fail\Nto reject our null hypothesis. Dialogue: 0,0:06:51.62,0:06:54.60,Default,,0000,0000,0000,,So this is telling us that, Dialogue: 0,0:06:55.56,0:06:56.97,Default,,0000,0000,0000,,we will fail to reject Dialogue: 0,0:06:56.97,0:07:00.81,Default,,0000,0000,0000,,our null, meaning that\Nwe do not have enough evidence to conclude Dialogue: 0,0:07:00.96,0:07:04.80,Default,,0000,0000,0000,,that the average petal length\Nis not equal to four centimeters. Dialogue: 0,0:07:06.02,0:07:09.75,Default,,0000,0000,0000,,The other way you can apply a decision\Nrule is with a p value. Dialogue: 0,0:07:10.92,0:07:13.34,Default,,0000,0000,0000,,And since we are doing a Dialogue: 0,0:07:13.34,0:07:15.46,Default,,0000,0000,0000,,two sided hypothesis test, Dialogue: 0,0:07:15.46,0:07:19.40,Default,,0000,0000,0000,,we will can do two times\Nwhatever probability Dialogue: 0,0:07:19.40,0:07:22.43,Default,,0000,0000,0000,,we get because we're going\Nto be calculating it for one tail. Dialogue: 0,0:07:22.43,0:07:24.96,Default,,0000,0000,0000,,But since we're doing two sided\Nwe'll just need to multiply it Dialogue: 0,0:07:26.02,0:07:27.33,Default,,0000,0000,0000,,by two. Dialogue: 0,0:07:27.33,0:07:29.81,Default,,0000,0000,0000,,And so what we're going to put in here\Nis we're going to put Dialogue: 0,0:07:29.81,0:07:33.75,Default,,0000,0000,0000,,in our test statistic that we get. Dialogue: 0,0:07:35.32,0:07:38.30,Default,,0000,0000,0000,,The degrees of freedom again Dialogue: 0,0:07:38.30,0:07:40.47,Default,,0000,0000,0000,,and again we're going to do lower tail Dialogue: 0,0:07:40.47,0:07:44.31,Default,,0000,0000,0000,,equals true because our original test\Nstatistic is negative. Dialogue: 0,0:07:44.31,0:07:48.10,Default,,0000,0000,0000,,So we want a lower tail\Nlike the extreme value. Dialogue: 0,0:07:49.46,0:07:52.84,Default,,0000,0000,0000,,And then we're going to multiply by\Ntwo again because we are doing a two sided Dialogue: 0,0:07:53.70,0:07:56.74,Default,,0000,0000,0000,,piece two sided hypothesis test. Dialogue: 0,0:07:57.14,0:07:59.92,Default,,0000,0000,0000,,And then this is the value\Nthat we compare to Dialogue: 0,0:07:59.92,0:08:02.90,Default,,0000,0000,0000,,our alpha which is 0.05. Dialogue: 0,0:08:02.100,0:08:06.48,Default,,0000,0000,0000,,So if our p value is less than the alpha Dialogue: 0,0:08:06.74,0:08:10.83,Default,,0000,0000,0000,,less than 0.05,\Nwe would reject the null hypothesis. Dialogue: 0,0:08:11.03,0:08:14.42,Default,,0000,0000,0000,,In this case\Nour p value is greater than 0.05. Dialogue: 0,0:08:14.82,0:08:18.36,Default,,0000,0000,0000,,So we would fail to reject our null\Nhypothesis again as well. Dialogue: 0,0:08:19.32,0:08:22.35,Default,,0000,0000,0000,,You should get the same conclusion. Dialogue: 0,0:08:23.00,0:08:25.58,Default,,0000,0000,0000,,With either method, you should be Dialogue: 0,0:08:25.58,0:08:29.12,Default,,0000,0000,0000,,coming to the same reject\Nor fail to reject. Dialogue: 0,0:08:29.12,0:08:32.20,Default,,0000,0000,0000,,You should not be getting\Ndifferent conclusions. Dialogue: 0,0:08:35.33,0:08:36.34,Default,,0000,0000,0000,,So that's how you can kind of Dialogue: 0,0:08:36.34,0:08:39.32,Default,,0000,0000,0000,,compute a hypothesis test by hand. Dialogue: 0,0:08:39.73,0:08:43.77,Default,,0000,0000,0000,,But as always, usually in R\Nthere is an easier way to do it. Dialogue: 0,0:08:44.42,0:08:47.25,Default,,0000,0000,0000,,So there is a function t test Dialogue: 0,0:08:47.25,0:08:50.23,Default,,0000,0000,0000,,which may be familiar from when we did. Dialogue: 0,0:08:50.44,0:08:52.41,Default,,0000,0000,0000,,Confidence intervals for means. Dialogue: 0,0:08:52.41,0:08:54.12,Default,,0000,0000,0000,,And this is actually you can Dialogue: 0,0:08:54.12,0:08:57.10,Default,,0000,0000,0000,,do confidence intervals\Nplus hypothesis testing in here. Dialogue: 0,0:08:57.71,0:09:01.04,Default,,0000,0000,0000,,So we still are going to have\Nthe same null. Dialogue: 0,0:09:01.04,0:09:04.08,Default,,0000,0000,0000,,And I turned it off\Nhypotheses from up here. Dialogue: 0,0:09:04.53,0:09:07.76,Default,,0000,0000,0000,,And so what we're going to do\Nis we're going to just say t dot test, Dialogue: 0,0:09:09.18,0:09:12.21,Default,,0000,0000,0000,,give it the data\Nthat we are doing the t test on, Dialogue: 0,0:09:13.37,0:09:16.35,Default,,0000,0000,0000,,which is the petal length of iris flowers. Dialogue: 0,0:09:17.06,0:09:20.09,Default,,0000,0000,0000,,We need to specify what our, Dialogue: 0,0:09:20.19,0:09:22.77,Default,,0000,0000,0000,,null hypothesis new value is. Dialogue: 0,0:09:22.77,0:09:27.41,Default,,0000,0000,0000,,We're saying that we are hypothesizing\Nthat the true, average Dialogue: 0,0:09:27.41,0:09:29.33,Default,,0000,0000,0000,,petal length is four. Dialogue: 0,0:09:29.33,0:09:32.32,Default,,0000,0000,0000,,So we will say mu is equal to four. Dialogue: 0,0:09:32.57,0:09:35.55,Default,,0000,0000,0000,,And then we also need to specify that our Dialogue: 0,0:09:35.55,0:09:39.24,Default,,0000,0000,0000,,our that our alternative hypothesis is a Dialogue: 0,0:09:39.54,0:09:42.52,Default,,0000,0000,0000,,two sided hypothesis test. Dialogue: 0,0:09:43.38,0:09:45.65,Default,,0000,0000,0000,,Okay. Dialogue: 0,0:09:45.65,0:09:47.67,Default,,0000,0000,0000,,And if we go ahead and run that. Dialogue: 0,0:09:47.67,0:09:51.76,Default,,0000,0000,0000,,And notice it shows it is a one\Nsample t test which is perfect. Dialogue: 0,0:09:51.81,0:09:53.94,Default,,0000,0000,0000,,We have one sample and a to t test. Dialogue: 0,0:09:53.94,0:09:57.72,Default,,0000,0000,0000,,It gives us eight t\Nwhich is our test statistic Dialogue: 0,0:09:58.13,0:10:00.86,Default,,0000,0000,0000,,which should match what we got up here. Dialogue: 0,0:10:00.86,0:10:02.88,Default,,0000,0000,0000,,And it does Dialogue: 0,0:10:02.88,0:10:05.20,Default,,0000,0000,0000,,the degrees freedom is pretty easy. Dialogue: 0,0:10:05.20,0:10:08.18,Default,,0000,0000,0000,,150 minus one. And then here's a P. Dialogue: 0,0:10:08.28,0:10:11.11,Default,,0000,0000,0000,,Same exact P-value\Nwe got here by doing a by hand. Dialogue: 0,0:10:13.18,0:10:13.74,Default,,0000,0000,0000,,And then Dialogue: 0,0:10:13.74,0:10:16.72,Default,,0000,0000,0000,,you can\Nkind of see they have X bar right here. Dialogue: 0,0:10:17.48,0:10:20.96,Default,,0000,0000,0000,,And then it also gives you\Nthat 95% confidence interval. Dialogue: 0,0:10:22.23,0:10:24.40,Default,,0000,0000,0000,,So this is an, quick and easy way Dialogue: 0,0:10:24.40,0:10:27.38,Default,,0000,0000,0000,,that you can compute a t test for me. Dialogue: 0,0:10:28.54,0:10:31.52,Default,,0000,0000,0000,,You can this is kind of showing you\Nhow to do it all by hand. Dialogue: 0,0:10:31.98,0:10:35.01,Default,,0000,0000,0000,,And then this will show you kind of\Nhow to just do it in one simple step Dialogue: 0,0:10:35.01,0:10:37.99,Default,,0000,0000,0000,,by computing a p value for you. Dialogue: 0,0:10:39.10,0:10:41.98,Default,,0000,0000,0000,,If you wanted to change what your, Dialogue: 0,0:10:41.98,0:10:43.54,Default,,0000,0000,0000,,your null hypothesis was. Dialogue: 0,0:10:43.54,0:10:48.04,Default,,0000,0000,0000,,So say, like you were testing,\Nis the mean equal to two instead? Dialogue: 0,0:10:48.75,0:10:50.21,Default,,0000,0000,0000,,You could totally do that. Dialogue: 0,0:10:50.21,0:10:54.56,Default,,0000,0000,0000,,And then you can see that\Nthis p value is way, way smaller. Dialogue: 0,0:10:55.67,0:10:59.41,Default,,0000,0000,0000,,Or if you wanted\Nto change your alternative. Dialogue: 0,0:10:59.56,0:11:03.65,Default,,0000,0000,0000,,So it's not that it's\Njust not equal to four and it's, you know, Dialogue: 0,0:11:03.65,0:11:07.39,Default,,0000,0000,0000,,maybe less or greater than. So Dialogue: 0,0:11:08.40,0:11:09.51,Default,,0000,0000,0000,,you could do it like this. Dialogue: 0,0:11:09.51,0:11:12.49,Default,,0000,0000,0000,,You can do less or Dialogue: 0,0:11:12.90,0:11:15.88,Default,,0000,0000,0000,,greater and that'll tell you, Dialogue: 0,0:11:17.69,0:11:19.26,Default,,0000,0000,0000,,which that'll Dialogue: 0,0:11:19.26,0:11:22.100,Default,,0000,0000,0000,,change the output of your hypothesis test, Dialogue: 0,0:11:22.100,0:11:26.18,Default,,0000,0000,0000,,kind of depending on if you're doing a\None sided or two sided test.