# \donttest{
require(gkwreg)
require(gkwdist)
data(ReadingSkills)
# Example 1: Standard Kumaraswamy with interaction and heteroscedasticity
# Mean: Dyslexia × IQ interaction (do groups differ in IQ effect?)
# Precision: Main effects (variability differs by group and IQ level)
fit_kw <- gkwreg(
accuracy ~ dyslexia * iq |
dyslexia + iq,
data = ReadingSkills,
family = "kw",
control = gkw_control(method = "L-BFGS-B", maxit = 2000)
)
summary(fit_kw)
# Interpretation:
# - Alpha (mean): Interaction shows dyslexic children benefit less from
# higher IQ compared to controls
# - Beta (precision): Controls show more variable accuracy (higher precision)
# IQ increases consistency of performance
# Example 2: Simpler model without interaction
fit_kw_simple <- gkwreg(
accuracy ~ dyslexia + iq |
dyslexia + iq,
data = ReadingSkills,
family = "kw",
control = gkw_control(method = "L-BFGS-B", maxit = 2000)
)
# Test if interaction is significant
anova(fit_kw_simple, fit_kw)
# Example 3: Exponentiated Kumaraswamy for ceiling effects
# Reading accuracy often shows ceiling effects (many perfect/near-perfect scores)
# Lambda parameter can model this right-skewed asymmetry
fit_ekw <- gkwreg(
accuracy ~ dyslexia * iq | # alpha
dyslexia + iq | # beta
dyslexia, # lambda: ceiling effect by group
data = ReadingSkills,
family = "ekw",
control = gkw_control(method = "L-BFGS-B", maxit = 2000)
)
summary(fit_ekw)
# Interpretation:
# - Lambda varies by dyslexia status: Controls have stronger ceiling effect
# (more compression at high accuracy) than dyslexic children
# Test if ceiling effect modeling improves fit
anova(fit_kw, fit_ekw)
# Example 4: McDonald distribution alternative
# Provides different parameterization for extreme values
fit_mc <- gkwreg(
accuracy ~ dyslexia * iq | # gamma
dyslexia + iq | # delta
dyslexia * iq, # lambda: interaction affects tails
data = ReadingSkills,
family = "mc",
control = gkw_control(method = "L-BFGS-B", maxit = 2000)
)
summary(fit_mc)
# Compare 3-parameter models
AIC(fit_ekw, fit_mc)
# }
Run the code above in your browser using DataLab