すでに推定した Males データを使った結婚の賃金を高める効果の固定効果モデルを、ランダム効果モデルでも推定し、固定効果モデルと係数に違いがあるか、ハウスマン検定で検討しなさい。また、ハイブリッド・モデルで時定変数もモデルに投入して分析しなさい。
Males データを使って結婚の効果を推定した固定効果モデルは以下のようなものであった。
library(plm)
data(Males)
names(Males) # 変数名を確認
## [1] "nr" "year" "school" "exper" "union" "ethn" "married"
## [8] "health" "wage" "industry" "occupation" "residence"
levels(Males$occupation) <- c("Professionals", "Managers", "Sales", "Clerks", "Craftsmen", "Operatives", "Laborers", "Farm", "Service")
Males$marriage <- as.numeric(Males$married == "yes")
Males$union2 <- as.numeric(Males$union=="yes")
Males$health2 <- as.numeric(Males$health=="yes")
# 職業のダミー変数をループを回して8個作る
for(i in 1:8){
var1 <- Males$occupation==levels(Males$occupation)[i+1] # Males$occupationの値が levels(Ma..) の i+1 番目の値と同じかどうか
var1 <- as.numeric(var1)
Males <- cbind(Males, var1)
}
colnames(Males)[(ncol(Males) - 7) : ncol(Males)] <- levels(Males$occupation)[-1]
head(Males)[(ncol(Males) - 7) : ncol(Males)]
## Managers Sales Clerks Craftsmen Operatives Laborers Farm Service
## 1 0 0 0 0 0 0 0 1
## 2 0 0 0 0 0 0 0 1
## 3 0 0 0 0 0 0 0 1
## 4 0 0 0 0 0 0 0 1
## 5 0 0 0 1 0 0 0 0
## 6 1 0 0 0 0 0 0 0
xtabs(~occupation + Managers, Males)
## Managers
## occupation 0 1
## Professionals 453 0
## Managers 0 399
## Sales 233 0
## Clerks 486 0
## Craftsmen 934 0
## Operatives 881 0
## Laborers 401 0
## Farm 64 0
## Service 509 0
d0 <- pdata.frame(Males[, c(-10, -12)]) # 使わない変数を削除
fixed1 <- plm(wage ~ married + exper + I(exper^2) + union + health + occupation, data=d0, model="within")
上のモデルと同じ独立変数を指定したランダム効果モデル、そして学歴と人種の主効果を投入したハイブリッド・モデルを推定し、その結果をハウスマン検定を使って固定効果モデルの結果と比較したのが、以下である。
random1 <- update(fixed1, model="random")
hybrd1 <- update(random1, ~ Within(marriage) + Within(exper) + Within(I(exper^2)) + Within(union2) + Within(health2) + Within(Managers) + Within(Sales) + Within(Clerks) + Within(Craftsmen) + Within(Operatives) + Within(Laborers) + Within(Farm) + Within(Service) + ethn + school )
library(texreg)
screenreg(list(fixed1, random1, hybrd1), # 以下は表をきれいに整理するためのオプション
custom.model.names = c("Fixed", "Random", "Hybrid"),
custom.coef.names=c(rep(NA, 14), "marriedyes", "exper", "I(exper^2)",
"unionyes", "healthyes", "occupationManagers",
"occupationSales", "occupationClerks",
"occupationCraftsmen" , "occupationOperatives",
"occupationLaborers", "occupationFarm",
"occupationService", rep(NA, 3)),
reorder.coef=c(14, 1:13, 15:17),
digits = 3)
##
## ==============================================================
## Fixed Random Hybrid
## --------------------------------------------------------------
## (Intercept) 1.181 *** 0.752 ***
## (0.038) (0.111)
## marriedyes 0.045 * 0.075 *** 0.045 *
## (0.018) (0.017) (0.018)
## exper 0.115 *** 0.112 *** 0.115 ***
## (0.009) (0.008) (0.009)
## I(exper^2) -0.004 *** -0.005 *** -0.004 ***
## (0.001) (0.001) (0.001)
## unionyes 0.083 *** 0.112 *** 0.083 ***
## (0.019) (0.018) (0.019)
## healthyes -0.011 -0.016 -0.011
## (0.047) (0.047) (0.047)
## occupationManagers -0.012 -0.032 -0.012
## (0.032) (0.031) (0.032)
## occupationSales -0.061 -0.081 * -0.061
## (0.038) (0.037) (0.038)
## occupationClerks -0.080 ** -0.121 *** -0.080 **
## (0.031) (0.030) (0.031)
## occupationCraftsmen -0.029 -0.083 ** -0.029
## (0.030) (0.029) (0.030)
## occupationOperatives -0.028 -0.101 *** -0.028
## (0.031) (0.029) (0.031)
## occupationLaborers -0.039 -0.123 *** -0.039
## (0.034) (0.032) (0.034)
## occupationFarm -0.058 -0.203 ** -0.058
## (0.066) (0.063) (0.066)
## occupationService -0.045 -0.147 *** -0.045
## (0.034) (0.032) (0.034)
## ethnblack -0.123 *
## (0.050)
## ethnhisp 0.025
## (0.045)
## school 0.077 ***
## (0.009)
## --------------------------------------------------------------
## R^2 0.180 0.158 0.174
## Adj. R^2 0.157 0.157 0.174
## Num. obs. 4360 4360 4360
## ==============================================================
## *** p < 0.001, ** p < 0.01, * p < 0.05
phtest(fixed1, random1)
##
## Hausman Test
##
## data: wage ~ married + exper + I(exper^2) + union + health + occupation
## chisq = 206.17, df = 13, p-value < 2.2e-16
## alternative hypothesis: one model is inconsistent
結婚の係数は、固定効果モデルは 0.045 であるのに対して、ランダム効果モデルは 0.075 で多少の違いが見られる。また固定効果モデルでは職業はサービス職以外は有意にならなかったが、ランダム効果モデルではかなり有意になっている。ハウスマン検定の結果は 0.1% 水準で有意であり、TCUH を統制したモデルとしては、固定効果モデルのほうが適切であると考えられる。
ハイブリッド・モデルに投入した時定変数は、人種と学歴であるが、人種に関して黒人の方が白人(others となっているがほとんど白人であろう)よりも賃金が低く、ヒスパニックに関しては白人と有意な差がでなかった。教育年数は 0.077 の傾きで有意である。\(\exp(0.077)=1.08\) であるから、教育年数が1年のびると 8% 賃金が上昇するという推定結果である。
すでに推定した固定効果モデルをランダム効果モデルでも推定し、結果をハウスマン検定で比較しなさい。また時定変数もモデルに投入してハイブリッド・モデルを推定しなさい。