All installed packages were loaded to be used in the R Program.
library(plm)
library(knitr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.1 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::between() masks plm::between()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks plm::lag(), stats::lag()
## ✖ dplyr::lead() masks plm::lead()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lubridate)
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
test.dat <- load("Ozone_Drought_Final.RData")
test.dat <- combinedAir.final
regions <- read.csv("region_code.csv")
test.dat$State.Code <- as.numeric(test.dat$State.Code)
test.dat$USDM.categorical <- factor(test.dat$USDM.categorical, levels = c("NoDrought", "ModerateDrought", "SevereDrought"))
test.dat$USDM.categorical <- relevel(test.dat$USDM.categorical, ref = "NoDrought")
test.dat$month = as.numeric(test.dat$month)
test.dat1 <- test.dat %>%
merge(regions, by = "State.Code")
md_reg<- lm(Max.Ozone ~ USDM.categorical, data = test.dat1)
stargazer(md_reg, type = "text", title = "All Regions", align = TRUE)
##
## All Regions
## ===============================================================
## Dependent variable:
## -------------------------------
## Max.Ozone
## ---------------------------------------------------------------
## USDM.categoricalModerateDrought 2.497***
## (0.014)
##
## USDM.categoricalSevereDrought 4.458***
## (0.020)
##
## Constant 41.529***
## (0.007)
##
## ---------------------------------------------------------------
## Observations 6,589,427
## R2 0.011
## Adjusted R2 0.011
## Residual Std. Error 14.482 (df = 6589424)
## F Statistic 36,076.910*** (df = 2; 6589424)
## ===============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
ne <- test.dat1 %>%
filter(noaa_region == "northeast")
ne_reg <- lm(Max.Ozone ~ USDM.categorical,
data = ne)
stargazer(ne_reg, type = "text", title = "Northeast", align = TRUE)
##
## Northeast
## ===========================================================
## Dependent variable:
## ---------------------------
## Max.Ozone
## -----------------------------------------------------------
## USDM.categoricalModerateDrought 0.419***
## (0.051)
##
## USDM.categoricalSevereDrought -1.430***
## (0.166)
##
## Constant 40.274***
## (0.016)
##
## -----------------------------------------------------------
## Observations 960,225
## R2 0.0002
## Adjusted R2 0.0001
## Residual Std. Error 14.654 (df = 960222)
## F Statistic 72.887*** (df = 2; 960222)
## ===========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
nr <- test.dat1 %>%
filter(noaa_region == "northern_rockies")
nr_reg <- lm(Max.Ozone ~ USDM.categorical,
data = nr)
stargazer(ne_reg, type = "text", title = "Northern Rockies", align = TRUE)
##
## Northern Rockies
## ===========================================================
## Dependent variable:
## ---------------------------
## Max.Ozone
## -----------------------------------------------------------
## USDM.categoricalModerateDrought 0.419***
## (0.051)
##
## USDM.categoricalSevereDrought -1.430***
## (0.166)
##
## Constant 40.274***
## (0.016)
##
## -----------------------------------------------------------
## Observations 960,225
## R2 0.0002
## Adjusted R2 0.0001
## Residual Std. Error 14.654 (df = 960222)
## F Statistic 72.887*** (df = 2; 960222)
## ===========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
nw <- test.dat1 %>%
filter(noaa_region == "northwest")
nw_reg <- lm(Max.Ozone ~ USDM.categorical,
data = nw)
stargazer(nw_reg, type = "text", title = "Northwest", align = TRUE)
##
## Northwest
## =============================================================
## Dependent variable:
## -----------------------------
## Max.Ozone
## -------------------------------------------------------------
## USDM.categoricalModerateDrought 3.534***
## (0.089)
##
## USDM.categoricalSevereDrought 6.177***
## (0.201)
##
## Constant 35.588***
## (0.045)
##
## -------------------------------------------------------------
## Observations 105,338
## R2 0.021
## Adjusted R2 0.021
## Residual Std. Error 12.445 (df = 105335)
## F Statistic 1,132.407*** (df = 2; 105335)
## =============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
ohv <- test.dat1 %>%
filter(noaa_region == "ohio_valley")
ohv_reg <- lm(Max.Ozone ~ USDM.categorical,
data = ohv)
stargazer(ohv_reg, type = "text", title = "Ohio Valley", align = TRUE)
##
## Ohio Valley
## ==============================================================
## Dependent variable:
## ------------------------------
## Max.Ozone
## --------------------------------------------------------------
## USDM.categoricalModerateDrought 1.974***
## (0.046)
##
## USDM.categoricalSevereDrought 3.933***
## (0.108)
##
## Constant 43.448***
## (0.016)
##
## --------------------------------------------------------------
## Observations 1,006,480
## R2 0.003
## Adjusted R2 0.003
## Residual Std. Error 14.543 (df = 1006477)
## F Statistic 1,505.052*** (df = 2; 1006477)
## ==============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
sth <- test.dat1 %>%
filter(noaa_region == "south")
sth_reg <- lm(Max.Ozone ~ USDM.categorical,
data = sth)
stargazer(sth_reg, type = "text", title = "South", align = TRUE)
##
## South
## =============================================================
## Dependent variable:
## -----------------------------
## Max.Ozone
## -------------------------------------------------------------
## USDM.categoricalModerateDrought 1.457***
## (0.035)
##
## USDM.categoricalSevereDrought 2.852***
## (0.052)
##
## Constant 39.513***
## (0.018)
##
## -------------------------------------------------------------
## Observations 951,486
## R2 0.004
## Adjusted R2 0.004
## Residual Std. Error 14.384 (df = 951483)
## F Statistic 2,017.385*** (df = 2; 951483)
## =============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
se <- test.dat1 %>%
filter(noaa_region == "southeast")
se_reg <- lm(Max.Ozone ~ USDM.categorical,
data = se)
stargazer(se_reg, type = "text", title = "Southeast", align = TRUE)
##
## Southeast
## ==============================================================
## Dependent variable:
## ------------------------------
## Max.Ozone
## --------------------------------------------------------------
## USDM.categoricalModerateDrought 3.979***
## (0.035)
##
## USDM.categoricalSevereDrought 5.774***
## (0.052)
##
## Constant 41.123***
## (0.016)
##
## --------------------------------------------------------------
## Observations 982,391
## R2 0.022
## Adjusted R2 0.022
## Residual Std. Error 13.686 (df = 982388)
## F Statistic 11,008.180*** (df = 2; 982388)
## ==============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
sw <- test.dat1 %>%
filter(noaa_region == "southwest")
sw_reg <- lm(Max.Ozone ~ USDM.categorical,
data = sw)
stargazer(sw_reg, type = "text", title = "Southwest", align = TRUE)
##
## Southwest
## =============================================================
## Dependent variable:
## -----------------------------
## Max.Ozone
## -------------------------------------------------------------
## USDM.categoricalModerateDrought -0.072**
## (0.033)
##
## USDM.categoricalSevereDrought 4.012***
## (0.042)
##
## Constant 46.398***
## (0.024)
##
## -------------------------------------------------------------
## Observations 683,530
## R2 0.016
## Adjusted R2 0.016
## Residual Std. Error 12.389 (df = 683527)
## F Statistic 5,608.052*** (df = 2; 683527)
## =============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
uw <- test.dat1 %>%
filter(noaa_region == "upper_midwest")
uw_reg <- lm(Max.Ozone ~ USDM.categorical,
data = uw)
stargazer(uw_reg, type = "text", title = "Upper Midwest", align = TRUE)
##
## Upper Midwest
## ===========================================================
## Dependent variable:
## ---------------------------
## Max.Ozone
## -----------------------------------------------------------
## USDM.categoricalModerateDrought -0.745***
## (0.063)
##
## USDM.categoricalSevereDrought -1.035***
## (0.212)
##
## Constant 41.718***
## (0.023)
##
## -----------------------------------------------------------
## Observations 382,355
## R2 0.0004
## Adjusted R2 0.0004
## Residual Std. Error 13.058 (df = 382352)
## F Statistic 79.860*** (df = 2; 382352)
## ===========================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
wst <- test.dat1 %>%
filter(noaa_region == "west")
wst_reg <- lm(Max.Ozone ~ USDM.categorical,
data = wst)
stargazer(wst_reg, type = "text", title = "West", align = TRUE)
##
## West
## ==============================================================
## Dependent variable:
## ------------------------------
## Max.Ozone
## --------------------------------------------------------------
## USDM.categoricalModerateDrought 3.049***
## (0.032)
##
## USDM.categoricalSevereDrought 3.319***
## (0.038)
##
## Constant 41.862***
## (0.021)
##
## --------------------------------------------------------------
## Observations 1,290,716
## R2 0.009
## Adjusted R2 0.009
## Residual Std. Error 16.293 (df = 1290713)
## F Statistic 5,980.247*** (df = 2; 1290713)
## ==============================================================
## Note: *p<0.1; **p<0.05; ***p<0.01