# \donttest{
require(gkwreg)
require(gkwdist)
data(retinal)
# Example 1: Nonlinear time decay with level effects
# Model gas decay as quadratic function of log-time
# Allow precision to vary by initial gas concentration
fit_kw <- gkwreg(
Gas ~ LogT + LogT2 + Level |
Level,
data = retinal,
family = "kw"
)
summary(fit_kw)
# Interpretation:
# - Alpha: Decay curve shape varies by initial gas concentration
# LogT + LogT2 capture nonlinear exponential-like decay
# - Beta: Precision differs by concentration level
# Higher concentration may produce more/less variable decay
# Example 2: Heteroscedastic model
# Variability in gas proportion may change over time
fit_kw_hetero <- gkwreg(
Gas ~ LogT + LogT2 + Level |
Level + LogT,
data = retinal,
family = "kw"
)
summary(fit_kw_hetero)
# Interpretation:
# - Beta: Precision varies with both level and time
# Early measurements may be more variable than late measurements
# Test heteroscedasticity
anova(fit_kw, fit_kw_hetero)
# Example 3: Exponentiated Kumaraswamy for decay tails
# Gas decay may show different tail behavior at extreme time points
# (very fast initial decay or very slow residual decay)
fit_ekw <- gkwreg(
Gas ~ LogT + LogT2 + Level | # alpha: decay curve
Level + LogT | # beta: heteroscedasticity
Level, # lambda: tail heaviness by level
data = retinal,
family = "ekw"
)
summary(fit_ekw)
# Interpretation:
# - Lambda varies by level: Different initial concentrations may have
# different rates of extreme decay (very fast or very slow residual gas)
# - Important for predicting complete absorption time
# Example 4: McDonald distribution for asymmetric decay
# Alternative parameterization for skewed decay patterns
fit_mc <- gkwreg(
Gas ~ LogT + LogT2 + Level | # gamma
LogT + Level | # delta
Level, # lambda
data = retinal,
family = "mc",
control = gkw_control(
method = "BFGS",
maxit = 1500,
reltol = 1e-8
)
)
summary(fit_mc)
# Model comparison
AIC(fit_kw, fit_kw_hetero, fit_ekw, fit_mc)
# }
Run the code above in your browser using DataLab