1/19
Looks like no tags are added yet.
How can you compare categorical variables
Can be compared based on the proportion of people who fall into each category of the categorical variable
can be summarised in a two-way table
What is the chi-square test
A test used to explain the relationship between two categorical variables by comparing the actual counts with the expected counts
a non-parametric test that does not need a normal distribution
how to intrepret the chi-square test statistic
Quantifies the comparison between the observed and expected results if the null hypothesis were true
Sum of all cells’ (observed count - expected count)2/expected count
If above the critical value, then we can reject the null hypothesis
how is the p-value calculate in a chi-square test
uses a statistical distribution of x2 with a df of (r-1) x (c-1)
r = no of rows
c = no of columns
how to calculate expected count
used to calculate what resulst would look like if the null hypothesis were true
the sum of a row x the sum of a column / the total number of observations
what are the assumptions of the chi-square test
The test becomes more accurate as the counts in each cell get larger, so we use it when no more than 20% of expected counts are below 5, and all expected counts are above or equal to 1
need to be a fixed number of observations and a fixed number of answers (can’t be short answer, only multiple choice)
what are the hypotheses for the chi-square test
null: variable one and variable 2 are independent
One categorical variable does not lead to a change in another (men will not always like dogs more than cats)
alternative hypothesis: variable 1 and variable 2 are dependent
if you are a man you a more likely to prefer dog more than cats
what are residuals
When we reject the null hypothesis, we can look at residuals to determine the association between each variable
residuals = observed - expected
Basically, what is the extent of the relationship between the variables
What is a standardised residual
A measure of how much a cell contributes to the test statistic
observed - expected / square root of expected
A result >2 or < -2 indicates a significant difference between expected and observed (there is an association between variables)
What to use when normal distribution can’t be assumed
You can use non-parametric tests to determine the statistical significance between variables where a normal distribution cannot be assumed
Can also be done if outliers are present
What are non-parametric tests
a test that involves ranking numbers rather than focusing on their values
the Mann U Whitney test ( aka wilcoxon rank sum test) used an alternative to a two-sample test)
Wilcoxon signed rank test used as an alternative to one-sample or match pair test
How to undergo a Mann-Whitney U test
order the whole data and rank each observation from lowest(1) to highest(10)
add up all the ranks for each sample ( R1 = sample 1, R2 = sample 2)
calculate the test statistic
what to do if two value are the same when rank
you give ecah number the average of the two ranking they would fufill if they weren’t the same number
two rankings tied for 2nd place, 2+3/2 = 2.5
How to caluclate the test statistic
U = R1-n (n1 + 1)/2
n1: number of observations in 1 sample
calculates how often a rank from one group proceeds the rank of the other group
what are the hypothesises for a mann whitney U test
Null: no difference between the samples
Alternative: difference between each group
what if the samples have the same sampling ditsribution
if the samples have the same shape and spread then we look at their median
Null: median 1 - median 2 = 0
A: median 1 - median 2 doesn’t = 0
what are the hypothesis in a wilcoxon signed rank test ( matched pair)
Null: no systematic difference between pairs
Alternative: systematic difference between the pairs
How to calculate the test statistic ( matched pair)
Determine the difference between all the pairs in the data set
Order the differences based on value and rank
pairs with = differences are given the same rank
when differences are equal, they are excluded from the ranking system
calculate Wt, which is the sum of the rankings of all the positive differences
what is a Wilcoxon signed-rank test ( one sample)
a test used when the sample for a one-sample test is not normally distributed or contains outliers
Null: median = m0 (null value)
alternative: median doesn’t = m0 (null value)
the tests stat is calculated the same but we determine the differences between each value and the null value
How are p-values calculated in these test
Typically calculated using RStudio as an output from the test
If the sample has fewer than 50 values, the p-value then results are exact, if not an approximation of the p-value is used