Data
setwd("C:/Users/User/Dropbox/IO")
library(readxl)
df <- read_excel("data_Griliches_Mairesse.xls")
DT::datatable(df)Observations
index)sic3)yr)ldsal)lemp)ldnpt)ldrst)ldrnd)ldinv)Борлуулалт, Хүний нөөцийн орц, Капитал, R&D капитал, R&Dхөрөнгө оруулалт, Капиталын хөрөнгө оруулалт хувьсагчийн дундаж, вариацыг тус тус ол
бүх компанийн хувьд
library(dplyr)
sapply(df[,-1:-3], mean)## ldsal lemp ldnpt ldrst ldrnd ldinv
## 5.673087 1.259177 4.468996 3.400962 1.787530 2.674828
sapply(df[,-1:-3], var)## ldsal lemp ldnpt ldrst ldrnd ldinv
## 3.844412 3.151506 4.912960 4.115928 4.212387 4.710967
бүх үед ажиглагдсан компаниудын хувьд
df_b <- df %>%
group_by(index) %>%
filter(n()==4)
dim(df_b)## [1] 856 9
sapply(df_b[,-1:-3], mean)## ldsal lemp ldnpt ldrst ldrnd ldinv
## 6.914288 2.412850 5.915943 4.885773 3.221566 4.068996
sapply(df_b[,-1:-3], var)## ldsal lemp ldnpt ldrst ldrnd ldinv
## 3.377599 2.631953 4.232875 3.724434 3.976469 4.223425
дор хаяж 2 үе ажиглалттай компанийн хувьд
df_c <- df %>%
group_by(index) %>%
filter(n()>1)sapply(df_c[,-1:-3], mean)## ldsal lemp ldnpt ldrst ldrnd ldinv
## 5.917722 1.505869 4.766525 3.665835 2.018152 2.926110
sapply(df_c[,-1:-3], var)## ldsal lemp ldnpt ldrst ldrnd ldinv
## 3.774591 3.008001 4.746978 4.026733 4.216257 4.695677
Баланслагдсан панел датаг (balanced panel) (ө. х өмнөх асуултын (b) түүвэр) ашиглан дараахь моделийг үнэл
\[ldsal_{it} = \beta_1 lemp_{it} + \beta_2 ldnpt_{it} + \beta_3 ldrst_{it} +\beta_4 d78_t + \beta_5 · d83_t + \beta_6 d88_t + \alpha_i + \varepsilon_{it}\]
library(ggplot2)
library(GGally)
ggpairs(data = df_b[, -1:-3], mapping = aes(color = ldsal),
upper = list(continuous = "smooth"), lower = list(combo = "facetdensity"),
diag = list(continuous = "barDiag"))plot(df_b[,-1:-3])library(AER) # Эконометрикийн пакэж
library(plm) # Панел регрессийн пакеж
eq <- ldsal ~ lemp + ldnpt + ldrst + ldrnd + ldinv + yrreg_1 <- plm(eq, data = df_b,
index = c("index", "yr"),
model = "pooling",
effect = NULL)
reg_2 <- plm(eq, data = df_b,
index = c("index", "yr"),
model = "within",
effect = "individual")
reg_3 <- plm(eq, data = df_b,
index = c("index", "yr"),
model = "random")
summary(reg_1)## Oneway (individual) effect Pooling Model
##
## Call:
## plm(formula = eq, data = df_b, effect = NULL, model = "pooling",
## index = c("index", "yr"))
##
## Balanced Panel: n=214, T=4, N=856
##
## Residuals :
## Min. 1st Qu. Median 3rd Qu. Max.
## -3.3800 -0.1880 0.0429 0.2540 1.7500
##
## Coefficients :
## Estimate Std. Error t-value Pr(>|t|)
## (Intercept) 2.55807408 0.11282072 22.6738 < 2.2e-16 ***
## lemp 0.44315995 0.03626271 12.2208 < 2.2e-16 ***
## ldnpt 0.51461835 0.03644167 14.1217 < 2.2e-16 ***
## ldrst 0.07822247 0.05767731 1.3562 0.1754
## ldrnd -0.07198017 0.05309277 -1.3557 0.1755
## ldinv 0.00035965 0.03986656 0.0090 0.9928
## yr78 0.06216295 0.05093461 1.2204 0.2226
## yr83 -0.01829938 0.05415244 -0.3379 0.7355
## yr88 0.31905760 0.05238189 6.0910 1.701e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 2887.8
## Residual Sum of Squares: 233.56
## R-Squared: 0.91912
## Adj. R-Squared: 0.90946
## F-statistic: 1203.23 on 8 and 847 DF, p-value: < 2.22e-16
summary(reg_2)## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = eq, data = df_b, effect = "individual", model = "within",
## index = c("index", "yr"))
##
## Balanced Panel: n=214, T=4, N=856
##
## Residuals :
## Min. 1st Qu. Median 3rd Qu. Max.
## -1.6700 -0.1010 0.0025 0.1070 1.5700
##
## Coefficients :
## Estimate Std. Error t-value Pr(>|t|)
## lemp 0.702198 0.068901 10.1913 < 2.2e-16 ***
## ldnpt 0.016315 0.058042 0.2811 0.77873
## ldrst 0.345403 0.064996 5.3142 1.486e-07 ***
## ldrnd 0.088757 0.047655 1.8625 0.06300 .
## ldinv 0.041471 0.035668 1.1627 0.24539
## yr78 0.081210 0.034682 2.3416 0.01951 *
## yr83 0.061685 0.043376 1.4221 0.15550
## yr88 0.255169 0.046934 5.4367 7.752e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 218.51
## Residual Sum of Squares: 74.622
## R-Squared: 0.65849
## Adj. R-Squared: 0.48771
## F-statistic: 152.807 on 8 and 634 DF, p-value: < 2.22e-16
summary(reg_3)## Oneway (individual) effect Random Effect Model
## (Swamy-Arora's transformation)
##
## Call:
## plm(formula = eq, data = df_b, model = "random", index = c("index",
## "yr"))
##
## Balanced Panel: n=214, T=4, N=856
##
## Effects:
## var std.dev share
## idiosyncratic 0.1177 0.3431 0.456
## individual 0.1407 0.3750 0.544
## theta: 0.5841
##
## Residuals :
## Min. 1st Qu. Median 3rd Qu. Max.
## -2.4800 -0.1020 0.0167 0.1510 1.1300
##
## Coefficients :
## Estimate Std. Error t-value Pr(>|t|)
## (Intercept) 2.8879799 0.1300080 22.2139 < 2.2e-16 ***
## lemp 0.5119974 0.0478084 10.7094 < 2.2e-16 ***
## ldnpt 0.3663215 0.0386222 9.4847 < 2.2e-16 ***
## ldrst 0.0581819 0.0511814 1.1368 0.2560
## ldrnd 0.0095089 0.0448160 0.2122 0.8320
## ldinv 0.0494081 0.0344810 1.4329 0.1523
## yr78 0.0768796 0.0353673 2.1737 0.0300 *
## yr83 0.0271389 0.0397895 0.6821 0.4954
## yr88 0.3274173 0.0391204 8.3695 2.377e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 680.32
## Residual Sum of Squares: 111.23
## R-Squared: 0.83651
## Adj. R-Squared: 0.82771
## F-statistic: 541.711 on 8 and 847 DF, p-value: < 2.22e-16
phtest(reg_2, reg_3)##
## Hausman Test
##
## data: eq
## chisq = 123.11, df = 8, p-value < 2.2e-16
## alternative hypothesis: one model is inconsistent