if (requireNamespace("gamlss", quietly = TRUE)) {
library(gamlss)
sub_df <- data.frame(
age = seq(1, 20, length.out = 100),
height = 50 + 2.5 * seq(1, 20, length.out = 100) + rnorm(100, 0, 5)
)
mdl <- gamlss(height ~ pb(age), data = sub_df, family = NO())
quantile_function <- getQuantileRefactored(
obj = mdl,
term = "age",
quantile = c(0.25, 0.5, 0.75),
data = sub_df
)
}else{
message("The 'gamlss' package is not installed. Please install it to run this example.")
}
Run the code above in your browser using DataLab