capitalrep <- read.csv("data/capitalreplication.csv", header=T)
capitalrep$K1_N14 <- capitalrep$K1/capitalrep$N14*100
capitalrep$A1_K1 <- capitalrep$A1/capitalrep$K1*100
capitalrep$S1_C1 <- capitalrep$S1/capitalrep$C1*100
capitalrep$U_L <- capitalrep$U/capitalrep$L*100
capitalrep$IN_CP <- (capitalrep$IN/capitalrep$IN[capitalrep$YEAR==2015])/(capitalrep$CP/capitalrep$CP[capitalrep$YEAR==2015])*100
capitalrep$P_N <- capitalrep$P/capitalrep$N
capitalrep$M2029_N <- capitalrep$M2029/capitalrep$N*100
capitalrep$E1_N <- capitalrep$E1/(capitalrep$N*1000)*100
Adjusting the year of the data
matsu <- subset(capitalrep, 1953<=YEAR & YEAR<=1987)
Lag and log-transformation
matsu$S1_C1_LAG <- c(NA,matsu$S1_C1[1:length(matsu$S1_C1)-1])
matsu$LK1_N14 <- log(matsu$K1_N14)
matsu$LA1_K1 <- log(matsu$A1_K1)
matsu$LS1_C1 <- log(matsu$S1_C1)
matsu$LIN_CP <- log(matsu$IN_CP)
matsu$LU_L <- log(matsu$U_L)
matsu$LP_N <- log(matsu$P_N)
matsu$LM2029_N <- log(matsu$M2029_N)
matsu$LE1_N <- log(matsu$E1_N)
matsu$LS1_C1_LAG <- log(matsu$S1_C1_LAG)
matsu_ols <- lm(K1_N14~A1_K1+S1_C1+IN_CP+U_L+P_N+M2029_N+E1_N,data=matsu)
matsu_log_ols <- lm(LK1_N14~LA1_K1+LS1_C1+LIN_CP+LU_L+LP_N+LM2029_N+LE1_N,data=matsu)
matsu_lag_ols <- lm(K1_N14~A1_K1+S1_C1_LAG+IN_CP+U_L+P_N+M2029_N+E1_N,data=matsu)
matsu_laglog_ols <- lm(LK1_N14~LA1_K1+LS1_C1_LAG+LIN_CP+LU_L+LP_N+LM2029_N+LE1_N,data=matsu)
library(memisc)
matsu_model <- mtable("(1)"=matsu_ols,"(2)"=matsu_log_ols,"(3)"=matsu_lag_ols,"(4)"=matsu_laglog_ols,coef.style="stat",signif.symbols=c("***"=.01,"**"=.05, "*"=.1),summary.stats=c("adj. R-squared","N"))
print(matsu_model)
##
## Calls:
## (1): lm(formula = K1_N14 ~ A1_K1 + S1_C1 + IN_CP + U_L + P_N + M2029_N +
## E1_N, data = matsu)
## (2): lm(formula = LK1_N14 ~ LA1_K1 + LS1_C1 + LIN_CP + LU_L + LP_N +
## LM2029_N + LE1_N, data = matsu)
## (3): lm(formula = K1_N14 ~ A1_K1 + S1_C1_LAG + IN_CP + U_L + P_N +
## M2029_N + E1_N, data = matsu)
## (4): lm(formula = LK1_N14 ~ LA1_K1 + LS1_C1_LAG + LIN_CP + LU_L +
## LP_N + LM2029_N + LE1_N, data = matsu)
##
## ==================================================================
## (1) (2) (3) (4)
## ----------- ----------- ----------- -----------
## K1_N14 LK1_N14 K1_N14 LK1_N14
## ------------------------------------------------------------------
## (Intercept) -7.068* -2.771 -6.046 -1.777
## (-1.775) (-0.505) (-1.540) (-0.332)
## A1_K1 0.037 0.043
## (0.895) (1.041)
## S1_C1 0.086
## (1.169)
## IN_CP -0.000 -0.011
## (-0.023) (-0.999)
## U_L 0.488*** 0.592***
## (5.944) (6.585)
## P_N 0.158*** 0.116**
## (4.285) (2.666)
## M2029_N 0.371*** 0.336***
## (4.863) (4.406)
## E1_N -0.290 -0.296
## (-1.005) (-1.032)
## LA1_K1 0.065 -0.003
## (0.053) (-0.003)
## LS1_C1 0.000
## (0.007)
## LIN_CP -0.107 -0.201
## (-0.541) (-1.008)
## LU_L 0.209*** 0.211***
## (5.275) (5.433)
## LP_N 0.589*** 0.525**
## (2.854) (2.544)
## LM2029_N 1.025*** 0.962***
## (5.941) (5.644)
## LE1_N -0.216* -0.205*
## (-1.943) (-1.881)
## S1_C1_LAG -0.101
## (-1.271)
## LS1_C1_LAG -0.028
## (-1.436)
## ------------------------------------------------------------------
## adj. R-squared 0.974 0.982 0.972 0.982
## N 35 35 34 34
## ==================================================================
## Significance: *** = p < 0.01; ** = p < 0.05; * = p < 0.1
Durbin-Watson statistics
library(lmtest)
dwtest(matsu_ols)
##
## Durbin-Watson test
##
## data: matsu_ols
## DW = 1.4282, p-value = 0.004377
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(matsu_log_ols)
##
## Durbin-Watson test
##
## data: matsu_log_ols
## DW = 1.5646, p-value = 0.01366
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(matsu_lag_ols)
##
## Durbin-Watson test
##
## data: matsu_lag_ols
## DW = 1.5337, p-value = 0.01134
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(matsu_laglog_ols)
##
## Durbin-Watson test
##
## data: matsu_laglog_ols
## DW = 1.6339, p-value = 0.02171
## alternative hypothesis: true autocorrelation is greater than 0
capitalrep$K2_N <- capitalrep$K2/capitalrep$N*100
capitalrep$A2_K2 <- capitalrep$A2/capitalrep$K2*100
capitalrep$C2_A2 <- capitalrep$C2/capitalrep$A2*100
capitalrep$X_C2 <- capitalrep$X/capitalrep$C2*100
capitalrep$G1_N <- capitalrep$G1/capitalrep$N*100
capitalrep$F1_N <- capitalrep$F1/(capitalrep$N*1000)*100
capitalrep$M1524_N <- capitalrep$M1524/capitalrep$N*100
capitalrep$E2_N <- capitalrep$E2/(capitalrep$N*1000)*100
capitalrep$Y1972 <- ifelse(capitalrep$YEAR<1972,0,1)
Adjusting the year of the data
akiba <- subset(capitalrep, 1960<=YEAR & YEAR<=1986)
Time trend
akiba$TREND=1:nrow(akiba)
Lag and log-transformation
akiba$K2LAG <- c(NA,akiba$K2[1:length(akiba$K2)-1])
akiba$A2_K2LAG <- (akiba$A2)/(akiba$K2LAG)
akiba$LA2_K2LAG <- log(akiba$A2_K2LAG)
akiba$LK2_N <- log(akiba$K2_N)
akiba$LA2_K2 <- log(akiba$A2_K2)
akiba$LC2_A2 <- log(akiba$C2_A2)
akiba$LU_L <- log(akiba$U_L)
akiba$LW <- log(akiba$W)
akiba$LG1_N <- log(akiba$G1_N)
akiba$LF1_N <- log(akiba$F1_N)
akiba$LM1524_N <- log(akiba$M1524_N)
akiba$LE2_N <- log(akiba$E2_N)
# Ehrlich’s (1975) method to treat the cases where the original values are zero
akiba$X_C2_1 <- ifelse(akiba$X==0,1,akiba$X)/akiba$C2*100
akiba$LX_C2_1 <- log(akiba$X_C2_1)
akiba_ols <- lm(K2_N~A2_K2+C2_A2+X_C2+U_L+W+G1_N+F1_N+M1524_N+E2_N+Y1972+TREND, data=akiba)
akiba_log_ols <- lm(LK2_N~LA2_K2+LC2_A2+LX_C2_1+LU_L+LW+LG1_N+LF1_N+LM1524_N+LE2_N+Y1972+TREND, data=akiba)
akiba_lag_ols <- lm(K2_N~A2_K2LAG+C2_A2+X_C2+U_L+W+G1_N+F1_N+M1524_N+E2_N+Y1972+TREND, data=akiba)
akiba_laglog_ols <- lm(LK2_N~LA2_K2LAG+LC2_A2+LX_C2_1+LU_L+LW+LG1_N+LF1_N+LM1524_N+LE2_N+Y1972+TREND, data=akiba)
akiba_model <- mtable("(1)"=akiba_ols,"(2)"=akiba_log_ols,"(3)"=akiba_lag_ols,"(4)"=akiba_laglog_ols,coef.style="stat",signif.symbols=c("***"=.01,"**"=.05, "*"=.1),summary.stats=c("adj. R-squared","N"))
print(akiba_model)
##
## Calls:
## (1): lm(formula = K2_N ~ A2_K2 + C2_A2 + X_C2 + U_L + W + G1_N + F1_N +
## M1524_N + E2_N + Y1972 + TREND, data = akiba)
## (2): lm(formula = LK2_N ~ LA2_K2 + LC2_A2 + LX_C2_1 + LU_L + LW +
## LG1_N + LF1_N + LM1524_N + LE2_N + Y1972 + TREND, data = akiba)
## (3): lm(formula = K2_N ~ A2_K2LAG + C2_A2 + X_C2 + U_L + W + G1_N +
## F1_N + M1524_N + E2_N + Y1972 + TREND, data = akiba)
## (4): lm(formula = LK2_N ~ LA2_K2LAG + LC2_A2 + LX_C2_1 + LU_L + LW +
## LG1_N + LF1_N + LM1524_N + LE2_N + Y1972 + TREND, data = akiba)
##
## ============================================================
## (1) (2) (3) (4)
## ---------- --------- ---------- ---------
## K2_N LK2_N K2_N LK2_N
## ------------------------------------------------------------
## (Intercept) 1.341 -2.506 -1.403 1.729
## (0.339) (-0.285) (-0.856) (0.959)
## A2_K2 -0.011
## (-0.363)
## C2_A2 -0.010** -0.008
## (-2.571) (-1.549)
## X_C2 -0.042* -0.031
## (-1.867) (-1.445)
## U_L 0.344** 0.310**
## (2.632) (2.246)
## W 0.011 0.016
## (0.772) (1.335)
## G1_N -0.002 -0.004
## (-0.302) (-0.906)
## F1_N 0.114 0.190*
## (1.292) (1.948)
## M1524_N 0.068 0.064
## (1.145) (1.164)
## E2_N 0.231 0.512
## (0.614) (1.297)
## Y1972 0.090 0.020 0.088 0.002
## (0.692) (0.264) (0.704) (0.030)
## TREND -0.045 -0.021 -0.015 -0.010
## (-0.891) (-0.717) (-0.321) (-0.402)
## LA2_K2 0.924
## (0.454)
## LC2_A2 -0.214 -0.130
## (-1.649) (-0.798)
## LX_C2_1 -0.004 -0.002
## (-0.401) (-0.165)
## LU_L 0.224 0.190
## (1.579) (1.231)
## LW 0.462 0.536
## (1.039) (1.491)
## LG1_N -0.617 -0.773
## (-0.826) (-1.357)
## LF1_N -0.115 0.130
## (-0.198) (0.230)
## LM1524_N 0.704 0.474
## (1.733) (1.310)
## LE2_N 0.078 0.165
## (0.230) (0.563)
## A2_K2LAG 0.311
## (0.844)
## LA2_K2LAG 0.281
## (1.269)
## ------------------------------------------------------------
## adj. R-squared 0.979 0.969 0.977 0.970
## N 27 27 26 26
## ============================================================
## Significance: *** = p < 0.01; ** = p < 0.05; * = p < 0.1
Durbin-Watson statistics
dwtest(akiba_ols)
##
## Durbin-Watson test
##
## data: akiba_ols
## DW = 1.687, p-value = 0.01055
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(akiba_log_ols)
##
## Durbin-Watson test
##
## data: akiba_log_ols
## DW = 1.8087, p-value = 0.03568
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(akiba_lag_ols)
##
## Durbin-Watson test
##
## data: akiba_lag_ols
## DW = 2.068, p-value = 0.09291
## alternative hypothesis: true autocorrelation is greater than 0
dwtest(akiba_laglog_ols)
##
## Durbin-Watson test
##
## data: akiba_laglog_ols
## DW = 1.7299, p-value = 0.01866
## alternative hypothesis: true autocorrelation is greater than 0
capitalrep$Cm_K2 <- capitalrep$Cm/capitalrep$K2
capitalrep$Gm_N <- capitalrep$Gm/capitalrep$N*100
capitalrep$L_N <- capitalrep$L/(capitalrep$N*10)*100
capitalrep$N2029_N <- capitalrep$N2029/capitalrep$N
Adjusting the year of the data
mer <- subset(capitalrep, 1957<=YEAR & YEAR<=1982)
Log-transformation
mer$LK2_N <- log(mer$K2_N)
mer$LCm_K2 <- log(mer$Cm_K2)
mer$LU_L <- log(mer$U_L)
mer$LGm_N <- log(mer$Gm_N)
mer$LL_N <- log(mer$L_N)
mer$LN2029_N <- log(mer$N2029_N)
mer$LM2029_N <- log(mer$M2029_N)
# Ehrlich’s (1975) method to treat the cases where the original values are zero
mer$X_Cm_1 <- ifelse(mer$X==0,1,mer$X)/mer$Cm
mer$LX_Cm_1 <- log(mer$X_Cm_1)
Other variables such as time trend
mer$TREND=1:nrow(mer)
mer$Gm_N_LAG <- c(NA,mer$Gm_N[1:length(mer$Gm_N)-1])
mer$DGm_N <- (mer$Gm_N-mer$Gm_N_LAG)/mer$Gm_N_LAG
mer$LDGm_N <- mer$LGm_N-log(mer$Gm_N_LAG)
Prais-Winsten’s method
library(prais)
mer_prais1 <- prais_winsten(LK2_N~LCm_K2+LX_Cm_1+LU_L+LGm_N+LL_N+TREND+LN2029_N, data = mer)
mer_prais2 <- prais_winsten(LK2_N~LCm_K2+LX_Cm_1+LU_L+LGm_N+LL_N+LN2029_N, data = mer)
mer_prais3 <- prais_winsten(LK2_N~LCm_K2+LX_Cm_1+LU_L+LDGm_N+LL_N+TREND+LN2029_N, data = mer)
summary(mer_prais1)
##
## Call:
## prais_winsten(formula = LK2_N ~ LCm_K2 + LX_Cm_1 + LU_L + LGm_N +
## LL_N + TREND + LN2029_N, data = mer)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.071401 -0.023727 0.009096 0.024390 0.066940
##
## AR(1) coefficient rho after 19 Iterations: 0.461
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.445409 3.238699 -0.138 0.8921
## LCm_K2 -0.147699 0.112207 -1.316 0.2046
## LX_Cm_1 -0.016904 0.007193 -2.350 0.0304 *
## LU_L 0.161222 0.098492 1.637 0.1190
## LGm_N 0.238650 0.422558 0.565 0.5792
## LL_N -0.816586 1.425087 -0.573 0.5737
## TREND -0.044445 0.029715 -1.496 0.1521
## LN2029_N 0.148879 0.487281 0.306 0.7635
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03655 on 18 degrees of freedom
## Multiple R-squared: 0.9613, Adjusted R-squared: 0.9463
## F-statistic: 63.9 on 7 and 18 DF, p-value: 2.014e-11
##
## Durbin-Watson statistic (original): 1.215
## Durbin-Watson statistic (transformed): 1.463
summary(mer_prais2)
##
## Call:
## prais_winsten(formula = LK2_N ~ LCm_K2 + LX_Cm_1 + LU_L + LGm_N +
## LL_N + LN2029_N, data = mer)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.08077 -0.01980 0.00768 0.01941 0.07410
##
## AR(1) coefficient rho after 20 Iterations: 0.3597
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.038922 1.022543 3.950 0.000859 ***
## LCm_K2 -0.125769 0.120260 -1.046 0.308772
## LX_Cm_1 -0.017393 0.007828 -2.222 0.038633 *
## LU_L 0.075663 0.087912 0.861 0.400152
## LGm_N -0.395499 0.029762 -13.289 4.54e-11 ***
## LL_N 0.279917 1.158227 0.242 0.811619
## LN2029_N 0.763891 0.216576 3.527 0.002252 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.038 on 19 degrees of freedom
## Multiple R-squared: 0.9618, Adjusted R-squared: 0.9497
## F-statistic: 79.66 on 6 and 19 DF, p-value: 1.921e-12
##
## Durbin-Watson statistic (original): 1.352
## Durbin-Watson statistic (transformed): 1.549
summary(mer_prais3)
##
## Call:
## prais_winsten(formula = LK2_N ~ LCm_K2 + LX_Cm_1 + LU_L + LDGm_N +
## LL_N + TREND + LN2029_N, data = mer)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.047997 -0.014791 -0.001091 0.014248 0.046265
##
## AR(1) coefficient rho after 10 Iterations: 0.3231
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.101579 0.777864 -0.131 0.8976
## LCm_K2 -0.196721 0.093693 -2.100 0.0510 .
## LX_Cm_1 -0.010774 0.005757 -1.871 0.0786 .
## LU_L 0.076792 0.061695 1.245 0.2301
## LDGm_N 0.736844 0.244411 3.015 0.0078 **
## LL_N -1.847362 0.883264 -2.092 0.0518 .
## TREND -0.027444 0.001812 -15.146 2.65e-11 ***
## LN2029_N 0.219515 0.159862 1.373 0.1875
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02651 on 17 degrees of freedom
## Multiple R-squared: 0.9838, Adjusted R-squared: 0.9772
## F-statistic: 147.8 on 7 and 17 DF, p-value: 5.745e-14
##
## Durbin-Watson statistic (original): 1.363
## Durbin-Watson statistic (transformed): 1.62