Created
October 26, 2023 15:15
-
-
Save naomispence/09897ad14b3479879d7ccb617df7b3da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################BIVARIATE INFERENTIAL STATISTICS############################################################## | |
####ANOVA for a quantitative dependent variable (DV) and categorical independent variable (IV) | |
#run an analysis of variance (ANOVA); only change variable names and put in this order DV ~ IV | |
#IMPORTANT: USE THE COPY OF YOUR CATEGORICAL VARIABLE THAT YOU USED FOR THE BAR GRAPH (variable name ends in cat) | |
data.aov1 <- aov(wave5addhealth$H5ID23 ~ wave5addhealth$H5HR2cat, data=wave5addhealth) | |
summary(data.aov1) | |
#remove hashtag on line below to run Tukey ONLY if the F test is statistically significant AND there are more than 2 categories on the IV. | |
#TukeyHSD(data.aov1) | |
##INTERPRETATION OF ANOVA: The ANOVA results show a statistically signficant relationship between living arrangements | |
# and the amount of time spent watching TV, movies, and videos among adults in the United States (F=8.58; p<.05). | |
# Tukey's post-hoc test shows more specifically that adults who live in their parents' home or another persons' home | |
# watch significantly more TV, movies, or videos than those who live in their own place (p<.05). There is a difference | |
# of about 4 hours per week between those living arrangements. | |
####CHI SQUARE for categorical independent variable and categorical dependent variable | |
#only change the variable names | |
data.chisq1 <- chisq.test(wave5addhealth$H5OD2A, wave5addhealth$H5HR2) | |
data.chisq1 | |
##INTERPRETATION OF CHI SQUARE: The chi square test of independence shows that there is a statistically significant | |
# association between sex at birth and living arrangements among adults in the U.S. (chi squared=14.715; p<.05). | |
####CORRELATION for 2 quantitative variables | |
#only change the variable names | |
cor.test(wave5addhealth$Age, wave5addhealth$H5ID23) | |
##INTERPRETATION OF CORRELATION: There is not a statistically significant association between age and amount of | |
# time that adults in the U.S. spend watching TV, movies, or videos (Pearson's correlation= .013; p>.05). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment