##
#
# MEBn5033 In-class practice without solutions 12: simple regression analysis
#
##

#
# 1. read in "states_complete.csv" dataset
#

dir()

?read.table


# attach the dataset
attach(states)

#
# 2. use descriptive statistics to variables romney 2012, ba_or_more, relig_prot
#

?summary


#
# 3. plot relationship between variable:
# X axis: relig_prot, Y axis: romney2012
# X axis: ba_or_more, Y axis: romney2012
#

# try to add straight line by combining functions abline() and lm()

?plot


#
# 4. fit linear model: romney2012 ~ relig_prot by using lm() function 
# interpret the results
#

?lm

?summary

#
# 5. fit linear model: obama2012 ~ ba_or_more by using lm() function 
#

?lm

?summary

