The function resid_density()
plots an histogram and a density estimator of the normalised quantile residuals from a fitted GAMLSS model. The function model_density()
plots density estimators of the normalised quantile residuals from more than one fitted GAMLSS models.
resid_density(obj, resid, hist.col = "black", hist.fill = "white",
dens.fill = "#FF6666", title)
model_density(obj, ..., title)
A density plot of the residuals is produced.
The function needs a GAMLSS fitted model or
any standarised residual
The colour of the border of the histogram
The colout of the hisogram
the colour of the desnsity
A title if needed
extra GAMLSS models
Mikis Stasinopoulos, Bob Rigby and Fernanda De Bastiani
This function resid_density()
is a denity plot (similar to of the four plots produded when the plotting function plot.gamlss()
is used within the gamlss package.
I uses plotting function from the ggplot2 package.
Rigby, R. A., Stasinopoulos, D. M., Heller, G. Z., and De Bastiani, F. (2019) Distributions for modeling location, scale, and shape: Using GAMLSS in R, Chapman and Hall/CRC. An older version can be found in https://www.gamlss.com/.
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, https://www.jstatsoft.org/v23/i07/.
Stasinopoulos D. M., Rigby R.A., Heller G., Voudouris V., and De Bastiani F., (2017) Flexible Regression and Smoothing: Using GAMLSS in R, Chapman and Hall/CRC.
Stasinopoulos, M.D., Kneib, T., Klein, N., Mayr, A. and Heller, G.Z., (2024). Generalized Additive Models for Location, Scale and Shape: A Distributional Regression Approach, with Applications (Vol. 56). Cambridge University Press.
(see also https://www.gamlss.com/).
plot.gamlss
data(abdom)
a<-gamlss(y~pb(x),family=LO,data=abdom)
b<-gamlss(y~pb(x),family=NO,data=abdom)
resid_density(a)
model_density(a,b)
Run the code above in your browser using DataLab