Intro Stuff

setwd( "C:/Users/Jerome/Documents/Data_Science_110/Datasets")
library(tidyverse)
## -- Attaching packages ----------------------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.1     v dplyr   1.0.0
## v tidyr   1.1.0     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts -------------------------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(mosaic)
## Warning: package 'mosaic' was built under R version 4.0.2
## Loading required package: lattice
## Loading required package: ggformula
## Warning: package 'ggformula' was built under R version 4.0.2
## Loading required package: ggstance
## Warning: package 'ggstance' was built under R version 4.0.2
## 
## Attaching package: 'ggstance'
## The following objects are masked from 'package:ggplot2':
## 
##     geom_errorbarh, GeomErrorbarh
## 
## New to ggformula?  Try the tutorials: 
##  learnr::run_tutorial("introduction", package = "ggformula")
##  learnr::run_tutorial("refining", package = "ggformula")
## Loading required package: mosaicData
## Warning: package 'mosaicData' was built under R version 4.0.2
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
## 
## Have you tried the ggformula package for your plots?
## 
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:purrr':
## 
##     cross
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
lcn_sample_2 <- read.csv("lcn_sample_2.csv")

Run Regression

fit3 <- lm(MEASURE ~ as.factor(UrbRur) +as.factor(Educ) +as.factor(Wealth), data = lcn_sample_2)
summary(fit3)
## 
## Call:
## lm(formula = MEASURE ~ as.factor(UrbRur) + as.factor(Educ) + 
##     as.factor(Wealth), data = lcn_sample_2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -47.064 -18.295   8.012  14.900  40.980 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)          40.011      5.004   7.996 2.13e-13 ***
## as.factor(UrbRur)2    7.051      4.232   1.666   0.0975 .  
## as.factor(Educ)1     -2.634      3.593  -0.733   0.4645    
## as.factor(Educ)2     -5.875      9.821  -0.598   0.5505    
## as.factor(Educ)3      1.903      5.926   0.321   0.7485    
## as.factor(Educ)4     -4.718     21.722  -0.217   0.8283    
## as.factor(Wealth)2   -5.002      4.181  -1.197   0.2332    
## as.factor(Wealth)3   -2.004      4.885  -0.410   0.6821    
## as.factor(Wealth)4    7.064      5.641   1.252   0.2123    
## as.factor(Wealth)5    8.396     10.456   0.803   0.4231    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.3 on 165 degrees of freedom
## Multiple R-squared:  0.04773,    Adjusted R-squared:  -0.004216 
## F-statistic: 0.9188 on 9 and 165 DF,  p-value: 0.5103
print(fit3)
## 
## Call:
## lm(formula = MEASURE ~ as.factor(UrbRur) + as.factor(Educ) + 
##     as.factor(Wealth), data = lcn_sample_2)
## 
## Coefficients:
##        (Intercept)  as.factor(UrbRur)2    as.factor(Educ)1    as.factor(Educ)2  
##             40.011               7.051              -2.634              -5.875  
##   as.factor(Educ)3    as.factor(Educ)4  as.factor(Wealth)2  as.factor(Wealth)3  
##              1.903              -4.718              -5.002              -2.004  
## as.factor(Wealth)4  as.factor(Wealth)5  
##              7.064               8.396