Assignment3EC

docx

School

University of Southern California *

*We aren’t endorsed by this school

Course

MISC

Subject

Economics

Date

Feb 20, 2024

Type

docx

Pages

11

Uploaded by imanmobeen

Report
Assignment 3 ######Question A What kind of data is this? This data is panel data. It consists of observations that are on the same N entities at two or more different time periods. For the most part, this data seems balanced. However, at GDP there are some missing data points meaning it could be an unbalanced panel. ## Set Working Directory and Import Data setwd("~/Desktop/323") install.packages("readr") library(readr) data <- read.csv("a3dataset.csv") View(data) ######Question B ## Calc Summary Notes library(psych) psych::describeBy(data, na.rm = TRUE, group = data$Province, skew = FALSE, ranges = TRUE)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
#Graphing coplot(Population ~ Year|Province, type = "l", data = data, xlab = c("Year", "Province"), ylab = "Population", rows = 1) coplot(GDP ~ Year|Province, type = "l", data = data, xlab = c("Year", "Province"), ylab = "GDP", rows = 1) coplot(Crime ~ Year|Province, type = "l", data = data, xlab = c("Year", "Province"), ylab = "Crime", rows = 1)
library(car) scatterplot(Crime ~ Year|Province, boxplots = FALSE, smooth = TRUE, regLine = TRUE, data = data, xlab = "Year", ylab = "Crime") #####Question C+D #Should we allow for time trend? Why or why not? No, we should not allow for time trends because if the study period is short then including a time trend is not relevant, as Crime does have a trend the time period is rather short. Population and GDP do not have a clear time trend. #Should we control for seasonality?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
We should not control for seasonality because the data is yearly. Seasonality usually refers to patterns that occur within a year such as temperature changes or holiday seasons but with yearly data these patterns may be captured in the overall annual trend. This data is also less than 10 years. Yearly data is aggregated at the annual level, and it could not exhibit the same level of seasonality as more frequent data. #####Question E data$gdppc <- data$GDP/data$Population library(plm) #Perform Pooled OLS Reg library(plm) ols <- plm(Crime ~ gdppc, data = data, model= "pooling") summary(ols) #Perform First Diff Reg fdreg <- plm(Crime~gdppc, data=data, model = "fd", effect = "individual", index = c("Province")) summary(fdreg)
#Perform Fixed Effects Reg fereg <- plm(Crime~gdppc, data=data, model = "within", effect = "individual", index = c("Province")) summary(fereg)
#Perform a FE estimator reg with Year FE data$Y2014 <- ifelse(data$Year==2014, 1,0) data$Y2015 <- ifelse(data$Year==2015, 1,0) data$Y2016 <- ifelse(data$Year==2016, 1,0) data$Y2017 <- ifelse(data$Year==2017, 1,0) data$Y2018 <- ifelse(data$Year==2018, 1,0) data$Y2019 <- ifelse(data$Year==2019, 1,0) data$Y2020 <- ifelse(data$Year==2020, 1,0) data$Y2021 <- ifelse(data$Year==2021, 1,0) data$Y2022 <- ifelse(data$Year==2022, 1,0) # 2014 as base year feyreg <- plm(Crime~gdppc+Y2015+Y2016+Y2017+Y2018+Y2019+Y2020+Y2021+Y2022, data=data, model = "within", effect = "individual", index = c("Province")) summary(feyreg)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
# Perform RE Reg rereg <- plm(Crime~gdppc+Y2015+Y2016+Y2017+Y2018+Y2019+Y2020+Y2021+Y2022, data=data, model = "random", effect = "individual", index = c("Province")) summary(rereg)
Overall, the best model to use would be fixed effects after estimating the models.