I have fitted a model with
m0 <- lms(weight,age, data=df)
After, I use the model to predict percentiles for same ages:
newages <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
centiles.pred(m0, xname="age", xvalues= newages, cent= c(5,25,50,75,95))
Is it possible to estimate the error of the percentiles predicted? How?
Below a reproducible examples with data include in the gamlss package:
library("gamlss")
library("gamlss.data")
data("dbbmi")
m0 <- lms(bmi,age, data=dbbmi, trans.x=TRUE, k=2)
newages <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
percentiles <- centiles.pred(m0, xname="age", xvalues= newages, cent= c(5,25,50,75,95))
In principle, you could try bootstrapping them. I would parallelize the code since the package is rather slow. On Linux we can conveniently use
parallel::mclapply, which is the parallel version oflapply. We might silence the function a little usingcapture.output. I demonstrate this with example from?centiles.pred.Using
simplify2arraygives us an"array"on which we canapplysdto get bootstrap standard errors,which we can put into a neat list.