if (FALSE) {
# Basic usage with default settings
model <- cnorm.shash(age = children$age, score = children$raw_score)
# Custom polynomial degrees for complex developmental pattern
model_complex <- cnorm.shash(
age = adolescents$age,
score = adolescents$vocabulary_score,
mu_degree = 4, # Complex mean trajectory
sigma_degree = 3, # Changing variability pattern
epsilon_degree = 2, # Skewness shifts
delta = 1.3 # Slightly heavy tails
)
# Even more complex model, including a polynomial for the delta parameter
model_complex2 <- cnorm.shash(
age = adolescents$age,
score = adolescents$vocabulary_score,
mu_degree = 4, # Complex mean trajectory
sigma_degree = 3, # Changing variability pattern
epsilon_degree = 2, # Skewness shifts
delta_deree = 2 # Quadratic change for the tail weight
)
# Homogeneous population with light tails
model_selective <- cnorm.shash(
age = gifted$age,
score = gifted$achievement,
delta = 0.8, # Lighter tails for selected population
sigma_degree = 1 # Simple linear variance change
)
# With sampling weights
model_weighted <- cnorm.shash(
age = survey$age,
score = survey$score,
weights = survey$sample_weight
)
# Custom optimization control for difficult convergence
model_robust <- cnorm.shash(
age = mixed$age,
score = mixed$score,
control = list(factr = 1e-6, maxit = 2000),
delta = 1.5
)
# Compare model fit
compare(model_complex, model_complex2)
}
Run the code above in your browser using DataLab