title: Advanced Statistics
subtitle: DLMDSAS01
authors: Prof. Dr. Unknown
publisher: IU International University of Applied Sciences
date: 2023
pp. 181 - 205
Our learning objectives are as follows:
Buckle up for a wild ride
We often want to make a “statement” about the entire population, but we only have samples of said population. It is usually impossible to analyse an entire population of anything. We therefore must define a suitable sample(s) that we can use to make such a “statement” about the entire population. For example, we cannot give medicine to every human on earth, but want to state “this vaccine protects you against Covid-19.”
One challenge is to avoid biases and ensure the sample is representative of the population.
If we assume that we have gathered such an unbiased sample that is a good representative of the population then we want to develop and test a hypothesis, deciding if it is true based on the sample.
The Null Hypothesis is a statement that represents no effect. Typically denoted as (said “H-not”), and it denotes the absence of an effect. The Alternative Hypothesis, denoted as is the presence of the effect we want to establish.
How do we do this?
The course book dives into a quick example about cholesterol medication that I will include to learn notation. When participants take the medicine we gather data, say changes to their Cholesterol. Well, you’d get the cholesterol levels and find the changes yourself. Then, we would be interested in discriminating between the null hypothesis, that the medicine did not have an effect, versus that the medicine caused some change in cholesterol.
Because the aim would be to lower cholesterol, you might change the null hypothesis to include if the cholesterol increased, and modify the test hypothesis to only include if the cholesterol levels decreased.
The hypothesis tests is defined as a rule that we can use to do either:
A paired test is the case when we have at least two measurements from the same source, a person in the example above.
Randomized controlled trial removes biases by having two groups, a control group to monitor without introducing changes like a new medicine, often using a placebo, and the test group that has the change introduced. Participants are randomly selected and ideally concealed from people administering the tests. Instead of pairing data points like above, this trial considers two independent samples.
When we take measurements we obtain a large dataset of values taken from each sample, . You can say we obtain a distribution of values for each group. To perform the hypothesis test to decide whether to accept or reject the null hypothesis, we must construct a test statistic . We use this to derive our decision formally.
The easiest way to discriminate between the null and alternative hypothesis is to compare the (sample) mean of the two groups. Per the central limit theorem, any sum of identically distributed random numbers will approximate a normal distribution. If the number of individuals in each sample is sufficiently large then the samples follow an approximate normal distribution.
What is “sufficiently large”? In an old statistics course I took, we were told was a good rule of thumb. The course book drops this down to .
We must walk before we run, and stand before we walk. We start with only one group that we want to determine whether it is compatible with a given hypothesis. But first, what is a z-score? The z-score, for a statistic , is defined as:
where is the mean and is the standard deviation of the population. I don’t think this is a proper introduction as it is rooted in the normal distribution. Basically, we let be the standard normal distribution. Then we note that a normal distribution , where the spread and alignment are determined by and .
Our test -score with the group mean as :
Good to note that the more elements we consider in our sample, the larger becomes, and the smaller the standard deviation. If the samples are taken from a normal distributed sample, will also follow a normal distribution without relying on the central limit theorem… because it is the standard normal distribution.
In most cases, we do not know the population statistics and need to rely on sample statistics, like sample standard deviation , which has one less degree of freedom than the population.
I changed the sample mean to be because that is how I was taught and the way for angle brackets is a lot of typing.
Quick recall of sample variance:
This is an unbiased estimator because of the correction factor .
We have two random variables in the definition of , the sample mean and sample variance. Our value does not follow a normal distribution because of the use of the sample variance instead of the population variance. However, it will follow the Student’s t-distribution, which has a single parameter, the number of degrees of freedom.
The Student’s t-distribution | wiki is a generalization of the standard normal distribution. It’s bell shaped and symmetric around zero. The difference is that (the t-distribution) has heavier tails, and the amount of probability given to the tails is controlled by its parameter . For the t-distribution becomes the standard Cauchy distribution with fat tails. And for , the t-distribution becomes the standard normal distribution.
The Student’s t-distribution | Simple.Wiki was developed by William Sealy Gosset in 1908 and named after the pseudonym he used whilst publishing the paper.
More information about the math can be found on the page Student’s t-Distribution | Wolfram MathWorld.
If the variable follows a normal distribution, perhaps approximately via the central limit theorem, then will follow the t-distribution. In the sample variance case, the number of degrees of freedom is .
The Student’s t-Distribution behaves much like the standard normal distribution but with more pronounced tails, essentially shifting some of the probability of outcomes. If a variable follows a Student distribution with degrees of freedom, we write . The PDF of is given as follows:
Obviously not the easiest function to work with.
Now, let us look at the case of two groups. We construct a test statistic similar to the -score:
We have there the difference in sample means on both the top and bottom. The constant is the known difference between the population means under the null hypothesis. And is an estimate of the standard error of the difference between the two samples.
In most practical applications we would set because we would not know that information unless we had further or external knowledge about the population.
From the propagation of uncertainties, we can recall the standard error of the differences is given by:
Therefore, if you somehow know the variance of the population, the equation becomes:
However, it would be a bit odd (in my opinion) to have the population variance but no the population means. Therefore, we typically estimate them from the sample variance, giving:
This is a -distribution (proven by Hogg et al. theorem 3.6.1) but the degrees of freedom (d.o.f.) can be difficult to determine when either the sample variances nor the number of elements in the sample are the same.
The value of the number of degrees of freedom is between the limits:
If , you can see the range would be quite large.
A reasonable approximation is the harmonic mean:
If we assume the variances in the two groups are the same, this is called the Two-Sample Student’s t-Test. If we allow the variances to be different from each other, it is called the Welch’s Test.
For Paired Samples, the test can be expressed as a special case of the one-sample t-test. Instead of viewing start and end as two different groups, we take the difference and work with that as just one group. Let be the difference between 2 samples. The test statistic becomes:
Who uses the division sign anymore?
We know that is the sample mean of the difference and that is the sample standard deviation of the differences. The population mean, is the hypothesis we want to test. And is the number of paired measurements, giving degrees of freedom.
There is some confusion around number of samples and degrees of freedom, especially in the two-case scenario.
Now, given that the null hypothesis is true, we can use the distribution of this test statistic to decide whether the observed value of the test statistic is unlikely or not. The observed value of the test statistic comes from replacing all the estimators by their observed values:
To observe if this test statistics is statistically significant, we need to see where it falls in the distribution. And to make a decision, we need to set a cut-off value, which we will denote .
The book shows a graph for the example of the standard normal distribution. The cutoff point is at the tail(s) of the distribution, depending on your null hypothesis. If we have a null hypothesis, and our test statistic lands in the high probability region of the distribution, the main bell, then we fail to reject the null and accept there was no change. However, if the test statistic lands in the tail beyond the cut-off, we can more safely reject the null hypothesis.
A note on the distribution. When we take a “large enough” sample, we generally just assume the sample mean follows a normal distribution. However, when we perform the analysis, we need to check if the distribution actually follows a normal distribution. The t-test works well for symmetric distributions, like the normal distribution. It does not work well for asymmetric distributions.
This means that, in practice, if we have to deal wit ha situation where the assumption that the underlying distribution is a normal distribution is not fulfilled, we have to take this into consideration as a source of systematic uncertainty and quantify how big the effect of this non-normality is on our final result.
p. 187
From above, to decide between the hypothesis we need to construct a function of t he measurements that maps the measured values into a number:
This function can be anything from simple to a sophisticated machine learning algorithm. Using this function, we can show the distribution of this test statistic for the null and the alternative hypothesis, which we will discuss below.
To determine if we should reject the null hypothesis, we need to define a critical value such that:
Unfortunately, in most realistic cases we cannot distinguish between the null and alternative hypothesis perfectly. The distributions of the test statistics for the two cases will overlap. The course book shows a graph of 2 bell curves which I think is an interesting perspective. Basically, our data gives us a certain curve, and the t-test is also a certain curve. Their tails will overlap at a kind of meaningful portion of the curves.
This leads to 2 types of Errors:
The course book also provides a nice table…
I more mathematical terms:
The cut-off value will affect these probabilities. In many practical applications, is chosen in advance, which determines the cut-off value . We would decide ahead of time what kind of Type I error we are willing to tolerate. We do this before looking at the data because once we look at the data our tolerance become bias. Consider an edge case. If we look at the data and believe we should reject the , we might adjust probabilities to make it so.
Our probabilities and have an inverse relationship, which should be clear.
I do love this definition… The rejection region (RR) is the set of values of the statistic that are at least as extreme as the cut-off value. It was hard at first for me to understand, but these values are at least as extreme. By “extreme”, we mean that they are not near the null hypothesis, they are extreme values living in the tail end of the probability distribution. Anything at least as extreme, or more extreme, falls into the rejection region and causes us to reject the null hypothesis.
The chosen value of is a naive metric for evaluating the performance of the hypothesis test. A more useful metric is the “power of the test”.
The Power of the Test is a measure of the quality of a test with respect to the probability that the testing process will detect an effect. Informally, it is the probability that the hypothesis test will yield a decision to reject :
and describes the probability to detect an effect if it is indeed there.
Ok, let’s have a look considering a test about parameter , our favourite parameter. Suppose we have , The alternative is . Given , the test statistic , and the rejection region, the power of the test when the actual parameter is is:
The probability our test statistic is in the rejection region given that our parameter is in-fact extreme, is qual to rejecting the null hypothesis.
Now, we go to our Type II error, is the probability of failing to reject when the true value of the parameter is :
The book then flies into an example with , and we want a confidence level of .
The Hypotheses tests are:
Note, sometimes the alternative is and so we would consider both tails of the distribution. That is like cutting the confidence interval in half and applying each half to each side of the distribution (You can see why we like symmetry). In the above case, since we are only concerned with the greater than side, that is the right side of the distribution.
The one-sample Student’s t-test is given by:
That little formula is based on the sample mean and the population standard deviation. If is sufficiently large, then by the central limit theorem, the distribution of will follow a normal distribution if we do know the population standard deviation. If we only have sample standard deviation (typically) then we fall back on the Student’s t-distribution with degrees of freedom.
With our chosen cut-off, we have . Our -score will only follow the normal distribution in this example because we are pretending we know the population standard deviation.
Now, I haven’t covered how to look up values in a normal distribution table, but it’s quite simple. You can find tables online, Standard Normal Distribution Table | MathIsFun.com. This has a cool slider. Because we know our alpha, we look in the table for its value. This one is actually a more difficult table because it only takes the right half, but the graph is symmetric. As such, we are looking for . It lands right between so we split the difference linearly, . This gives us .
We don’t have , but if we did, it’s just a matter of comparison.
Suppose the true value of the (population mean). Let’s look at and power of the test at 16 too. Remember, our null hypothesis assumes .
And the power of the test:
The probability of the Type II error decreases as the sample size increases, and the power of the increases with the sample size.
The book continues the evaluate when . The probability of a Type II error is about 36%. That is a large change to fail to reject the null hypothesis when the real parameter is just one unit large than assumed. If that is the case, and that unit would be significant, we would need more data to decrease that probability.
Note that the probability of a type I error and the power of a test have an inverse relationship. We want the power to be high and the probability of committing a type I error to be low.
p. 193
We can approach hypothesis testing from another angle. If we look at the distributions of the test statistic for the null and alternative hypothesis, we might be tempted to choose the cut-off value where they intersect. This choice is not optimal if the apriori probabilities of the null and alternative hypothesis are very different.
Using the Bayesian priors for the null hypothesis and the alternative hypothesis , we can define the cut-off as the biggest such that:
Function is the distribution of the test statistic for the null and alternative hypothesis. The best choice is determined by the Neyman-Pearson Theorem.
Per the Introduction to Mathematical Statistics text, by Hogg et al., p. 472
Theorem 8.1.1 - Neyman-Pearson Theorem: Let , where is a fixed positive integer, denote a random sample from a distribution that has pdf or pmf . Let be an the unknown distribution parameter(s). The likelihood of is
Let and be distinct fixed values of so that . We will also let be some positive number. And we let be a subset of the sample space such that
Ok… Then C is the best critical region of size for testing the simple hypothesis against the alternative simple hypothesis .
The text book continues on with a proof.
Our course book states, the most powerful test has a rejection region given by:
where is chosen so that the probability of the Type I error is . I do like the latter notation as it’s not giving the impression that there’s a derivative anywhere.
The course book then dives into an example with a Poisson distribution. Poisson is a decent example because the exponents make easy work of the product of pdfs.
p. 196
We are going to discuss in more detail how we can quantify the significance of the result of the hypothesis test. A good question is, “As we have observed a difference between the groups and, say, rejected the null hypothesis and accepted the alternative hypothesis, how sure are we that this is not due to random chance?”
If we repeat the same experiment many times using different samples, how sure are we that we would always observe this difference between the groups?
Questions like these are important in practice. Take the field of medicine for example. You want to be very sure that a drug is both safe and effective. We need a metric that allows us to make a statement that an observed outcome, for example, the difference of the sample mean of two groups, is larger than we would expect if from random variations and chance alone.
For a result to be statistically significant we require the expected variation due to random fluctuation to be smaller than what we see. This is express by the -value, defined by the American Statistical Association as:
Informally, a -value is the probability under a specified statistical model that a statistical summary of the data would be equal to ore more extreme than its observed value.
For a test statistic , the -value is the smallest value of for which the observed data suggest that the null hypothesis is rejected. So, the smaller the -value, the more unlikely the data comes from the distribution specified by the null hypothesis.
We have already seen the use of threshold , which is practical. We make two important observations:
The -value is not easily understood though. The previous author continues:
While the -value can be a useful statistical measure, it is commonly misused and misinterpreted. This has lead to some scientific journals discouraging the use of -values, and some scientists and statisticians recommending their abandonment, with some arguments essentially unchanged since -values were first introduced.
Now, how do we calculate the -value? We assume we have two hypotheses, our null and alternative. The -value is the probability of observing a value of our test statistic that is at least as extreme as the observed value, assuming is true at first.
I am letting be the observed test statistic, as I don’t want to write the work “observed” in the formula.
The -value is based on a random sample. Therefore it is itself a random variable distributed on the interval .
If the null hypothesis is true, the distribution of -values is uniform, each value is equally likely. That is an interesting take.
Summary of what the -value is:
What the -value is not:
p. 201
Reporting a “significant” result based on the -value can be very misleading if we do not describe the way we test the hypothesis. We must also report all the tests that did not yield a significant result.
The course book gives a Jelly-Bean example… Let’s say it is observed that people who eat jellybeans have more acne. So we test each colour independently and notice that the green ones cross the threshold we set of . What does this mean?
Well, if we publish that we tested 100 different colours and we found the green ones to be significant we must remember that even at , we are saying that we accept 1 out of 20 results with cross the threshold on chance alone.
If we perform multiple hypothesis tests then we need a mechanism that can prevent us from obtaining statistically significant results by testing several hypotheses and cherry picking the ones that give use promising results.
The Familywise Error Rate (FWE) aims at reducing the overall probability of rejecting true null hypothesis in multiple hypothesis testing.
The Family-wise error rate | Wiki is the probability of making one or more false discoveries (I like this definition), or Type I errors when performing multiple hypothesis tests.
There’s also the discussion, Familywise Error Rate | StatisticsHowTo.com. Has very similar definition of the probability of making at least on Type I Error.
If we have 100 tests, like colours of jellybeans, with , means each one has 95% chance to be correctly assessed. If they are independent, then we can say of the 100, there is a chance they are all assessed correctly, or about a 99.4% chance that at least one true null hypothesis is rejected by chance.
This begs the question, what should we set to then? We would like the overall value to be 0.05, so we rearrange the equation as follows:
Note, the above example is slightly approximate because of has a lot of decimal places.
The typical method to control the Familywise Error Rate (FWE) is the Bonferroni method. This method rejects a specific null hypothesis if its corresponding -value is less than , where is the number of hypothesis. This works because when is small:
An issue with this type of control is that the multiple testing procedure might result in a low power. The power is the ability to reject a false null hypothesis. It can become too restrictive, so we look for an alternative measure.
When we have many hypothesis tests, it might make sense to allow a small proportion of true null hypotheses to be rejected. This means accepting a small fraction of false discoveries, as long as we are able to quantify the level and can introduce a control method that allows us to specify the level at which we accept these false discoveries. This is so the power is not too low.
We will define a measure that controls the proportion of true null hypotheses rejected. Let’s cover some notation:
Since we do not know if the null hypothesis is true or not during testing, the quantities with or are technically not accessible. We can measure the number of experiments we do, the number of discoveries that exceed the threshold and the number of where we do not exceed the threshold.
In a single hypothesis test, we want to have a small Type I error (rejecting a true null hypothesis). That is, we want to control the probability of a false positive (detecting an effect when there is none). The False Discovery Rate (FDR) is the corresponding quantity for multiple hypothesis test, which is the expected proportion of the false positive with respect to all positives:
We compute the expected value because the discovery rate is a random variable. We have unfortunately defined our formula with values that are not observable and therefore it is not computable.
For uncorrelated or positively correlated test, we can us the following approach!
For each test, we define the null hypothesis, . Each hypothesis has an associated -value. Now, order the hypotheses in ascending order by their -values:
Now choose the largest value such that
Then, the hypotheses are rejected and we say that we control the FDR at level . Additionally, we choose the value of such that the number of rejections is maximised.
In case that the hypotheses are correlated between the tests, we modify the procedure such that:
Where
Q1: We aim at testing the hypothesis that a new sample shows a greater mean for a variable which we assume follows a normal distribution of known average and variance. Which test is appropriate, considering that we do not know the size of the sample?
a.) Student’s t-test b.) -test c.) -test d.) -test
The Chi-Squared test | Wiki I don’t think was mentioned in this unit. It is apparently used when the sample sizes are large. There’s a little more to it but because it sounds like it requires the sample size, we cannot use.
The F-Test | Wiki Also was not yet discussed. The test statistic is used to determine if the data has an F-Distribution under the null hypothesis. Looking through the maths, it it contingent a degrees of freedom that depends on the sample size.
The -test also depends on the sample size. Therefore, because it sounds like we know the population statistics, and we don’t know the sample size, we should use the -test, (c).
Q2: What is Type I error give the null and alternative hypothesis as and ?
a.) Cases when the statistics calculation makes our test conclude that is true while is actually true. b.) Cases when the statistics calculation makes our test conclude that is true while is actually true. c.) Cases of any of the two errors. d.) Measured with the probability , the power of the test.
The definition in the book states Type I is when the sample appears extreme, significant enough to incorrectly reject and accept . I think it would be (b).
Q3: What kind of relationship does the power of the test have with the value? That is, as increases, how does the power of the test behave?
a.) Increases b.) Varies unpredictably c.) Stays equal d.) Decreases
I believe the course book stated that the power has an inverse relationship with . Yes, on p. 192 it states, ”… it is important to consider that the probability of a type I error and the power of a test have an inverse relationship.” So if increases, the power decreases (d).
The power of a statistical test is the probability of correctly rejecting the null hypothesis when it is false. In other words, it is the probability of detecting a real effect when it is present. The power of a test is influenced by several factors, including:
A test with a high power is more likely to correctly detect a real effect. Conversely, a test with a low power is more likely to miss a real effect. When designing a study, it is important to choose a significance level, effect size, and sample size that will provide a reasonable level of power.
Here is a table that summarizes the relationship between the significance level, effect size, and power of a test:
Significance level (α) | Effect size | Power |
---|---|---|
0.05 | Small | 0.20 |
0.05 | Medium | 0.80 |
0.01 | Small | 0.05 |
0.01 | Medium | 0.60 |
As you can see, the power of a test increases as the significance level decreases and the effect size increases. However, it is important to note that the power of a test can never be 100%, even if the effect size is large. This is because there is always some chance that the observed difference between the two groups could be due to random chance.
The correct answer is apparently (a), increases.
The power of a statistical test and the significance level (often denoted by alpha, α) are inversely related. The power of a test is the probability that it correctly rejects a false null hypothesis. In other words, it is the ability of the test to detect a true effect or difference when it exists.
The significance level (alpha, α) is the probability of incorrectly rejecting a true null hypothesis. It is the probability of making a Type I error, which is the error of rejecting a null hypothesis that is actually true.
The relationship can be summarized as follows:
Power (1 - β): The power of a test increases as the probability of making a Type II error (β) decreases. Power is influenced by factors such as the effect size, sample size, and the variability in the data.
Significance Level (α): The significance level is the probability of making a Type I error. It is typically set by the researcher before conducting the test and is denoted by α.
Inverse Relationship: There is an inverse relationship between power and the significance level. As you decrease the significance level (α), you increase the probability of making a Type II error (β), which in turn decreases the power of the test. Conversely, as you increase the significance level, you decrease the probability of Type II error, thereby increasing the power of the test.
In summary, there is a trade-off between the risk of Type I errors (α) and Type II errors (β). Researchers must carefully choose the significance level based on the desired balance between these two types of errors, taking into consideration the specific context and consequences of each type of error in their study.
OK, so I think I thought of Alpha incorrectly. It’s almost like we always view it backwards, if we drop a 95% confidence interval down to just 90%, then the probability of failing to reject the null hypothesis goes up, and the probability of correctly rejecting it decreases…
Q4: An -test tests that:
a.) The variance of the second sample is left stable. b.) The probability that the variances differ is high. c.) How good is an estimate of the variance. d.) The variances of two samples differ significantly provided they are (or approximately) normally distributed.
Section 3.6.2 of Introduction to Mathematical Statistics specifically covers the -distribution, starting on page 212. It begins with 2 chi-square random variables and divides each by their degrees of freedom, and then divides those by each other. That is,
The F-Distribution | Wiki arises frequently as the null distribution of a test statistic, notably in the analysis of variance (ANOVA), and other F-Tests.
The F-distribution is a continuous probability distribution that is used in hypothesis tests to compare two or more variances. It is named after Sir Ronald Fisher, an English statistician who developed it in the early 20th century.
The F-distribution is typically used in two types of hypothesis tests:
One-way analysis of variance (ANOVA): This test compares the means of two or more groups. The null hypothesis is that all of the groups have the same mean. The F-statistic is calculated by dividing the variance between the groups by the variance within the groups. If the F-statistic is greater than a critical value, then the null hypothesis is rejected. This means that there is evidence to suggest that the means of the groups are not equal.
Testing the equality of variances: This test compares the variances of two or more populations. The null hypothesis is that all of the populations have the same variance. The F-statistic is calculated by dividing the larger sample variance by the smaller sample variance. If the F-statistic is greater than a critical value, then the null hypothesis is rejected. This means that there is evidence to suggest that the variances of the populations are not equal.
Here is a table of some of the common uses of the F-distribution:
Hypothesis test | Null hypothesis | Test statistic | Critical value | Interpretation |
---|---|---|---|---|
One-way ANOVA | All groups have the same mean | F = (between-groups variance)/(within-groups variance) | F > critical value | Reject null hypothesis if means are significantly different |
Testing equality of variances | All populations have the same variance | F = (larger sample variance)/(smaller sample variance) | F > critical value | Reject null hypothesis if variances are significantly different |
The F-distribution is a versatile tool that can be used to test a variety of hypotheses about variances. It is a widely used distribution in statistical analysis.
The F-distribution is a fairly robust test, meaning that it can still be used to compare variances even if the samples are not strictly normally distributed. However, if the samples are heavily skewed or have outliers, then the F-test may not be as accurate. In these cases, it may be better to use a non-parametric test, such as the Kruskal-Wallis test or the Welch’s ANOVA.
Here is a table summarizing the conditions under which the F-test is valid:
Condition | Requirement |
---|---|
Independence | The samples are independent of each other. |
Equal variances | The populations from which the samples were drawn have equal variances. |
Normality | The samples are approximately normally distributed. |
If the samples are not normally distributed, but they are not severely skewed or have outliers, then the F-test may still be a reasonable choice. However, it is important to be aware of the limitations of the test and to interpret the results cautiously. If the samples are severely skewed or have outliers, then it is best to use a non-parametric test.
Let’s go with (d) for the win.
Q5: When applying the Student’s -test on a normal variable, what are the parts we must calculate?
a.) The sample mean and size. b.) The sample size and theoretical variance. c.) The accuracy and sample size. d.) The sample mean, variance, and size, as well as the theoretical mean.
This question does not involve the second case in the course book where we compare 2 different groups. The test statistic is
So we have everything in (d).