# Librerías
#-------------------------
#install.packages("WDI")
#install.packages("wbstats")
#install.packages("tidyverse")
#install.packages("plm")
#install.packages("gplots")
library(WDI)
library(wbstats)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.5.0 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plm)
##
## Attaching package: 'plm'
## The following objects are masked from 'package:dplyr':
##
## between, lag, lead
library(gplots)
##
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
##
## lowess
OBTENCIÓN DE LOS DATOS
# DATA
# ----------------------------------------
gpd_data <- wb_data(country=c("MX", "EC", "CA"),
indicator = "NY.GDP.PCAP.CD", start_date=1950, end_date=2023)
gpd_data
## # A tibble: 189 × 9
## iso2c iso3c country date NY.GDP.PCAP.CD unit obs_status footnote
## <chr> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
## 1 CA CAN Canada 1960 2259. <NA> <NA> <NA>
## 2 CA CAN Canada 1961 2240. <NA> <NA> <NA>
## 3 CA CAN Canada 1962 2269. <NA> <NA> <NA>
## 4 CA CAN Canada 1963 2374. <NA> <NA> <NA>
## 5 CA CAN Canada 1964 2555. <NA> <NA> <NA>
## 6 CA CAN Canada 1965 2770. <NA> <NA> <NA>
## 7 CA CAN Canada 1966 3047. <NA> <NA> <NA>
## 8 CA CAN Canada 1967 3217. <NA> <NA> <NA>
## 9 CA CAN Canada 1968 3463. <NA> <NA> <NA>
## 10 CA CAN Canada 1969 3764. <NA> <NA> <NA>
## # ℹ 179 more rows
## # ℹ 1 more variable: last_updated <date>
# PANEL
# ----------------------------
panel <- select(gpd_data, country, date, NY.GDP.PCAP.CD)
panel
## # A tibble: 189 × 3
## country date NY.GDP.PCAP.CD
## <chr> <dbl> <dbl>
## 1 Canada 1960 2259.
## 2 Canada 1961 2240.
## 3 Canada 1962 2269.
## 4 Canada 1963 2374.
## 5 Canada 1964 2555.
## 6 Canada 1965 2770.
## 7 Canada 1966 3047.
## 8 Canada 1967 3217.
## 9 Canada 1968 3463.
## 10 Canada 1969 3764.
## # ℹ 179 more rows
#Industrialización, inflación, exportación
comercio_data <- wb_data(country=c("US", "CN", "IR", "UA"), indicator=c("FP.CPI.TOTL.ZG", "NE.EXP.GNFS.ZS", "NV.IND.MANF.ZS"), start_date=1970, end_date=2023)
comercio_data
## # A tibble: 212 × 7
## iso2c iso3c country date FP.CPI.TOTL.ZG NE.EXP.GNFS.ZS NV.IND.MANF.ZS
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 CN CHN China 1970 NA 2.49 NA
## 2 CN CHN China 1971 NA 2.79 NA
## 3 CN CHN China 1972 NA 3.25 NA
## 4 CN CHN China 1973 NA 4.24 NA
## 5 CN CHN China 1974 NA 4.93 NA
## 6 CN CHN China 1975 NA 4.70 NA
## 7 CN CHN China 1976 NA 4.51 NA
## 8 CN CHN China 1977 NA 4.30 NA
## 9 CN CHN China 1978 NA 4.56 NA
## 10 CN CHN China 1979 NA 5.16 NA
## # ℹ 202 more rows
panel_comercio <- select(comercio_data, country, date, FP.CPI.TOTL.ZG, NE.EXP.GNFS.ZS, NV.IND.MANF.ZS )
panel_comercio <- subset(panel_comercio, date == 1990 | date == 2000 | date == 2010 | date == 2020)
panel_comercio <- pdata.frame(panel_comercio, index = c("country", "date"))
panel_comercio
## country date FP.CPI.TOTL.ZG NE.EXP.GNFS.ZS
## China-1990 China 1990 3.0522901 12.451603
## China-2000 China 2000 0.3478112 20.893697
## China-2010 China 2010 3.1753248 27.185333
## China-2020 China 2020 2.4194219 18.586139
## Iran, Islamic Rep.-1990 Iran, Islamic Rep. 1990 7.6276749 13.278742
## Iran, Islamic Rep.-2000 Iran, Islamic Rep. 2000 14.4767513 21.467058
## Iran, Islamic Rep.-2010 Iran, Islamic Rep. 2010 10.0893629 24.399653
## Iran, Islamic Rep.-2020 Iran, Islamic Rep. 2020 30.5941390 19.424609
## Ukraine-1990 Ukraine 1990 NA 27.664671
## Ukraine-2000 Ukraine 2000 28.2030972 60.297057
## Ukraine-2010 Ukraine 2010 9.3729311 46.456538
## Ukraine-2020 Ukraine 2020 2.7324921 38.821646
## United States-1990 United States 1990 5.3979564 9.254732
## United States-2000 United States 2000 3.3768573 10.692777
## United States-2010 United States 2010 1.6400434 12.341361
## United States-2020 United States 2020 1.2335844 10.209229
## NV.IND.MANF.ZS
## China-1990 NA
## China-2000 NA
## China-2010 31.61282
## China-2020 26.28517
## Iran, Islamic Rep.-1990 14.51243
## Iran, Islamic Rep.-2000 16.63923
## Iran, Islamic Rep.-2010 12.78391
## Iran, Islamic Rep.-2020 21.13949
## Ukraine-1990 NA
## Ukraine-2000 17.38735
## Ukraine-2010 13.09575
## Ukraine-2020 10.10138
## United States-1990 NA
## United States-2000 15.11507
## United States-2010 11.90609
## United States-2020 10.62906
library(skimr)
skim(panel_comercio)
| Name | panel_comercio |
| Number of rows | 16 |
| Number of columns | 5 |
| _______________________ | |
| Column type frequency: | |
| factor | 2 |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: factor
| skim_variable | n_missing | complete_rate | ordered | n_unique | top_counts |
|---|---|---|---|---|---|
| country | 0 | 1 | FALSE | 4 | Chi: 4, Ira: 4, Ukr: 4, Uni: 4 |
| date | 0 | 1 | FALSE | 4 | 199: 4, 200: 4, 201: 4, 202: 4 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| FP.CPI.TOTL.ZG | 1 | 0.94 | 8.25 | 9.43 | 0.35 | 2.58 | 3.38 | 9.73 | 30.59 | ▇▂▁▁▂ |
| NE.EXP.GNFS.ZS | 0 | 1.00 | 23.34 | 14.36 | 9.25 | 12.42 | 20.16 | 27.31 | 60.30 | ▇▅▁▁▁ |
| NV.IND.MANF.ZS | 4 | 0.75 | 16.77 | 6.56 | 10.10 | 12.56 | 14.81 | 18.33 | 31.61 | ▇▆▂▂▂ |
Tenemos datos ausentes. Los vamos a reemplazar por la media.
#Na's = reemplazar por el promedio
panel_comercio$NV.IND.MANF.ZS[is.na(panel_comercio$NV.IND.MANF.ZS)]<-mean(panel_comercio$NV.IND.MANF.ZS,na.rm=TRUE)
panel_comercio$FP.CPI.TOTL.ZG [is.na(panel_comercio$FP.CPI.TOTL.ZG)]<-mean(panel_comercio$FP.CPI.TOTL.ZG
,na.rm=TRUE)
panel_comercio
## country date FP.CPI.TOTL.ZG NE.EXP.GNFS.ZS
## China-1990 China 1990 3.0522901 12.451603
## China-2000 China 2000 0.3478112 20.893697
## China-2010 China 2010 3.1753248 27.185333
## China-2020 China 2020 2.4194219 18.586139
## Iran, Islamic Rep.-1990 Iran, Islamic Rep. 1990 7.6276749 13.278742
## Iran, Islamic Rep.-2000 Iran, Islamic Rep. 2000 14.4767513 21.467058
## Iran, Islamic Rep.-2010 Iran, Islamic Rep. 2010 10.0893629 24.399653
## Iran, Islamic Rep.-2020 Iran, Islamic Rep. 2020 30.5941390 19.424609
## Ukraine-1990 Ukraine 1990 8.2493159 27.664671
## Ukraine-2000 Ukraine 2000 28.2030972 60.297057
## Ukraine-2010 Ukraine 2010 9.3729311 46.456538
## Ukraine-2020 Ukraine 2020 2.7324921 38.821646
## United States-1990 United States 1990 5.3979564 9.254732
## United States-2000 United States 2000 3.3768573 10.692777
## United States-2010 United States 2010 1.6400434 12.341361
## United States-2020 United States 2020 1.2335844 10.209229
## NV.IND.MANF.ZS
## China-1990 16.76731
## China-2000 16.76731
## China-2010 31.61282
## China-2020 26.28517
## Iran, Islamic Rep.-1990 14.51243
## Iran, Islamic Rep.-2000 16.63923
## Iran, Islamic Rep.-2010 12.78391
## Iran, Islamic Rep.-2020 21.13949
## Ukraine-1990 16.76731
## Ukraine-2000 17.38735
## Ukraine-2010 13.09575
## Ukraine-2020 10.10138
## United States-1990 16.76731
## United States-2000 15.11507
## United States-2010 11.90609
## United States-2020 10.62906
skim(panel_comercio)
| Name | panel_comercio |
| Number of rows | 16 |
| Number of columns | 5 |
| _______________________ | |
| Column type frequency: | |
| factor | 2 |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: factor
| skim_variable | n_missing | complete_rate | ordered | n_unique | top_counts |
|---|---|---|---|---|---|
| country | 0 | 1 | FALSE | 4 | Chi: 4, Ira: 4, Ukr: 4, Uni: 4 |
| date | 0 | 1 | FALSE | 4 | 199: 4, 200: 4, 201: 4, 202: 4 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| FP.CPI.TOTL.ZG | 0 | 1 | 8.25 | 9.11 | 0.35 | 2.65 | 4.39 | 9.55 | 30.59 | ▇▃▁▁▂ |
| NE.EXP.GNFS.ZS | 0 | 1 | 23.34 | 14.36 | 9.25 | 12.42 | 20.16 | 27.31 | 60.30 | ▇▅▁▁▁ |
| NV.IND.MANF.ZS | 0 | 1 | 16.77 | 5.62 | 10.10 | 13.02 | 16.70 | 16.92 | 31.61 | ▅▇▁▁▁ |
GRÁFICOS DE HETEROGENEIDAD
# PLOTMEANS
#-------------------------------------
plotmeans(NE.EXP.GNFS.ZS ~ country, data = panel_comercio,
main = "Heterogeneidad entre países",
xlab = "País", ylab = "Exportación",
barcol = "blue")
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
Existen diferencias en media entre los países de la muestra.
plotmeans(NE.EXP.GNFS.ZS ~ date, data = panel_comercio,
main = "Heterogeneidad entre años",
xlab = "años", ylab = "Exportación",
barcol = "red")
En el año 2000 se produjo el máximo en índice de exportaciones y a
partir de este año ha ido descendiendo hasta 20.
# PLOTMEANS
#-------------------------------------
plotmeans(FP.CPI.TOTL.ZG ~ country, data = panel_comercio,
main = "Heterogeneidad entre países",
xlab = "País", ylab = "Inflación",
barcol = "blue")
Irán y Ucrania tiene un índice de inflación muy superior al resto.
plotmeans(FP.CPI.TOTL.ZG ~ date, data = panel_comercio,
main = "Heterogeneidad entre años",
xlab = "Años", ylab = "Inflación",
barcol = "red")
La media de la inflación es similar en cada uno de los años.
plotmeans(NV.IND.MANF.ZS ~ country, data = panel_comercio,
main = "Heterogeneidad entre países",
xlab = "País", ylab = "Industrialización",
barcol = "blue")
El índice de industrialización es superior en China e Irán respecto al
resto.
plotmeans(NV.IND.MANF.ZS ~ date, data = panel_comercio,
main = "Heterogeneidad entre países",
xlab = "años", ylab = "Industrialización",
barcol = "red")
El índice de industrialización es similar en los cuatro años.
REGRESIÓN AGRUPADA O POOLED
pooled <- plm(NE.EXP.GNFS.ZS ~NV.IND.MANF.ZS + FP.CPI.TOTL.ZG, data = panel_comercio, model= "pooling")
summary(pooled)
## Pooling Model
##
## Call:
## plm(formula = NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG,
## data = panel_comercio, model = "pooling")
##
## Balanced Panel: n = 4, T = 4, N = 16
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -20.3587 -8.7484 -3.7500 5.6762 21.8281
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## (Intercept) 19.32268 11.13593 1.7352 0.10634
## NV.IND.MANF.ZS -0.13559 0.62589 -0.2166 0.83186
## FP.CPI.TOTL.ZG 0.76246 0.38585 1.9761 0.06976 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 3093.4
## Residual Sum of Squares: 2378.9
## R-Squared: 0.231
## Adj. R-Squared: 0.11269
## F-statistic: 1.95251 on 2 and 13 DF, p-value: 0.18135
Constante = 19,32. El índice de exportaciones independiente del valor de la inflación y del índice de industrialización es de 19,32 unidades. El coeficiente tiene un p valor de 0,1063, siendo superior a los niveles del 1%, 5% y 10%. El coeficiente de la constante es similar al valor cero (acepta H0).
Industria = -0,13. Se estima que un aumento en el índice de industris de una unidad, con el resto de factores constantes, provocaría un descenso del índice de exportaciones de 0,13 unidades. El coeficiente tiene un p valor de 0,83816, siendo superior a los niveles del 1%, 5% y 10%. El coeficiente de la constante es similar al valor cero (acepta H0). La variable industrialización es irrelevante para determinar el nivel de exportaciones.
Inflación = 0,76. Se estima que un incremento de la inflación de una unidad, con el resto de variables constantes, provocaría un incremento de las exportacioned de 0,76 unidades. El p-valor en este caso es de 0,06, indicando que al nivel del 10% sería una variable relevnte, pero no al 5% ni al 1%.
EFECTOS FIJOS
within <- plm(NE.EXP.GNFS.ZS ~NV.IND.MANF.ZS + FP.CPI.TOTL.ZG, data = panel_comercio, model = "within")
summary(within)
## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG,
## data = panel_comercio, model = "within")
##
## Balanced Panel: n = 4, T = 4, N = 16
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -13.49706 -2.17112 0.51032 3.02790 8.29901
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## NV.IND.MANF.ZS -0.013969 0.530951 -0.0263 0.9795
## FP.CPI.TOTL.ZG 0.543505 0.322619 1.6847 0.1230
##
## Total Sum of Squares: 746.1
## Residual Sum of Squares: 541.05
## R-Squared: 0.27483
## Adj. R-Squared: -0.087758
## F-statistic: 1.89492 on 2 and 10 DF, p-value: 0.20054
within$coefficients
## NV.IND.MANF.ZS FP.CPI.TOTL.ZG
## -0.01396916 0.54350463
pFtest(within, pooled) #¿Efectos fijos relevantes?
##
## F test for individual effects
##
## data: NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG
## F = 11.323, df1 = 3, df2 = 10, p-value = 0.001483
## alternative hypothesis: significant effects
H0: la constante de cada país es similar alfa1 = alfa2 = alfa3 = alfa4 (la constante de todos los países es similar)[POOLED]
H1: La constante de cada país es diferente.
El p-valor = 0,001 < 0,05. Tenemos evidencia empírica para rechazar H0 al 1%, al 5% y al 10%. Por tanto, las constantes son diferentes, indicando que el modelo pooled es inconsistente, pues no capta la heterogeneidad inobservable entre países.
MODELO RANDOM EFFECTS 1
walhus <- plm(NE.EXP.GNFS.ZS ~NV.IND.MANF.ZS + FP.CPI.TOTL.ZG, data = panel_comercio, model= "random", random.method = "walhus")
summary(walhus)
## Oneway (individual) effect Random Effect Model
## (Wallace-Hussain's transformation)
##
## Call:
## plm(formula = NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG,
## data = panel_comercio, model = "random", random.method = "walhus")
##
## Balanced Panel: n = 4, T = 4, N = 16
##
## Effects:
## var std.dev share
## idiosyncratic 47.251 6.874 0.318
## individual 101.428 10.071 0.682
## theta: 0.677
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -11.3695 -4.6894 -0.8683 5.5393 13.3124
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 19.522835 9.587209 2.0363 0.04172 *
## NV.IND.MANF.ZS -0.064129 0.500120 -0.1282 0.89797
## FP.CPI.TOTL.ZG 0.592957 0.304645 1.9464 0.05161 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 990.96
## Residual Sum of Squares: 737.68
## R-Squared: 0.25559
## Adj. R-Squared: 0.14107
## Chisq: 4.46357 on 2 DF, p-value: 0.10734
amemiya <- plm(NE.EXP.GNFS.ZS ~NV.IND.MANF.ZS + FP.CPI.TOTL.ZG, data = panel_comercio, model= "random", random.method = "amemiya")
summary(amemiya)
## Oneway (individual) effect Random Effect Model
## (Amemiya's transformation)
##
## Call:
## plm(formula = NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG,
## data = panel_comercio, model = "random", random.method = "amemiya")
##
## Balanced Panel: n = 4, T = 4, N = 16
##
## Effects:
## var std.dev share
## idiosyncratic 45.087 6.715 0.296
## individual 107.467 10.367 0.704
## theta: 0.6919
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -11.19960 -4.57480 -0.81202 5.56180 13.10955
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 19.49533 9.67140 2.0158 0.04382 *
## NV.IND.MANF.ZS -0.06062 0.49747 -0.1219 0.90301
## FP.CPI.TOTL.ZG 0.58916 0.30297 1.9446 0.05182 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 968.93
## Residual Sum of Squares: 720.09
## R-Squared: 0.25682
## Adj. R-Squared: 0.14248
## Chisq: 4.49229 on 2 DF, p-value: 0.10581
nerlove <- plm(NE.EXP.GNFS.ZS ~NV.IND.MANF.ZS + FP.CPI.TOTL.ZG, data = panel_comercio, model= "random", random.method = "nerlove")
summary(nerlove)
## Oneway (individual) effect Random Effect Model
## (Nerlove's transformation)
##
## Call:
## plm(formula = NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG,
## data = panel_comercio, model = "random", random.method = "nerlove")
##
## Balanced Panel: n = 4, T = 4, N = 16
##
## Effects:
## var std.dev share
## idiosyncratic 33.816 5.815 0.176
## individual 158.318 12.582 0.824
## theta: 0.7749
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -10.29388 -3.93960 -0.47956 5.00513 11.93748
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 19.33851 10.64463 1.8167 0.06926 .
## NV.IND.MANF.ZS -0.04169 0.48394 -0.0861 0.93135
## FP.CPI.TOTL.ZG 0.56969 0.29442 1.9350 0.05300 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 865.09
## Residual Sum of Squares: 636.95
## R-Squared: 0.26371
## Adj. R-Squared: 0.15044
## Chisq: 4.65618 on 2 DF, p-value: 0.097482
HAUSMAN TEST
PANEL, PASOS:
1.- Comparar entre pooled y FE/RE —- FE 2.- Comparar FE/RE ¿cuál es mejor? —- Test de Hausman
H0: El modelo de RE es consistente y no hace falta estimar por FE. H1: El modleo de RE es inconsistente y sí hace falta estimar por FE.
#HT1
#------------------------
phtest(walhus, within)
##
## Hausman Test
##
## data: NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG
## chisq = 0.12456, df = 2, p-value = 0.9396
## alternative hypothesis: one model is inconsistent
P-valor = 0,93 > 0,05 — acepta H0 —- RE Walhus es consistente (mejor)
#HT2
#----------------------------
phtest(amemiya, within)
##
## Hausman Test
##
## data: NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG
## chisq = 0.60266, df = 2, p-value = 0.7398
## alternative hypothesis: one model is inconsistent
P-valor = 0,73 > 0,05 — acepta H0 —- RE Amemiya es consistente (mejor)
#HT3
#----------------------------
phtest(nerlove, within)
##
## Hausman Test
##
## data: NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG
## chisq = 0.039574, df = 2, p-value = 0.9804
## alternative hypothesis: one model is inconsistent
P valor = 0,98 > 0,05 – acepto H0 — RE Nerlove es consistente (mejor)
R2 ajustado WALHUS = 0.14107
R2 ajustado AMEMIYA = 0.14248
R2 ajustado NERLOVE = 0.15044 – La mejor estimación y más consistente es la del método NERLOVE.
final <- plm(NE.EXP.GNFS.ZS ~NV.IND.MANF.ZS + FP.CPI.TOTL.ZG, data = panel_comercio, model= "random", random.method = "nerlove")
summary(final)
## Oneway (individual) effect Random Effect Model
## (Nerlove's transformation)
##
## Call:
## plm(formula = NE.EXP.GNFS.ZS ~ NV.IND.MANF.ZS + FP.CPI.TOTL.ZG,
## data = panel_comercio, model = "random", random.method = "nerlove")
##
## Balanced Panel: n = 4, T = 4, N = 16
##
## Effects:
## var std.dev share
## idiosyncratic 33.816 5.815 0.176
## individual 158.318 12.582 0.824
## theta: 0.7749
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -10.29388 -3.93960 -0.47956 5.00513 11.93748
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 19.33851 10.64463 1.8167 0.06926 .
## NV.IND.MANF.ZS -0.04169 0.48394 -0.0861 0.93135
## FP.CPI.TOTL.ZG 0.56969 0.29442 1.9350 0.05300 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 865.09
## Residual Sum of Squares: 636.95
## R-Squared: 0.26371
## Adj. R-Squared: 0.15044
## Chisq: 4.65618 on 2 DF, p-value: 0.097482
Constante = 19,33. Se estima que la constante del modelo, independientemente de la industrialización y de la inflación, sea de 19,33 unidades. El coeficiente es significativo al 10%, ya que su p-valor es 0,069 < 0,10.
Industrialización = -0,04. Al aumentar el índice de industrialización en una unidad, con lo demás constante, provocaría que el índice de exportaciones disminuya en 0,04 unidades. El coeficiente es irrelevante, pues el p-valor (0,93) es mayor al 10%.
Inflación = 0,56. Al aumentar el índice de industrialización en una unidad, con lo demás constante, provocaría que el índice de exportaciones disminuya en 0,56 unidades. El coeficiente es relevante, pues el p-valor (0,053) es inferior al 10%.
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
stargazer(pooled, within, walhus, amemiya, final, type = "text")
##
## ===============================================================================
## Dependent variable:
## ----------------------------------------------------------------
## NE.EXP.GNFS.ZS
## (1) (2) (3) (4) (5)
## -------------------------------------------------------------------------------
## NV.IND.MANF.ZS -0.136 -0.014 -0.064 -0.061 -0.042
## (0.626) (0.531) (0.500) (0.497) (0.484)
##
## FP.CPI.TOTL.ZG 0.762* 0.544 0.593* 0.589* 0.570*
## (0.386) (0.323) (0.305) (0.303) (0.294)
##
## Constant 19.323 19.523** 19.495** 19.339*
## (11.136) (9.587) (9.671) (10.645)
##
## -------------------------------------------------------------------------------
## Observations 16 16 16 16 16
## R2 0.231 0.275 0.256 0.257 0.264
## Adjusted R2 0.113 -0.088 0.141 0.142 0.150
## F Statistic 1.953 (df = 2; 13) 1.895 (df = 2; 10) 4.464 4.492 4.656*
## ===============================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
CONCLUSIONES
El mejor modelo como hemos comentado es el modelo (5), que obtiene las estimaciones más precisas y correctas.