## Data set: renewables2015 (for description, run ?renewables2015)
plot(ecdf(renewables2015$renew_elec_output), cex = 0.3, main = "Empirical CDF")
abline(h = mean(renewables2015$renew_elec_output == 0), col = "grey", lty = 3)
text(1250, 0.155, paste0("prop. of zeros: ~0.12"), col = "blue")
plot(renew_elec_output ~ adj_sav_edu, renewables2015, pch = 16,
xlab = "Education expenditure (percent of GNI)",
ylab = "Renewable electricity output (in TWh)")
plot(renew_elec_output ~ agri_land, renewables2015, pch = 16,
xlab = "Matural logarithm of total agricultural land area",
ylab = "Renewable electricity output (in TWh)")
## Fit a zero-adjusted Box-Cox normal regression
fit <- BCSreg(renew_elec_output ~ adj_sav_edu + agri_land |
adj_sav_edu + agri_land |
adj_sav_edu + agri_land, renewables2015)
## coef
coef(fit) # regression coefficients of the scale submodel
coef(fit, model = "sigma") # regression coefficients of the relative dispersion submodel
coef(fit, model = "alpha") # regression coefficients of the zero-adjustment submodel
coef(fit, model = "full") # all regression coefficients
## vcov
vcov(fit) # covariance matrix for the scale submodel coefficients
vcov(fit, model = "sigma") # covariance matrix for the relative dispersion submodel coefficients
vcov(fit, model = "alpha") # covariance matrix for the zero-adjustment submodel coefficients
vcov(fit, model = "full") # full covariance matrix of the model (including the skewness parameter)
## Log-likelihood value
logLik(fit)
## AIC and BIC
AIC(fit)
AIC(fit, k = log(fit$nobs))
## Model matrices
model.matrix(fit) # design matrix for the scale submodel
model.matrix(fit, model = "sigma") # design matrix for the relative dispersion submodel
model.matrix(fit, model = "alpha") # design matrix for the zero-adjustment submodel
Run the code above in your browser using DataLab