# \donttest{
require(gkwreg)
require(gkwdist)
data(GasolineYield)
# Example 1: Kumaraswamy regression with batch effects
# Model mean yield as function of batch and temperature
# Allow precision to vary with temperature (heteroscedasticity)
fit_kw <- gkwreg(yield ~ batch + temp | temp,
data = GasolineYield,
family = "kw"
)
summary(fit_kw)
# Interpretation:
# - Alpha (mean): Different batches have different baseline yields
# Temperature affects yield transformation
# - Beta (precision): Higher temperatures may produce more variable yields
# Example 2: Full model with all physical-chemical properties
fit_kw_full <- gkwreg(
yield ~ gravity + pressure + temp10 + temp |
temp10 + temp,
data = GasolineYield,
family = "kw"
)
summary(fit_kw_full)
# Interpretation:
# - Mean model captures effects of crude oil properties
# - Precision varies with vaporization temperatures
# Example 3: Exponentiated Kumaraswamy for extreme yields
# Some batches may produce unusually high/low yields
fit_ekw <- gkwreg(
yield ~ batch + temp | # alpha: batch effects
temp | # beta: temperature precision
batch, # lambda: batch-specific tail behavior
data = GasolineYield,
family = "ekw"
)
summary(fit_ekw)
# Interpretation:
# - Lambda varies by batch: Some crude oils have more extreme
# yield distributions (heavy tails for very high/low yields)
# Model comparison: Does tail flexibility improve fit?
anova(fit_kw, fit_ekw)
# Diagnostic plots
par(mfrow = c(2, 2))
plot(fit_kw, which = c(1, 2, 4, 5))
par(mfrow = c(1, 1))
# }
Run the code above in your browser using DataLab