Biostats Final Exam Flashcards
Idea of the Chi-Square test for Goodness of Fit: when to use it
- used when the data are categorical
- measures how different the observed data are from what we would expect if Ho was true
not symmetric –> p value always area to the RIGHT of test statistic
Chi-Square Statistic
(x^2)
- The chi-square statistic compares observed and expected counts
- Observed counts: the actual number of observations of each type (ex: number of babies born on Monday)
- Expected counts: the number of observations that we would expect to see of each type if the null hypothesis was true (ex: number you would expect to find/usually have calculated)
Large values for chi squared represent strong deviations from the expected distribution under Ho, and will tend to be statistically significant (large test stat –> small p values –> probably a significant result)
Chi-Square Distributions
the chi-square distributions are a family of distributions that take only positive values, are skewed to the right, and are described by a specific degrees of freedom
- p values always area to right of test statistic
- highly right-skewed
- won’t exist if we have negative value
- looks different for every degree of freedom
Goodness of Fit Hypothesis
The chi-square test can be used for one categorical variable (1 SRS) with any number of levels (k). The null hypothesis can be that all population proportions are equal (uniform hypothesis) or that they are equal to some specific values (as long as the sum of all the population proportions in Ho = 1)
- Ho: p1 = p2 = p3 =p4 = p5 = p6 = p7 = 1/7
- Ho: pA=1/4, pB=1/2, pC=1/4
For 1 SRS of size n with k levels of a categorical variable:
- When testing Ho: p1=p2=…..=pk (a uniform distribution), the expected counts are all= n/k
- When testing Ho: p1=p1Ho and p2=p2Ho…. and pk=pkHO, the expected counts in each level i are expected count(i)=n piHo
Conditions for the goodness of fit test
The chi-square test for goodness of fit is used when we have a single SRS from a population and the variable is categorical with k mutually exclusive levels
We can safely use the chi-square test when:
- all expected counts have values > or = 1.0
- no more than 20% of the k expected counts have values < 5
Chi-square test for goodness of fit: overview, degrees of freedom, p value
The chi-square statistic for goodness of fit with k proportions measures how much observed counts differ from expected counts. It follows the chi-square distribution with k-1 degrees of freedom
- The p value is the tail under the chi-squared distribution with df= k - 1
Interpreting the chi-squared statistic
The individual values summed in the chi-square statistic are the chi-square components (or contributions). When the test is statistically significant.
- The largest components indicate which condition(s) are most different from the expected Ho. Compare the observed and expected counts to interpret the findings.
- You can also compare the actual proportions quantitatively in a graph.
Chi-squared test – Lack of significance: avoid a logical fallacy
- A non-significant P value is not conclusive: Ho could be true or not.
This is particularly relevant in the chi-squared. goodness of fit test where we are often interested in Ho, that the data fat a particular mode.
- A significant p-value suggests that the data do not follow that model
- But finding a non-significant P-value is NOT a validation of the null hypothesis and does NOT suggest that the data do follow the hypothesized model. It only shows that the data are not inconsistent with the model.
Two-way tables
An experiment has a two-way or block design if two categorical factors are studied with several levels of each factor.
- Compare TWO categorical variables.
Two way tables organize data about two categorical variables with any number of levels/treatments obtained from a two-way, or block, design.
When you see a two-way table, you should think of a chi-squared test (mostly likely, test of independence)
Marginal distribution
The marginal distributions (in the “margins” of the table) summarize each factor independently (summary of one column/row over the total value of all participants)
- With two factors, there are two marginal distributions.
Conditional distribution
The cells of the two-way table represent the intersection of a given level of one factor with a given level of the other factor. This can be used to compute the conditional distribution (one individual value within the table over total for that row or column).
Two-way table: Hypotheses
A two-way table has r rows and c columns.
Ho: There is no association. between the row and column variables in the table.
Ha: There is an association/relationship between the two variables.
We will compare actual counts from the sample data with expected counts given the null hypothesis of no relationship.
Two-way table: Expected counts
The expected count in any cell of a two-way table when Ho is true is:
expected count = (row total x column total) / table total
Conditions for the Chi-Squared Test of independence
The chi-square test for two-way tables looks for evidence of association between two categorical variables (factors) in sample data. The samples can be drawn either:
- By randomly selecting SRSs from different populations (or from a population subjected to different treatments) - ex: girls vaccinated for HPV or not among 8th graders and 12th graders
- Or by taking one SRS and classifying the individuals according to two categorical variables (factors) - ex: obesity and ethnicity among high school students
We can safely used the chi-square test of independence when:
- very few (no more than 1 in 5) expected counts are <5
- all expected counts are > or = 1.0
The chi-square test for two-way tables: hypotheses, degrees of freedom, p-value
Ho: rows and column variables are independent (there is no association between the row and column variables)
Ha: row and column variables are dependent (there is an association)
The x^2 statistic is summed over all r x c cells in the table. (x^2 = sum of (observed - expected count)^2/expected count – formula sheet)
When Ho is true, the chi-squared statistic follows ~ chi-squared distribution with (r-1)(c-1) degrees of freedom.
P-value: P(chi-squared variable > or = calculated)
Chi-square test for 2-way tables: Interpreting the chi-squared statistic
When chi-squared test is statistically significant:
- the largest components indicate which condition(s) are most different from Ho. You can also compare the observed and expected counts or compare the computed proportions in a graph.
- Reject null –> conclude relationship between the two categorical variables
- largest: probably most related
ANOVA test: brief description
analysis of variance test (compare 3+ groups)
Comparing Several Means
- When comparing >2 populations, the question is not only whether each population mean, mu i, is different from others, but also whether they are significantly different when taken as a group.
- extension of a 2-sample design
- compare 3+ groups using mean (average)
ANOVA
Handling Multiple Comparisons Statistically
- The first step in examining multiple populations statistically is to test for an overall statistical significance as evidence of any difference among the parameters we want to compare –> ANOVA F TEST
- AFTER: If the overall test showed statistical significance, then a detailed follow-up analysis can examine all pair-wise parameter comparisons to define which parameters differ from which and by how much —> more complex methods
Essentially:
(1) Compare all groups together - Are means all equal to each other or is at least 1 different!! (ex: did none of the drugs work or at least 1?)
(2) If reject Ho, find out which groups more different.
Sample variance + standard deviation
*** may be given s, have to know s^2 or vice versa
Sample variance: s^2
Sample standard deviation: s
ANOVA test: hypotheses
Ho: always a statement about the population (mu, NOT x bar)
examples:
Ho: mu1 = mu2 = m3
Ha: at least one mu(i) is different (Ho is not true)
Factor
a variable that can take on of several levels used to differentiate one group from another
An experiment has a one-way or completely randomized design if:
if several levels of one factor are being studied and the individuals are randomly assigned to its levels
- Ex: one way = 4 levels of nematode quantity in seedling growth experiment
- Ex: two way = 2 seed species and 4 levels of nematodes
One-way ANOVA
used for completely randomized, one-way designs
- need quantitative variable
The ANOVA F Test
The analysis of variance F test compares the variation due to specific sources (levels of the factor) with the variation among individuals who should be similar (individuals in the same sample).
Ho: All means (mu i) are equal
Ha: NOT ALL means (mu i) are equal (Ho is not true).
The analysis of variance F statistic for computing several means is:
F = variation among the sample means (variation between groups) / variation among individuals in the set of samples (variation within) = MSG/MSE
F test: looks at variation between groups vs. variation within groups
- how do the means vary? how do the observations within each sample vary?
K: # of levels (# of groups comparing)
ANOVA F Test: variability + F value trends
- Variability of means smaller than variability within samples —-> F tends to be small
- Variability of means larger than variability within samples –> F tends to be large
Small test statistic (F) corresponds to high p-value
- Large F –> small p-value
ANOVA F Test assumptions
- The k samples must be independent STSs. The individuals in each sample are completely unrelated (randomization + no overlap between groups)
- Each population represented by the k samples must be Normally distributed. However, the test is robust to deviations from Normality (skew, mild outliers) for large-enough samples, thanks to the central limit theorem
- The ANOVA F-test requires that all k populations have the same standard deviation sigma.
- — There are inference tests for this, but they tend to be sensitive to deviations from the Normality assumption or require equal sample sizes.
- — A simple and conservative approach: The ANOVA F test is approximately correct when the largest sample standard deviation is no more than ~ twice as large as the smallest sample standard deviation.
Equal sample sizes make the ANOVA more robust to deviations from the equal sigma rule (if sample sizes equal, test more robust)
Summary:
1. Independent random sample
2. Normal populations or large enough sample size
3. Equal population standard deviation (largest sd/smallest sd <2. If >2, don’t do ANOVA test)
+ Have to check normality for each group
Have to satisfy all three assumptions to be able to do ANOVA test
ANOVA test calculations
- We have k independent SRSs, from k populations or treatments. The (i)th population has a Normal distribution with unknown mean mu(i). All k populations have the same standard deviation sigma, unknown.
k = number of groups being compared N = total sample size (n for all groups added together) k-1 = numerator degrees of freedom N-k = demoninatory df Ho: mu1=mu2...muk
F (test statistic) = MSG/MSE = (SSG/(k-1))/(SSE/(N-k))