Lecture 4.1 - Comparing Groups
Comparing groups
- What type of inference is a test?
- A confidence interval for the difference between two means
- The two-sample test: testing for the difference between two means
- Experiments and causality
What type of inference is a test?
A review - descriptive vs. inference
Type of analysis | Descriptive | Inferential |
---|---|---|
Univariate | Histogram, bar chart | Confidence interval |
Univariate compared to theoretical expectation | QQ plot | One proportion z test, one proportion t test |
Comparing two variables | Scatterplot, two variable regression | Two proportion z test, two proportion t test |
Comparing many variables | Multiple variable regression | Multiple variable regression |
A review - one vs. two mean test
One mean test | Two mean test |
---|---|
Comparing the mean of your sample to some statement about the world | Comparing the mean of one part of your sample to another part of your sample |
Null hypothesis: based on some belief we have about the general population, i.e. students sleep 7.03 hours | Null hypothesis: no difference between groups |
Example
One mean test | Two mean test |
---|---|
: Our sample mean of hours of sleep is the same as all students in the world | : The sample mean of male students hours slept is the same as the mean of female students hours slept |
: Our sample mean is different than the world’s population mean | : The sample mean of female students is different than the sample mean of male students |
A confidence interval for the difference between two means/proportions
Difference between means/proportions: standard error
- Want to find the for
- Start with theoretical properties:
- Don’t know the population for each subsample, so use the sample s as before
Example: proportions
- 658 male passengers on the Titanic; 135 survived
- 388 female passengers on the Titanic; 292 survived
Confidence interval
What is the 95% confidence interval of the difference in means?
What can you conclude from this - how can you state the results? What are some factors that are omitted?
CI for the difference between two proportions/means
- First find two-sample / interval for the difference in means
- Then apply two-sample / test
- Interval looks like others we have seen
- Uses the model (proportion) or Student’s model (mean)
- The degrees of freedom for are complicated, so just use a computer
Sampling distribution for the difference between two means
When the conditions are met, the sampling distribution of the standardized sample difference between the means of two independent groups:
Uses the Student’s model
Degrees of freedom are found with a special formula
Think carefully here about what we are modeling
Assumptions
- Independence assumption:
- Within each group, individual responses should be independent of each other.
- Knowing one response should not provide information about other responses.
- Randomization condition:
- If responses are selected with randomization, their independence is likely.
- Independent Groups Assumption
- Responses in the two groups are independent of each other.
- Knowing how one group responds should not provide information about the other group.
Assumptions continued
- Nearly normal condition
- Check this for both groups
- A violation by either one, violates the condition
- in either group: should not use these methods if the histogram or Normal probability plot shows severe skewness
- closer to 40 for both groups: mildly skewed histogram is OK
- for both groups: Fine as long as no extreme outliers or extreme skewness
Confidence interval formally
When the conditions are met, the confidence interval for the difference between means from two independent groups is
where
Critical value depends on confidence level
The two sample test: testing for the difference between two means
A two sample test for difference between means
- Conditions same as two-sample t-interval
- ( usually )
- When the conditions are met and the null hypothesis is true, use the Student’s model to find the value.
Step by step example
- Is there a difference in housing price depending on if the house has a view?
- Think
- Plan: I have housing prices from many thousands of houses in King County, assumed to have been sampled randomly.
- Hypotheses
- Think
Step by step example
- Think
- Mean price of house with a view: 1772071, mean price no view: 1139608
- Model:
- Randomization Condition: Subjects assigned to treatment groups randomly?
- Independent Groups Assumption: Sampling method gives independent groups?
- Nearly normal condition: Histograms are reasonably unimodal and symmetric?
- The assumptions and conditions are reasonable?
After analyzing these assumptions , are we justified in using the Student’s t-model to perform a two-sample t-test?
Step by step example
- Show
- Mechanics
- Mean price of house with a view: 1772071
- Mean price no view: 1139608
- SD of view: 1128502
- SD no view: 823799
- of view: 433
- of no view 21504
- Mechanics
What is the formula we should use in the next step?
Step by step example
- Show
- Mechanics
- solve for the SE:
- solve for the SE:
- solve for the SE:
- find score:
- find score:
- find score:
- find value: can use table with ,
- Mechanics
Step by step example
Alternatively, we can use the built-in test function
- Show
What can we conclude, based on the results of this test? What are some assumptions of this test that may be violated?
Step by step example
- Tell
- Conclusion: the value = 0 is less than the critical value
- If there were no difference in the mean prices, then a difference this large would occur 1 times in millions of times
- Too rare to believe happened by chance? Yes
- Reject ? Yes
- Conclude that houses with a view are more expensive than regular houses? Yes
Experiments
Independence
- Independence assumption:
- Within each group, individual responses should be independent of each other.
- Knowing one response should not provide information about other responses.
- Randomization condition:
- If responses are selected with randomization, their independence is likely.
- Independent Groups Assumption
- Responses in the two groups are independent of each other.
- Knowing how one group responds should not provide information about the other group.
The importance of the counterfactual
For causal inference, one should ask the counter-factual question, for those who received “treatment”, what would have happened to them if they hadn’t been treated?
That is, we only observe one state of reality (had more vegetables), but we want to know the DIFFERENCE the treatment had on the person by asking what would have happened if the DID NOT receive the treatment
The importance of the counterfactual
More formally, we are interested in the difference the treatment has on the response variable (Health)
On a child ()that did receive more vegetables, we want to consider the case of what would have happened if they had NOT had the vegetables and find the treatment effect
- Or, = treatment effect ( denoting treatment; denoting control)
- Note that is observed, but is not.
The problem is one of missing data – how to estimate ?
Comparability problems
If subjects who receive treatment and those who do not are different in some important characteristics, we have selectivity bias – e.g. higher SES children were more likely to be in the vegetable treatment group
- Violates the independent group assumption because if rich children are more likely to be in the “eats vegetables” group we know that the observed value of the response variable, , is likely to be higher
- Knowing which group they are in gives us some knowledge of what their observed value of will be
Often called “omitted variable bias.”
Big problem in observational studies – many variables are probably not present that we’d like to know
What are some omitted variables that might bias our finding that houses on the view have a higher price than houses not on the view?
Experiments
- Experiments solve the omitted variable bias
- Random assignment of treatment and control status ensures that subjects differ ON AVERAGE only in the treatment they receive
- We can then compute the Average Treatment Effect (ATE) of being in the control vs. treatment
- A test between treatment and control group will therefore be accurate
- In observational studies, it is very rare to be able to guarantee that assignment to the two groups are independent of the response variable.
- If there are important other omitted variables that influence assignment to the two groups, need to control for these omitted variables via a multiple regression
Drawbacks of experiments
- Lack of generalizability – Often done on college students or in contrived settings (external validity)
- Cost – very expensive to run a full experiment
- Ethics – why shouldn’t we give positive treatments to everyone?
- Mechanically complicated
- Difficult to ensure proper randomization
- Difficult to design appropriate treatments
- Difficult to develop appropriate measurements
Multiple regression
- Multiple Regression
- Attempts to control for, or estimate the treatment effect, for each variable included, INDEPENDENT of the other variables
- How sure are we of the treatment effect?
- test of the slope of the regression line
- Null hypothesis is that treatment variable (“eats vegetables”) makes no difference on response variable
- If slope is non-zero, it indicates that differences in treatment produce differences in response variable (increase education increase in wages)