# Packages list
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
library(ggplot2)
rm(list = ls())
gc()
## used (Mb) gc trigger (Mb) max used (Mb)
## Ncells 794618 42.5 1266607 67.7 1266607 67.7
## Vcells 1395242 10.7 8388608 64.0 2253842 17.2
cat("\f")
dt <- data.frame(state.x77)
\[ Income \sim \beta_0 + \beta_1 \ Illiteracy + \beta_2 \ Population + \beta_3 \ Area + \epsilon_i \]
reg1 <- lm(data = dt,
formula = Income ~ Illiteracy + Population + Area)
suppressWarnings(stargazer(reg1 , type = "text"))
##
## ===============================================
## Dependent variable:
## ---------------------------
## Income
## -----------------------------------------------
## Illiteracy -498.848***
## (114.900)
##
## Population 0.035**
## (0.016)
##
## Area 0.003***
## (0.001)
##
## Constant 4,670.198***
## (165.430)
##
## -----------------------------------------------
## Observations 50
## R2 0.413
## Adjusted R2 0.374
## Residual Std. Error 486.018 (df = 46)
## F Statistic 10.774*** (df = 3; 46)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
summary(reg1)
##
## Call:
## lm(formula = Income ~ Illiteracy + Population + Area, data = dt)
##
## Residuals:
## Min 1Q Median 3Q Max
## -751.92 -374.03 -82.93 347.95 1192.13
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.670e+03 1.654e+02 28.231 < 2e-16 ***
## Illiteracy -4.988e+02 1.149e+02 -4.342 7.7e-05 ***
## Population 3.476e-02 1.564e-02 2.222 0.03125 *
## Area 2.851e-03 8.162e-04 3.492 0.00107 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 486 on 46 degrees of freedom
## Multiple R-squared: 0.4127, Adjusted R-squared: 0.3744
## F-statistic: 10.77 on 3 and 46 DF, p-value: 1.755e-05
For the first variable, the relationship does make sense because a greater illiteracy means a bigger percentage of your population that is not attending school. An increase in 1 percentage unit in the illiteracy results in reduction of 498.848 dollars. Surprisingly, this variable is not statistically significant since the p-value is greater than 0.05.
For the second variable, the relationship does make sense since a greater population means more people paying taxes and spending in the particular state’s economy. An increase of 1 unit in population leads to an increase of 0.035 dollars. This variable is statistically significant but the magnitude of the change is small.
For the third variable, the relationship does make sense since a greater area means more space for development. An increase of 1 unit in area leads to an increase of 0.003 dollars. This variable is statistically significant but the magnitude of the change is also small.
Overall, The model is not a very good one at predicting income because only about 41.27% of the change in income is explained by the variables in our model, so we are missing out more determinant factors.
plot(reg1)
The fitted values vs residuals graph indicates that the relationship between the dependent and independent variables is not linear. It also shows that there is not a constant variation of the residuals.
The Q-Q shows that the residuals are not normally distributed but more like an upward parabola.
The Residuals vs leverage graph shows that Alaska is an influential outlier that is influencing the model.
Most of these assumptions does not hold for my model.
BLUE refers to the Best Linear Unbiased Estimator. When a model satisfies all of the assumptions, our coefficients estimated by OLS follow the best possible sampling distribution of unbiased estimates.