Regina Enríquez Chapa A01721435
Maximiliano Carvajal A01552179
Guillermo Cazares Cruz A01283709
library(WDI)
library(wbstats)
library(tidyverse)
## -- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --
## v dplyr 1.1.0 v readr 2.1.2
## v forcats 1.0.0 v stringr 1.5.0
## v ggplot2 3.4.1 v tibble 3.1.8
## v lubridate 1.9.3 v tidyr 1.3.0
## v purrr 1.0.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## i Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(gplots)
##
## Attaching package: 'gplots'
##
## The following object is masked from 'package:stats':
##
## lowess
library(plm)
##
## Attaching package: 'plm'
##
## The following objects are masked from 'package:dplyr':
##
## between, lag, lead
climate_change <- wb_data(country=c("MX","NO","FI","SE","DK"), indicator=c("EN.ATM.CO2E.KT","EG.FEC.RNEW.ZS","SP.URB.TOTL.IN.ZS","AG.LND.AGRI.ZS"), start_date=1950, end_date = 2020)
climate_change_periodic <- subset(climate_change, date == 1990 | date == 2000 | date == 2010 | date == 2020)
climate_change_periodic <- pdata.frame(climate_change_periodic, index = c("country","date"))
plotmeans(EG.FEC.RNEW.ZS ~ country, data = climate_change_periodic, xlab = "Países", ylab = "Consumo de energía renovable (%)", main = "Heterogeneidad entre países", mean.labels = FALSE)
plotmeans(EG.FEC.RNEW.ZS ~ date, data = climate_change_periodic, xlab = "Años", ylab = "Consumo de energía renovable (%)", main = "Heterogeneidad entre años", mean.labels = FALSE)
Variables:
pooled <- plm(EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS, data = climate_change_periodic, model = "pooling")
summary(pooled)
## Pooling Model
##
## Call:
## plm(formula = EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS +
## AG.LND.AGRI.ZS, data = climate_change_periodic, model = "pooling")
##
## Balanced Panel: n = 5, T = 4, N = 20
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -21.0579 -9.1215 1.5252 8.3077 19.4014
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## (Intercept) 6.6920e+01 5.2745e+01 1.2688 0.222678
## EN.ATM.CO2E.KT -4.8978e-05 2.5891e-05 -1.8917 0.076779 .
## SP.URB.TOTL.IN.ZS -1.9257e-01 6.3960e-01 -0.3011 0.767230
## AG.LND.AGRI.ZS -4.3226e-01 1.1559e-01 -3.7396 0.001786 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 7001.9
## Residual Sum of Squares: 2093.7
## R-Squared: 0.70098
## Adj. R-Squared: 0.64492
## F-statistic: 12.5029 on 3 and 16 DF, p-value: 0.00018278
within <- plm(EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS, data = climate_change_periodic, model = "within")
summary(within)
## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS +
## AG.LND.AGRI.ZS, data = climate_change_periodic, model = "within")
##
## Balanced Panel: n = 5, T = 4, N = 20
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -9.4665 -4.4639 -1.4433 5.8039 13.0689
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## EN.ATM.CO2E.KT -1.2809e-04 5.6772e-05 -2.2562 0.04351 *
## SP.URB.TOTL.IN.ZS 1.3931e+00 7.3104e-01 1.9057 0.08093 .
## AG.LND.AGRI.ZS -1.6306e+00 1.7146e+00 -0.9510 0.36036
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 1268.4
## Residual Sum of Squares: 691.09
## R-Squared: 0.45515
## Adj. R-Squared: 0.13732
## F-statistic: 3.34148 on 3 and 12 DF, p-value: 0.055906
pFtest(within,pooled)
##
## F test for individual effects
##
## data: EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS
## F = 6.0886, df1 = 4, df2 = 12, p-value = 0.006492
## alternative hypothesis: significant effects
Son muy diferentes, no se pueden intercambiar.
walhus <- plm(EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS, data = climate_change_periodic, model = "random", random.method = "walhus")
summary(walhus)
## Oneway (individual) effect Random Effect Model
## (Wallace-Hussain's transformation)
##
## Call:
## plm(formula = EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS +
## AG.LND.AGRI.ZS, data = climate_change_periodic, model = "random",
## random.method = "walhus")
##
## Balanced Panel: n = 5, T = 4, N = 20
##
## Effects:
## var std.dev share
## idiosyncratic 79.485 8.915 0.759
## individual 25.200 5.020 0.241
## theta: 0.336
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -16.1471 -8.5619 1.2411 5.9506 17.9110
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) 2.4120e+01 5.1083e+01 0.4722 0.6367978
## EN.ATM.CO2E.KT -4.0618e-05 2.8544e-05 -1.4230 0.1547456
## SP.URB.TOTL.IN.ZS 3.3143e-01 6.1918e-01 0.5353 0.5924661
## AG.LND.AGRI.ZS -4.6303e-01 1.4025e-01 -3.3015 0.0009617 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 3796.2
## Residual Sum of Squares: 1521.1
## R-Squared: 0.59931
## Adj. R-Squared: 0.52418
## Chisq: 23.9313 on 3 DF, p-value: 2.5819e-05
amemiya <- plm(EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS, data = climate_change_periodic, model = "random", random.method = "amemiya")
summary(amemiya)
## Oneway (individual) effect Random Effect Model
## (Amemiya's transformation)
##
## Call:
## plm(formula = EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS +
## AG.LND.AGRI.ZS, data = climate_change_periodic, model = "random",
## random.method = "amemiya")
##
## Balanced Panel: n = 5, T = 4, N = 20
##
## Effects:
## var std.dev share
## idiosyncratic 46.073 6.788 0.028
## individual 1624.149 40.301 0.972
## theta: 0.9161
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -8.8523 -4.7937 -1.7098 5.8322 13.9319
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) -6.1390e+01 5.6670e+01 -1.0833 0.27868
## EN.ATM.CO2E.KT -1.1019e-04 4.8273e-05 -2.2825 0.02246 *
## SP.URB.TOTL.IN.ZS 1.4989e+00 5.9081e-01 2.5370 0.01118 *
## AG.LND.AGRI.ZS -5.3496e-01 6.3082e-01 -0.8480 0.39641
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 1308.8
## Residual Sum of Squares: 761.35
## R-Squared: 0.41828
## Adj. R-Squared: 0.3092
## Chisq: 11.5045 on 3 DF, p-value: 0.0092885
nerlove <- plm(EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS, data = climate_change_periodic, model = "random", random.method = "nerlove")
summary(nerlove)
## Oneway (individual) effect Random Effect Model
## (Nerlove's transformation)
##
## Call:
## plm(formula = EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS +
## AG.LND.AGRI.ZS, data = climate_change_periodic, model = "random",
## random.method = "nerlove")
##
## Balanced Panel: n = 5, T = 4, N = 20
##
## Effects:
## var std.dev share
## idiosyncratic 34.555 5.878 0.017
## individual 2044.584 45.217 0.983
## theta: 0.9351
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -8.1316 -5.3145 -1.5510 5.8629 14.0382
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) -5.9767e+01 6.1306e+01 -0.9749 0.32961
## EN.ATM.CO2E.KT -1.1558e-04 4.8847e-05 -2.3661 0.01798 *
## SP.URB.TOTL.IN.ZS 1.5195e+00 5.9493e-01 2.5541 0.01065 *
## AG.LND.AGRI.ZS -6.3356e-01 7.6253e-01 -0.8309 0.40605
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 1292.5
## Residual Sum of Squares: 743.06
## R-Squared: 0.42511
## Adj. R-Squared: 0.31732
## Chisq: 11.8314 on 3 DF, p-value: 0.0079835
phtest(amemiya,within)
##
## Hausman Test
##
## data: EG.FEC.RNEW.ZS ~ EN.ATM.CO2E.KT + SP.URB.TOTL.IN.ZS + AG.LND.AGRI.ZS
## chisq = 0.73372, df = 3, p-value = 0.8652
## alternative hypothesis: one model is inconsistent
Debido a la r cuadrada ajustada, el modelo seleccionado es el de efectos aleatorios por el método amemiya.