class: center, middle, inverse, title-slide # Time-series cross-section model ### Thierry Warin, PhD ### quantum simulations
*
--- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Navigation tips - Tile view: Just press O (the letter O for Overview) at any point in your slideshow and the tile view appears. Click on a slide to jump to the slide, or press O to exit tile view. - Draw: Click on the pen icon (top right of the slides) to start drawing. - Search: click on the loop icon (bottom left of the slides) to start searching. You can also click on h at any moments to have more navigations tips. --- class: inverse, center, middle # Outline --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% ### outline 1. Time-series cross-section model 2. Fixed effects --- class: inverse, center, middle # Time-series cross-section model --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Time-series cross-section model ```r mydata1 <- readr::read_csv("https://warin.ca/datalake/courses_data/qmibr/session5/panel_data_1.csv") head(mydata1,4) ``` ``` ## # A tibble: 4 x 45 ## obs name country year lngdppc3 va ps ge rq rl cc inv ## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 1 Albania 1 1989 6.76 NA NA NA NA NA NA 44.8 ## 2 2 Albania 1 1990 6.52 NA NA NA NA NA NA 49.8 ## 3 3 Albania 1 1991 6.01 NA NA NA NA NA NA 9.51 ## 4 4 Albania 1 1992 5.56 NA NA NA NA NA NA 7.44 ## # … with 33 more variables: gns <dbl>, lninfl <dbl>, govrev <dbl>, ## # govexp <dbl>, fb <dbl>, strfb <dbl>, netdebt <dbl>, grossdebt <dbl>, ## # cab <dbl>, ief <dbl>, property <dbl>, integrity <dbl>, taxburden <dbl>, ## # govspend <dbl>, busfreedom <dbl>, labfreedom <dbl>, monfreedom <dbl>, ## # tradefreedom <dbl>, invfreedom <dbl>, finfreedom <dbl>, dcr <dbl>, ## # emplpop <dbl>, schooling1 <dbl>, to <dbl>, fdinet <dbl>, secondenrol <dbl>, ## # tertenrol <dbl>, incomeind <dbl>, lfp <dbl>, schooling2 <dbl>, ## # oldagedep <dbl>, remittances <dbl>, gci <dbl> ``` --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Time-series cross-section model ```r library(plm) mydata_1_random <- plm(grossdebt ~ busfreedom + finfreedom + invfreedom, data = mydata1, index = c("country", "year"), model = "random") ``` --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Time-series cross-section model ```r summary(mydata_1_random) ``` .pull-left[ <img src="./images/regression2a.png" width="100%" style="display: block; margin: auto;" /> ] .pull-right[ <img src="./images/regression2b.png" width="100%" style="display: block; margin: auto;" /> ] --- class: inverse, center, middle # Fixed effects --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Fixed effects In terms of estimation techniques, we need to use time-series cross-section based techniques. First, we need to go through a couple of checkings. Among the first ones, we need to see whether we need a fixed-effects or a random-effects model. FE explore the relationship between predictor and outcome variables within an entity (country, person, company, etc.). Each entity has its own individual characteristics that may or may not influence the predictor variables (for example, being a male or female could influence the opinion toward certain issue; or the political system of a particular country could have some effect on trade or GDP; or the business practices of a company may influence its stock price). When using FE we assume that something within the individual may impact or bias the predictor or outcome variables and we need to control for this. This is the rationale behind the assumption of the correlation between entity’s error term and predictor variables. FE remove the effect of those time-invariant characteristics so we can assess the net effect of the independent variable on the outcome variable. --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Fixed effects Another important assumption of the FE model is that those time-invariant characteristics are unique to the individual and should not be correlated with other individual characteristics. Each entity is different therefore the entity’s error term and the constant (which captures individual characteristics) should not be correlated with the others. If the error terms are correlated, then FE is no suitable since inferences may not be correct and you need to model that relationship (probably using random-effects), this is the main rationale for the Hausman test. ```r # Running a panel data with fixed effects fixed <- plm(grossdebt ~ busfreedom + finfreedom + invfreedom, data = mydata1, index = c("country", "year"), model = "within") # Running a panel data with random effects random <- plm(grossdebt ~ busfreedom + finfreedom + invfreedom, data = mydata1, index = c("country", "year"), model = "random") ``` --- background-image: url(./images/qslogo.PNG) background-size: 100px background-position: 90% 8% # Fixed effects ```r # Running the Hausman test phtest(fixed, random) ``` ``` ## ## Hausman Test ## ## data: grossdebt ~ busfreedom + finfreedom + invfreedom ## chisq = 5.4333, df = 3, p-value = 0.1427 ## alternative hypothesis: one model is inconsistent ``` Considering the results of the Hausman test with a `\(p-value >0.05\)`, we need a random effects model.