410 likes | 420 Views
Learn to create and properly analyze panel regression models and select the most appropriate ones using the plm package in R. Gain awareness and skills through lecture, slides, code, and datasets provided. Follow along with R or R Studio. Includes exercises and data from SNAP benefits, civilian population estimates, and food store employment data.
E N D
PANEL REGRESSION (T≥2)(plm package) By Mike Jadoo
Purpose • Bring about an awareness • Enable individuals to properly create analysis • Select the most appropriate model(s).
Special Thank you MLK library Digital commons lab
Lecture Structure • Slides, code, datasets are in the groups Meetup files section
Lecture Structure • Using R i386 3.2.3 or R studio • Can follow lecture and code or code after • There will be some web exercises
Data series • SNAP benefits data from USDA • Civilian population estimates from Census • Food store employment data from BEA
Orientation(TYPES OF DATA) • Cross-sectional datasets- observing many subjects at one point in time (i.e. OLS model) • Pooled Cross Sectional-multiple variables over two periods of time • Time series- one variable over multiple periods of time • Panel data- multiple variables over multiple periods of time
Orientation(Terminology Clarification) Longitudinal data • Pooled Cross sectional • Time series • Panel Data
History of Panel Data Regression • Sir George Biddell Airy's 1861 analysis of astronomical data • R. A. Fisher 1925 explained more fully the concepts and methods of both fixed-effects and random effects • First Paris Conference 1977 experts started to convene and share ideas Sir George Airy R.A. Fisher
Why use panel regression model? • Gives more observations to analyze • More complicated characteristics and behavioral hypothesis can be tested • Better analysis of the nature of unobserved errors and individual [idiosyncratic] errors
Statistical Modeling Review topics theory or use past experience Formulate a initial model Find the data Check the data Estimate the model Reformulate the model Check the Parameter estimates Interpret your results
Statistical modeling process review • Create the hypothesis - What are you trying to analyze or predict • Go over the topics relative theory -May involve extensive reading but it is the good first start!!
Finding the data sources Government sources are the good first start!! Can’t find the data your looking for? Staff is there to help. There are more providers of data, some have a cost.
Methodology • Review the data series methodology (document that tells you how the data is made), is this acceptable?
Panel Regression • Pooled (OLS) • Fixed effects • Random effects • First Differencing
Models Assumptions Fixed Effects 1. The model has parameter estimates and unobserved effect ai. 2. Data comes from cross sectional random sample 3. X variables changes over time, no prefect linear relationships exists among X’s 4. For each period, the expected value of the idiosyncratic errors given all X’s and the ai is 0 5. Variance for the idiosyncratic error terms and the ai is constant 6. The idiosyncratic errors are uncorrelated 7. The idiosyncratic errors are independent and normally distributed
Models Assumptions Random Effects 1. The model has parameter estimates and there is an ai. 2. Data comes from cross sectional random sample 3. No prefect linear relationships exists among X’s 4. For each period, the expected value of the idiosyncratic errors given all X’s and the ai is 0. Also, the expected value of ai for each parameter equals the constant term 5. Variance for the idiosyncratic error terms given all X’s and the ai is constant. Also, the variance of aiis constant given all X’s 6. The idiosyncratic errors are uncorrelated
Fixed vs Random Effects • Fixed effects: assuming that the individual effects are correlated with the other X’s; study the causes of changes within a person [or entity] • Random effects: assuming that the individual effects are uncorrelated with the other X’s
Demonstration • Hypothesis “Does food stamp benefits effect grocery store employment? if so, by how much?” • Data FOODEMPLY: Food store employment: BEA SNAPP: average annual participation in SNAP SNAPB: SNAP benefits distributed in thousands of dollars CIVPOP: estimated civilian population STATE: state identifier for all 50 states, YRS: time variable years from 2008 to 2012
Creating the Model • Create scatter plot, histogram
Creating the Model • Examine the data • Create the summary statistics
Test the series for normality JB Test
Checking for Prefect Collinearity Correlation box of all variables x <- newdata[3:6] y <- newdata[3:6] cor(x, y) LSNAPP LSNAPB LFoodEmply LCivPop LSNAPP 1.0000000 0.9924108 0.9028983 0.9497298 LSNAPB 0.9924108 1.0000000 0.8857668 0.9315922 LFoodEmply 0.9028983 0.8857668 1.0000000 0.9756423 LCivPop 0.9497298 0.9315922 0.9756423 1.0000000 • Correlation box of just explanatory variables newdata$LFoodEmply <-NULL x <- newdata[3:5] y <- newdata[3:5] cor(x, y) LSNAPP LSNAPB LCivPop LSNAPP 1.0000000 0.9924108 0.9497298 LSNAPB 0.9924108 1.0000000 0.9315922 LCivPop 0.9497298 0.9315922 1.0000000
Panel Regression • Set the panel regression
Panel Regression • Create and save the results for the different types of panel models, use the LM test to find best one. #Pooled OLS estimator: ols<-plm(LFoodEmply~LSNAPP+LSNAPB+LCivPop,data=newdata, index=c("id","t"),model='pooling') #first difference; firstdiff<-plm(LFoodEmply~LSNAPP+LSNAPB+LCivPop,data=newdata, index=c("id","t"),model='fd') #fixed effects(within): fixed<-plm(LFoodEmply~LSNAPP+LSNAPB+LCivPop,data=newdata, index=c("id","t"),model='within') # Random effects: random<-plm(LFoodEmply~LSNAPP+LSNAPB+LCivPop,data=newdata, index=c("id","t"),model='random‘)
Panel Regression • To determine Fixed vs Random effects use the Hausman Test # Hausman test for fixed versus random effects model phtest(random, fixed) Ho: random effect model is appropriate Ha: fixed effect model is appropriate Hausman Test data: LFoodEmply ~ LSNAPP + LSNAPB + LCivPop chisq = 23.125, df = 3, p-value = 3.803e-05 alternative hypothesis: one model is inconsistent
Test your model • If your panel data has a long time period then: • Check for serial correlation pbgtest(fixed) • Check for cross-sectional dependence (Baltagi) pcdtest()
Statistics of Fit • R2 and Adjusted R2 (some say R2 doesn’t matter) • Residual Sum of Squares or Mean Squared Errors • F-statistics: p< 0.05 • Parameter estimates
Interpretation of model • How you say it counts!! • Logs • Levels • Levels to log dependant variable Random effects: when the average effect of X changes across time and between states by one unit, this causes _______ change in Y. Fixed effects: Y changes _____ much overtime, on average per state, when X increases by one unit
Report findings Stargazer: collects the essential parameter estimates in a nice format
Summary • Orientation • History • Statistical model process • Data sources • Data Structure of panel data model • Panel data model in R • Interpretation of models parameter estimates • Reporting
Special Thanks Ani Katchova- Econometric Academy Sayed Hossain: Hossain Academy