As commentor suggest any form of subsetting would do. Here is a tidyverse
-way where you filter inside the plm
regression.
library(plm)
library(tidyverse)
library(stargazer)
model_plm_all <- plm(pcap ~ unemp + water + util + pc + gsp,
data=Produc,
effect = "individual", model = "within",
index=c("state", "year"))
model_plm_region5 <- plm(pcap ~ unemp + water + util + pc + gsp,
data=Produc %>%filter(region == 5),
effect = "individual", model = "within",
index=c("state", "year"))
model_plm_region6 <- plm(pcap ~ unemp + water + util + pc + gsp,
data=Produc %>%filter(region == 6),
effect = "individual", model = "within",
index=c("state", "year"))
stargazer(model_plm_all, model_plm_region5, model_plm_region6, type="text",
column.labels = c("All", "Region 5", "Region 6"), model.numbers = FALSE)
==========================================================================================
Dependent variable:
-----------------------------------------------------------------------------
pcap
All Region 5 Region 6
------------------------------------------------------------------------------------------
unemp 92.486*** 94.759*** 4.667
(11.648) (23.912) (27.650)
water 0.759*** 1.110*** 0.637**
(0.040) (0.155) (0.284)
util 1.316*** 1.193*** 0.730***
(0.017) (0.066) (0.149)
pc 0.006 0.039** 0.127***
(0.004) (0.017) (0.030)
gsp 0.006 0.001 -0.022
(0.004) (0.015) (0.029)
------------------------------------------------------------------------------------------
Observations 816 136 68
R2 0.970 0.984 0.960
Adjusted R2 0.968 0.982 0.954
F Statistic 4,899.365*** (df = 5; 763) 1,511.193*** (df = 5; 123) 280.529*** (df = 5; 59)
==========================================================================================
Note: *p<0.1; **p<0.05; ***p<0.01