Regina Enríquez Chapa A01721435
Maximiliano Carvajal A01552179
Guillermo Cazares Cruz A01283709
setwd("D:/8vo semestre")
library(plm)
library(gplots)
##
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
##
## lowess
Patent3 <- read.csv("PATENT 3.csv")
Patent3 <- Patent3[,c(1:12)]
colnames(Patent3)[1] = "cusip"
colSums(is.na(Patent3))
## cusip merger employ return patents patentsg stckpr rnd
## 0 0 0 0 0 0 0 0
## rndeflt sales sic year
## 0 0 0 0
str(Patent3)
## 'data.frame': 2250 obs. of 12 variables:
## $ cusip : int 800 800 800 800 800 800 800 800 800 800 ...
## $ merger : int 0 0 0 0 0 0 0 0 0 0 ...
## $ employ : int 10 12 12 12 13 13 14 14 13 12 ...
## $ return : int 6 6 4 5 5 5 5 5 4 5 ...
## $ patents : int 22 34 31 32 40 60 57 77 38 5 ...
## $ patentsg: int 24 32 30 34 28 33 53 47 64 70 ...
## $ stckpr : int 48 58 33 38 35 34 31 34 46 41 ...
## $ rnd : int 3 3 3 3 4 4 5 5 7 8 ...
## $ rndeflt : int 3 3 3 3 3 3 3 3 4 4 ...
## $ sales : int 344 436 535 567 631 706 819 992 1045 939 ...
## $ sic : int 3740 3740 3740 3740 3740 3740 3740 3740 3740 3740 ...
## $ year : int 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 ...
El modelo económico sería el siguiente:
patentsg = f(return,employ,rnd,sales)
Patent3 <- pdata.frame(Patent3, index = c("cusip","year"))
plotmeans(patentsg ~ year, data = Patent3, xlab = "Años", ylab = "Patentes", main = "Heterogeneidad entre años", mean.labels = FALSE)
plotmeans(patentsg ~ cusip, data = Patent3, xlab = "Empresas", ylab = "Patentes", main = "Heterogeneidad entre empresas", mean.labels = FALSE)
Sí se puede presenciar heterogeneidad en ambas graficas.
pooled_1 <- plm(patentsg ~ return + employ + rnd + sales, data = Patent3, model = "pooling")
summary(pooled_1)
## Pooling Model
##
## Call:
## plm(formula = patentsg ~ return + employ + rnd + sales, data = Patent3,
## model = "pooling")
##
## Balanced Panel: n = 225, T = 10, N = 2250
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -442.5435 -10.5304 -4.6064 1.7056 529.9156
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## (Intercept) -2.53818295 2.00364931 -1.2668 0.2054
## return 0.89882599 0.20031729 4.4870 7.588e-06 ***
## employ 1.50534937 0.04795130 31.3933 < 2.2e-16 ***
## rnd -0.07849107 0.01848652 -4.2459 2.266e-05 ***
## sales -0.00271798 0.00054088 -5.0251 5.428e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 14161000
## Residual Sum of Squares: 6169000
## R-Squared: 0.56435
## Adj. R-Squared: 0.56357
## F-statistic: 727.051 on 4 and 2245 DF, p-value: < 2.22e-16
within_1 <- plm(patentsg ~ return + employ + rnd + sales, data = Patent3, model = "within")
summary(within_1)
## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = patentsg ~ return + employ + rnd + sales, data = Patent3,
## model = "within")
##
## Balanced Panel: n = 225, T = 10, N = 2250
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -218.73410 -1.90671 -0.31204 1.51679 269.88092
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## return -0.0032470 0.0897144 -0.0362 0.9711
## employ -0.0575524 0.0606945 -0.9482 0.3431
## rnd -0.1442205 0.0119849 -12.0335 < 2.2e-16 ***
## sales -0.0015633 0.0003528 -4.4312 9.872e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 715640
## Residual Sum of Squares: 590370
## R-Squared: 0.17504
## Adj. R-Squared: 0.081968
## F-statistic: 107.202 on 4 and 2021 DF, p-value: < 2.22e-16
pFtest(within_1,pooled_1)
##
## F test for individual effects
##
## data: patentsg ~ return + employ + rnd + sales
## F = 85.256, df1 = 224, df2 = 2021, p-value < 2.2e-16
## alternative hypothesis: significant effects
walhus_1 <- plm(patentsg ~ return + employ + rnd + sales, data = Patent3, model = "random", random.method = "walhus")
summary(walhus_1)
## Oneway (individual) effect Random Effect Model
## (Wallace-Hussain's transformation)
##
## Call:
## plm(formula = patentsg ~ return + employ + rnd + sales, data = Patent3,
## model = "random", random.method = "walhus")
##
## Balanced Panel: n = 225, T = 10, N = 2250
##
## Effects:
## var std.dev share
## idiosyncratic 419.34 20.48 0.153
## individual 2322.46 48.19 0.847
## theta: 0.8668
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -147.41970 -3.95214 -2.55913 -0.11644 316.47117
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 17.78900639 3.22493375 5.5161 3.466e-08 ***
## return 0.06266189 0.09910040 0.6323 0.5272
## employ 0.80860589 0.04913451 16.4570 < 2.2e-16 ***
## rnd -0.11358574 0.01289051 -8.8116 < 2.2e-16 ***
## sales -0.00232998 0.00037996 -6.1322 8.665e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 954090
## Residual Sum of Squares: 813500
## R-Squared: 0.14736
## Adj. R-Squared: 0.14584
## Chisq: 387.993 on 4 DF, p-value: < 2.22e-16
amemiya_1 <- plm(patentsg ~ return + employ + rnd + sales, data = Patent3, model = "random", random.method = "amemiya")
summary(amemiya_1)
## Oneway (individual) effect Random Effect Model
## (Amemiya's transformation)
##
## Call:
## plm(formula = patentsg ~ return + employ + rnd + sales, data = Patent3,
## model = "random", random.method = "amemiya")
##
## Balanced Panel: n = 225, T = 10, N = 2250
##
## Effects:
## var std.dev share
## idiosyncratic 291.54 17.07 0.031
## individual 9195.47 95.89 0.969
## theta: 0.9438
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -174.82200 -3.06717 -1.81866 0.34135 292.16706
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 29.25087312 6.48511746 4.5105 6.469e-06 ***
## return 0.01382987 0.08902992 0.1553 0.8766
## employ 0.21701390 0.05564707 3.8998 9.626e-05 ***
## rnd -0.13463308 0.01182496 -11.3855 < 2.2e-16 ***
## sales -0.00180637 0.00034825 -5.1871 2.136e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 758130
## Residual Sum of Squares: 647790
## R-Squared: 0.14554
## Adj. R-Squared: 0.14402
## Chisq: 382.393 on 4 DF, p-value: < 2.22e-16
nerlove_1 <- plm(patentsg ~ return + employ + rnd + sales, data = Patent3, model = "random", random.method = "nerlove")
summary(nerlove_1)
## Oneway (individual) effect Random Effect Model
## (Nerlove's transformation)
##
## Call:
## plm(formula = patentsg ~ return + employ + rnd + sales, data = Patent3,
## model = "random", random.method = "nerlove")
##
## Balanced Panel: n = 225, T = 10, N = 2250
##
## Effects:
## var std.dev share
## idiosyncratic 262.39 16.20 0.028
## individual 9265.80 96.26 0.972
## theta: 0.9469
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -176.59240 -3.00166 -1.76173 0.38987 290.97104
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 29.72678963 6.82036888 4.3585 1.309e-05 ***
## return 0.01220865 0.08866824 0.1377 0.8904862
## employ 0.19225413 0.05584827 3.4424 0.0005765 ***
## rnd -0.13550037 0.01178374 -11.4989 < 2.2e-16 ***
## sales -0.00178445 0.00034702 -5.1422 2.715e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 753600
## Residual Sum of Squares: 642330
## R-Squared: 0.14765
## Adj. R-Squared: 0.14613
## Chisq: 388.894 on 4 DF, p-value: < 2.22e-16
phtest(nerlove_1,within_1)
##
## Hausman Test
##
## data: patentsg ~ return + employ + rnd + sales
## chisq = 113.03, df = 4, p-value < 2.2e-16
## alternative hypothesis: one model is inconsistent
Entre los 5 modelos analizados, el que obtuvo los mejores resultado fue el de regresión agrupada (Pooled). Esto se debe que tiene la mayor cantidad de R^2 ajustada, con 0.564. Por lo tanto, Pooled es el modelo más apropiado.
Como se mencionó hace unos instantes, el modelo más apropiado fue Pooled. Las 4 variables independientes son estadisticamente significativas, 2 tienen impactos positivos sobre la dependiente, y las otras 2 tienen impactos negativos. La variable independiente con mayor impacto fue “employ”.