Variable | Description |
---|---|
vturn | Voter turnout in election |
judrev | Judicial review (existence of an independent body which decides whether laws conform to the constitution). Coded 0 = no, 1 = yes. |
ud | Net union membership as a proportion wage and salary earners in employment (union density) |
unemp | Unemployment rate, percentage of civilian labour force. |
unemp_pmp | Cash expenditure for unemployment benefits as a percentage of GDP (public and mandatory private). |
realgdpgr | Growth of real GDP, percent change from previous year. |
debt | Gross general government debt (financial liabilities) as a percentage of GDP. |
socexp_t_pmp | Total public and mandatory private social expenditure as a percentage of GDP. |
Estimate a model for the electoral fractionalization of the party system as coded by the rae_ele
variable in the dataset using all the variables listed above.
Load all the necessary packages first.
library(foreign)
library(plm)
library(lmtest)
library(texreg)
library(dplyr)
Let's load the dataset:
cpds <- read.dta("CPDS_1960-2013_stata.dta")
The dataset has 291 variables, so we'll keep the ones we care about and drop the rest.
cpds <- select(cpds,
country,
year,
rae_ele,
vturn,
judrev,
ud,
unemp,
unemp_pmp,
realgdpgr,
debt,
socexp_t_pmp)
Now let's examine the dependent variable rae_ele
.
summary(cpds$rae_ele)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0.4915 0.6751 0.7436 0.7326 0.8076 0.9283 7
If we want to visualize the distribution of the rae_ele
, we can plot a histogram
hist(cpds$rae_ele,
xlab = "Electoral Fractionalization Index (rae_ele)",
main = "Electoral Fractionalization")
Let's run panel data regression with country fixed effects.
country_effects <- plm(rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp +
realgdpgr + debt + socexp_t_pmp,
data = cpds,
index = c("country", "year"),
model = "within",
effect = "individual")
summary(country_effects)
Oneway (individual) effect Within Model
Call:
plm(formula = rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp +
realgdpgr + debt + socexp_t_pmp, data = cpds, effect = "individual",
model = "within", index = c("country", "year"))
Unbalanced Panel: n=35, T=4-32, N=768
Residuals :
Min. 1st Qu. Median 3rd Qu. Max.
-0.12200 -0.01710 -0.00169 0.01650 0.12900
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
vturn -2.0891e-03 2.8088e-04 -7.4376 2.904e-13 ***
judrevJudicial review -3.9645e-02 1.2933e-02 -3.0655 0.002253 **
ud -7.5212e-04 2.8101e-04 -2.6765 0.007608 **
unemp 3.8075e-03 7.1698e-04 5.3105 1.456e-07 ***
unemp_pmp -5.8664e-03 3.3172e-03 -1.7685 0.077402 .
realgdpgr 4.3781e-05 4.6664e-04 0.0938 0.925277
debt -8.4289e-05 8.9307e-05 -0.9438 0.345579
socexp_t_pmp -2.0604e-03 7.5389e-04 -2.7330 0.006430 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 0.83227
Residual Sum of Squares: 0.7102
R-Squared: 0.14668
Adj. R-Squared: 0.13847
F-statistic: 15.5778 on 8 and 725 DF, p-value: < 2.22e-16
When controlling for country fixed effects, our model tells us that voter turnout, judicial review, labor union membership, unemployment, and total social expenditure are all statistically significant factors. But before we go any further, let's just verify the presence of country fixed effects using plmtest()
.
plmtest(country_effects, effect="individual")
Lagrange Multiplier Test - (Honda)
data: rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp + realgdpgr + ...
normal = 189.02, p-value < 2.2e-16
alternative hypothesis: significant effects
Since the p-value is less than 0.05
, we can continue with our analysis.
Let's look at our statistically significant variables and find out what their coefficients mean in relative terms. We'll start with judicial independenc or judrev
. Judicial review or judrev
is a factor variable coded as 1
for the existence of an independent body and 0
otherwise. We can calculate the relative effect of its coefficient as follows:
-3.9645e-02 / diff(range(cpds$rae_ele, na.rm = TRUE))
[1] -0.09077421
That tells us that there is a decline of 0.040
in electoral fractionalization index in countries with an independent judicial body which amounts to a decrease by 9.08%
.
We would like to know the relative effect of other coefficients as well. But instead of calculating them one by one we can simply calculate them all at once:
coefficients(country_effects) / diff(range(cpds$rae_ele, na.rm = TRUE))
vturn judrevJudicial review ud
-0.0047832999 -0.0907752600 -0.0017221059
unemp unemp_pmp realgdpgr
0.0087180116 -0.0134320501 0.0001002442
debt socexp_t_pmp
-0.0001929955 -0.0047175664
Now we can easily interpret the results for every statistically significant factor. Looking at the relative percentages, we can say that none of the other statistically significant factors are having a huge effect on our dependent variable.
For example, a one percent increase in voter turnout reduces electoral fractionalization by merely -0.002
, as does one percent increase in social spending. This amounts to a relative decline of about half a percent (0.48%
). Unemployment is the only factor with a statistically significant and positive correlation with our dependent variable. A one percent increase in unemployment increases electoral fractionalization by 0.004
, a relative increase of less than a percent (0.87%
).
None of the other factors (unemployment benefits, government debt and GDP growth) have any statistically significant effect on electoral fractionalization.
Now, let's run a time fixed effect model to estimate any effects that vary across time but are constant across countries.
time_effects <- plm(rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp +
realgdpgr + debt + socexp_t_pmp,
data = cpds,
index = c("country", "year"),
model = "within",
effect = "time")
plmtest(time_effects, effect="time")
Lagrange Multiplier Test - time effects (Honda)
data: rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp + realgdpgr + ...
normal = 3.3287, p-value = 0.0008727
alternative hypothesis: significant effects
Since plmtest()
tells us that the model with time fixed effects is statistically significant, we can proceed with our analysis.
summary(time_effects)
Oneway (time) effect Within Model
Call:
plm(formula = rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp +
realgdpgr + debt + socexp_t_pmp, data = cpds, effect = "time",
model = "within", index = c("country", "year"))
Unbalanced Panel: n=35, T=4-32, N=768
Residuals :
Min. 1st Qu. Median 3rd Qu. Max.
-0.21600 -0.04400 -0.00053 0.05480 0.19500
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
vturn -0.00035960 0.00025356 -1.4182 0.1565535
judrevJudicial review -0.02911525 0.00774309 -3.7602 0.0001834 ***
ud 0.00043130 0.00017305 2.4923 0.0129116 *
unemp 0.00110320 0.00093798 1.1761 0.2399207
unemp_pmp 0.01588536 0.00405292 3.9195 9.711e-05 ***
realgdpgr 0.00411686 0.00143653 2.8658 0.0042792 **
debt -0.00020220 0.00010232 -1.9761 0.0485241 *
socexp_t_pmp 0.00552104 0.00078057 7.0731 3.562e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 5.9337
Residual Sum of Squares: 4.5925
R-Squared: 0.22603
Adj. R-Squared: 0.21426
F-statistic: 26.5754 on 8 and 728 DF, p-value: < 2.22e-16
Before trying to interpret the results, let's put the effects of statistically significant coefficients in context.
coefficients(time_effects) / diff(range(cpds$rae_ele, na.rm = TRUE))
vturn judrevJudicial review ud
-0.0008233762 -0.0666644914 0.0009875313
unemp unemp_pmp realgdpgr
0.0025259692 0.0363723244 0.0094262695
debt socexp_t_pmp
-0.0004629617 0.0126413824
With fixed time effects, judicial review again is statistically significant, however its effect isn't nearly as large as it was in the country fixed effects model. In the time fixed effects model, countries with an independent judicial body experience a decline of 0.029
on the electoral fractionalization index which amounts to 6.67%
. government debt and unemployment benefits are both positively correlated with our dependent variable, although for marginal effect of government debt is negligible. An increase in one point in government debt as a percent of the GDP, has an estimated effect of increasing electoral fractionalization by one-twentieth of one percent (0.05%
). On the other hand, for each increase in unemployment benefits by one percent of the GDP, electoral fractionalization rises by 0.016
or an increase of 3.64%
.
Estimate a twoway model and compare to the previous country and time fixed effect models.
Let's run a twoway fixed effect model that controls for both country and time fixed effects.
twoway_effects <- plm(rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp +
realgdpgr + debt + socexp_t_pmp,
data = cpds,
index = c("country", "year"),
model = "within",
effect = "twoway")
summary(twoway_effects)
Twoways effects Within Model
Call:
plm(formula = rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp +
realgdpgr + debt + socexp_t_pmp, data = cpds, effect = "twoway",
model = "within", index = c("country", "year"))
Unbalanced Panel: n=35, T=4-32, N=768
Residuals :
Min. 1st Qu. Median 3rd Qu. Max.
-0.09810 -0.01770 -0.00108 0.01540 0.11200
Coefficients :
Estimate Std. Error t-value Pr(>|t|)
vturn -1.4588e-03 2.7207e-04 -5.3619 1.122e-07 ***
judrevJudicial review -5.6636e-02 1.2445e-02 -4.5509 6.307e-06 ***
ud -6.8797e-04 2.8491e-04 -2.4147 0.016007 *
unemp 3.5554e-03 6.8669e-04 5.1776 2.947e-07 ***
unemp_pmp 8.9455e-04 3.4704e-03 0.2578 0.796662
realgdpgr -1.4839e-03 5.7279e-04 -2.5906 0.009781 **
debt -2.4835e-04 8.4592e-05 -2.9358 0.003437 **
socexp_t_pmp -5.3631e-03 8.4541e-04 -6.3438 4.044e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 0.7043
Residual Sum of Squares: 0.5786
R-Squared: 0.17847
Adj. R-Squared: 0.16128
F-statistic: 18.8459 on 8 and 694 DF, p-value: < 2.22e-16
coefficients(twoway_effects) / diff(range(cpds$rae_ele, na.rm = TRUE))
vturn judrevJudicial review ud
-0.003340257 -0.129678436 -0.001575240
unemp unemp_pmp realgdpgr
0.008140687 0.002048229 -0.003397621
debt socexp_t_pmp
-0.000568639 -0.012279748
Judicial review once again is not only statistically significant but has a rather substantial effect on electoral fractionalization. Countries with an independent judicial body experience a decline of 0.057
. This effect amounts to a decline of 12.97%
. Voter turnout has a statistically significant negative effect on electoral fractionalization with a percentage inrease estimated to decrease electoral fractionalization by 0.001
or 0.33%
. Similarly, a rise in real GDP growth by one percent is estimated to decrease electoral fractionalization by 0.001
(0.34%
). When interpreting the effects of voter turnout and GDP growth it is important to keep in mind that a year-over-year increase of one percent in GDP growth is rather substantial, whereas it is not uncommon to see voter turnout fluctuating by several percentage points from one election to another.
A one percent increase in union membership has an estimated effect of decreasing our dependent variable by 0.001
(0.16%
), while a one percent increase in unemployment increases it by 0.004
or 0.81%
. Social expenditure also has a statistically significant effect with a one percent increase driving electoral fractionalization down by 0.005
or 1.23%
, which is still relatively small.
We can now compare the three models we've estimated side-by-side.
screenreg(list(country_effects, time_effects, twoway_effects),
custom.model.names = c("Country Fixed Effects",
"Time Fixed Effects",
"Twoway Fixed Effects"))
======================================================================================
Country Fixed Effects Time Fixed Effects Twoway Fixed Effects
--------------------------------------------------------------------------------------
vturn -0.00 *** -0.00 -0.00 ***
(0.00) (0.00) (0.00)
judrevJudicial review -0.04 ** -0.03 *** -0.06 ***
(0.01) (0.01) (0.01)
ud -0.00 ** 0.00 * -0.00 *
(0.00) (0.00) (0.00)
unemp 0.00 *** 0.00 0.00 ***
(0.00) (0.00) (0.00)
unemp_pmp -0.01 0.02 *** 0.00
(0.00) (0.00) (0.00)
realgdpgr 0.00 0.00 ** -0.00 **
(0.00) (0.00) (0.00)
debt -0.00 -0.00 * -0.00 **
(0.00) (0.00) (0.00)
socexp_t_pmp -0.00 ** 0.01 *** -0.01 ***
(0.00) (0.00) (0.00)
--------------------------------------------------------------------------------------
R^2 0.15 0.23 0.18
Adj. R^2 0.14 0.21 0.16
Num. obs. 768 768 768
======================================================================================
*** p < 0.001, ** p < 0.01, * p < 0.05
By comparing the models we can see that Judicial review is statistically significant in every model and is negatively correlated with electoral fractionalization. Real GDP growth and social spending are positively correlated in the time effects model but have a negative correlation in the twoway fixed effect model. A one point increase in GDP growth is estimated to increase electoral fractionalization by 0.004
(0.94%
) in the time fixed effect model and decrease it by 0.001
(0.34%
) in the twoway fixed effect model. Similarly, a one percent increase in social spending is estimated to increase electoral fractionalization by 0.006
(1.26%
) in the time fixed effect model and decrease it by 0.005
(1.23%
) in the twoway fixed effect model.
The effect of voter turnout in country fixed effect model is twice its effect in the twoway fixed effect model, and it is not statistically significant in the time fixed effects model. A one percent increase in voter turnout is estimated to decrease electoral fractionalization by 0.002
with country fixed effects, compared to 0.001
in the towway fixed effects model.
Unemployment effects in a country fixed effects model are similar to the effects in twoway fixed effect models and they are not statistically significant in model where we only control for time fixed effects. When unemployment increases by 1 percent it has an estimated effect of an increase of 0.004
in our dependent variable in both country fixed effects and twoway effects models, which amounts to a percentage increase of just under 1 percent.
Test for serial correlation and cross sectional dependence in the twoway model.
We can test serial correlation with the Breusch-Godfrey test to see if there is any temporal dependence in our model.
pbgtest(twoway_effects)
Breusch-Godfrey/Wooldridge test for serial correlation in panel
models
data: rae_ele ~ vturn + judrev + ud + unemp + unemp_pmp + realgdpgr + debt + socexp_t_pmp
chisq = 311.87, df = 4, p-value < 2.2e-16
alternative hypothesis: serial correlation in idiosyncratic errors
The Breusch-Godfrey test tells us that our model does indeed suffer from autocorrelated standard errors.
Next, we run the Pesaran cross-sectional dependence test to check for spatial dependence in our model.
pcdtest(twoway_effects)
Pesaran CD test for cross-sectional dependence in panels
data: formula
z = -3.8849, p-value = 0.0001024
alternative hypothesis: cross-sectional dependence
The Pesaran CD test confirms the presence of cross-sectional dependence in our model.
If either serial correlation or cross sectional dependence is present, use the methods discussed in the seminar to obtain heteroskedastic and autocorrelation consistent standard errors.
From the Breusch-Godfrey test we know that we have serial correlation in the error term of our model so we need to adjust the standard errors. We can use the "allerano"
method to obtain heteroskedasticity and autocorrelation (HAC) consistent standard errors. We first obtain a HAC robust covariance matrix from vcovHC()
by specifying method = "arellano"
and pass it along to coeftest()
for adjusting the standard errors.
twoway_hac <- coeftest(twoway_effects,
vcov = vcovHC(twoway_effects,
method = "arellano",
type = "HC3"))
twoway_hac
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
vturn -0.00145883 0.00067683 -2.1554 0.0314745 *
judrevJudicial review -0.05663615 0.04175377 -1.3564 0.1754028
ud -0.00068797 0.00078204 -0.8797 0.3793147
unemp 0.00355539 0.00114190 3.1136 0.0019244 **
unemp_pmp 0.00089455 0.00753789 0.1187 0.9055681
realgdpgr -0.00148389 0.00053781 -2.7591 0.0059485 **
debt -0.00024835 0.00014049 -1.7678 0.0775399 .
socexp_t_pmp -0.00536309 0.00150857 -3.5551 0.0004035 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Since the Pesaran CD test told us that we have cross-sectional dependence in our model, we need to adjust for spatial dependence as well. Fortunately, the Driscoll and Kraay's (1998) SCC method gives us heteroskedasticity and autocorrelation consistent errors that are also robust to cross-sectional dependence.
twoway_scc <- coeftest(twoway_effects,
vcov = vcovSCC(twoway_effects,
type="HC3",
cluster = "group"))
twoway_scc
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
vturn -0.00145883 0.00052318 -2.7884 0.005442 **
judrevJudicial review -0.05663615 0.04165998 -1.3595 0.174434
ud -0.00068797 0.00081061 -0.8487 0.396332
unemp 0.00355539 0.00112006 3.1743 0.001568 **
unemp_pmp 0.00089455 0.00667793 0.1340 0.893476
realgdpgr -0.00148389 0.00045927 -3.2310 0.001292 **
debt -0.00024835 0.00012329 -2.0143 0.044361 *
socexp_t_pmp -0.00536309 0.00107777 -4.9761 8.191e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Compare the HAC and spatially robust standard errors with the twoway model estimated earlier.
The twoway fixed effect model with heteroskedastic and autocorrelation consistent (HAC) standard errors and with SCC corrected standard errors are presented in a side-by-side comparison below.
screenreg(list(twoway_effects, twoway_hac, twoway_scc),
custom.model.names = c("Twoway", "Twoway (HAC)", "Twoway (SCC)"))
=============================================================
Twoway Twoway (HAC) Twoway (SCC)
-------------------------------------------------------------
vturn -0.00 *** -0.00 * -0.00 **
(0.00) (0.00) (0.00)
judrevJudicial review -0.06 *** -0.06 -0.06
(0.01) (0.04) (0.04)
ud -0.00 * -0.00 -0.00
(0.00) (0.00) (0.00)
unemp 0.00 *** 0.00 ** 0.00 **
(0.00) (0.00) (0.00)
unemp_pmp 0.00 0.00 0.00
(0.00) (0.01) (0.01)
realgdpgr -0.00 ** -0.00 ** -0.00 **
(0.00) (0.00) (0.00)
debt -0.00 ** -0.00 -0.00 *
(0.00) (0.00) (0.00)
socexp_t_pmp -0.01 *** -0.01 *** -0.01 ***
(0.00) (0.00) (0.00)
-------------------------------------------------------------
R^2 0.18
Adj. R^2 0.16
Num. obs. 768
=============================================================
*** p < 0.001, ** p < 0.01, * p < 0.05
The "Twoway" model suffers from heteroskedasticity, autocorrelation and cross-sectional dependence while the "Twoway (HAC)" model suffers only from cross-sectional dependence. The "Twoway (SCC)" model corrects for heteroskedastic and autocorrelation consistent (HAC) standard errors that are also robust to cross-sectional dependence and is the correct model out of the three models we compared above.
Display the results in publication-ready tables and discuss the substantively significant findings.
We'll present all the models of interest in a publication-ready table using screenreg()
.
screenreg(list(country_effects, twoway_effects, twoway_hac, twoway_scc),
custom.model.names = c("Country Effects",
"Twoway Effects",
"Twoway (HAC)",
"Twoway (SCC)"))
==================================================================================
Country Effects Twoway Effects Twoway (HAC) Twoway (SCC)
----------------------------------------------------------------------------------
vturn -0.00 *** -0.00 *** -0.00 * -0.00 **
(0.00) (0.00) (0.00) (0.00)
judrevJudicial review -0.04 ** -0.06 *** -0.06 -0.06
(0.01) (0.01) (0.04) (0.04)
ud -0.00 ** -0.00 * -0.00 -0.00
(0.00) (0.00) (0.00) (0.00)
unemp 0.00 *** 0.00 *** 0.00 ** 0.00 **
(0.00) (0.00) (0.00) (0.00)
unemp_pmp -0.01 0.00 0.00 0.00
(0.00) (0.00) (0.01) (0.01)
realgdpgr 0.00 -0.00 ** -0.00 ** -0.00 **
(0.00) (0.00) (0.00) (0.00)
debt -0.00 -0.00 ** -0.00 -0.00 *
(0.00) (0.00) (0.00) (0.00)
socexp_t_pmp -0.00 ** -0.01 *** -0.01 *** -0.01 ***
(0.00) (0.00) (0.00) (0.00)
----------------------------------------------------------------------------------
R^2 0.15 0.18
Adj. R^2 0.14 0.16
Num. obs. 768 768
==================================================================================
*** p < 0.001, ** p < 0.01, * p < 0.05
NOTE: In the screenreg()
output, the coefficients are rounded to 2 decimal places by default thus making it seem as if many of them were zero. You can change the number of decimal places displayed, but it is more important to understand that even small coefficients don't necessarily mean that their effects are small and certainly does not mean that the variable is not statistically significant. When interpreting your results, always keep in mind the scale and range of your independent and dependent variables.
The country effects model was the first model we estimated. However, since our data has time fixed effects as well, we estimated a twoway fixed effects model that controls for both country and time fixed effects. After correcting for heteroskedasticity and temporal and spatial correlation, our final model was the "Twoway (SCC)".
twoway_scc
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
vturn -0.00145883 0.00052318 -2.7884 0.005442 **
judrevJudicial review -0.05663615 0.04165998 -1.3595 0.174434
ud -0.00068797 0.00081061 -0.8487 0.396332
unemp 0.00355539 0.00112006 3.1743 0.001568 **
unemp_pmp 0.00089455 0.00667793 0.1340 0.893476
realgdpgr -0.00148389 0.00045927 -3.2310 0.001292 **
debt -0.00024835 0.00012329 -2.0143 0.044361 *
socexp_t_pmp -0.00536309 0.00107777 -4.9761 8.191e-07 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Since twoway_scc is not a model object but just a matrix of coefficients that we obtained from coeftest()
, we cannot use the coefficients()
function here. Instead we can simply extract the coefficients from the first column of the matrix to get the relative effects of each variable.
twoway_scc[,1] / diff(range(cpds$rae_ele, na.rm = TRUE))
vturn judrevJudicial review ud
-0.003340257 -0.129678436 -0.001575240
unemp unemp_pmp realgdpgr
0.008140687 0.002048229 -0.003397621
debt socexp_t_pmp
-0.000568639 -0.012279748
In the "Twoway (SCC)" model, voter turnout, unemployment, GDP growth, government debt and social expenditure are all statistically significant. A one percent increase in voter turnout is estimated to decrease electoral fractionalization by one-third of a percent (0.33%
) and so is one percent increase in GDP growth. Unemployment rate is the only variable with a positive effect where one percent increase has the estimated effect of increasing electoral fractionalization by 0.81%
. A one percent increase in government debt has a negative effect of 0.06%
on electoral fractionalization. Finally, social expenditure is estimated to decrease electoral fractionalization by 0.005
(1.23%
) in the twoway SCC model.
The remaining factors, namely, judicial review, union membership, and unemployment benefits do not have a statistically significant effect on electoral fractionalization.