Last active
April 11, 2024 14:14
-
-
Save naomispence/b587b793e30949707eebd4089359aae9 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
#Lab: Scatterplots and Regression | |
#Load the libraries and data first | |
library(ggplot2) | |
library(dplyr) | |
library(lsr) | |
library(descr) | |
library(Hmisc) | |
library('lehmansociology') | |
data(gss123) | |
options(scipen = 999) | |
#Regression and scatterplots are for interval-ratio | |
#independent and interval-ratio dependent variables | |
#In this example, age will be our independent variable | |
#and spouse's highest education year will be our dependent variable. | |
#WHAT WOULD THE RESEARCH QUESTION, NULL HYPOTHESIS, | |
#AND RESEARCH HYPOTHESIS BE FOR THIS PAIR OF VARIABLES? | |
#Now we will do a statistical procedure called regression | |
#This is a linear model of an interval-ratio dependent variable with | |
#an intercept and an interval-ratio independent variable | |
# The indpendent variable is age, and the dependent variable is | |
#spouse's highest year of education attained. | |
results<-lm(gss123$speduc~age, data=gss123) | |
summary(results) | |
#WRITE AN INTERPRETATION OF THE RESULTS HERE | |
#WRITE AN INTERPRETATION OF THE ADJUSTED R SQUARED | |
#This is the code for getting the correlation coefficient | |
cor.test(gss123$speduc, gss123$age) | |
#WRITE AN INTERPRETATION OF THE CORRELATION COEFFICIENT OUTPUT HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment