resid_plot: A residual plots

resid_indexR Documentation

A residual plots

Description

The function resid_index() is plotting the residuals of a GAMLSS fitted model (or any other suitable standardised residual) against the observation number index.

The function resid_mu() plots the residuals against fitted values for mu.

The function resid_median() plots the residuals against fitted median values.

The function resid_param() plots the residuals against any of the GAMLSS fitted parameters, mu, sigma, nu, or tau.

The function resid_quantile() plots the residuals against any fitted quantile.

The function resid_xvar() plots the residuals against an explanatory term.

The function resid_plots() produces a plot similar to the one that the function plot() produce for a GAMLSS model in package gamlss. This is, four plots: a) resid_index()(b) resid_mu(), (c) resid_density() and (d) resid_qqplot().

Residuals above (or below) certain specified value are identified.

Usage

resid_index(obj, resid, plot = TRUE, value = 2, title, annotate = TRUE, 
           no.lines = FALSE)
           
resid_mu(obj, resid, plot = TRUE, value = 2, title, annotate = TRUE)

resid_median(obj, resid, plot = TRUE, value = 3, title, 
            annotate = TRUE)

resid_param(obj, param = c("mu", "sigma", "nu", "tau"), title, 
            line.col = "darkred", point.col = "steelblue4", 
            point.shape = 20)            

resid_quantile(obj, quantile = 0.5, title, newdata, 
            line.col = "darkred", point.col = "steelblue4", 
            point.shape = 20)
            
resid_plots(obj, theme = c("original", "ts", "new", "ecdf"), value = 3)

resid_xvar(obj, xvar, plot = TRUE, value = 2, title, annotate = TRUE)

Arguments

obj

a GAMLSS object

resid

or any other suitable standardised residual vector.

xvar

a continuous explanatory variable

plot

whether to plot the result

param

which GAMLSS parameter mu, sigma, nu, or tau

value

the cut off value for the identification of very large or very small residuals

annotate

whether the threshold annotation should appear or not

line.col

the colour of the line

point.col

the colour of the points

point.shape

the shape of the points

title

a title of the plot if needed

theme

what type of plots should resid_plots() used : "original" is like using plot.gamlss(), "ts" is like using plot.gamlss(,ts="TRUE") (not implemented yet), "new" it uses (a) resid_index(), (b) resid_density(), (c) resid_wp() and (d) resid_dtop().

no.lines

this option allows to hide the horizontal lines so the resulting gg-plot can be used later with say facet_wrap() see example

newdata

whether the evaluation should be in newdata or the old data points

quantile

which quantile? default the median (0.50).

Value

A plot of the residuals is returned.

Author(s)

Mikis Stasinopoulos, Bob Rigby and Fernanda De Bastiani

References

Rigby, R. A. and Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), Appl. Statist., 54, part 3, pp 507-554.

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, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1201/9780429298547")}. 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, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v023.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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1201/b21973")}

Stasinopoulos, M. D., Rigby, R. A., and De Bastiani F., (2018) GAMLSS: a distributional regression approach, Statistical Modelling, Vol. 18, pp, 248-273, SAGE Publications Sage India: New Delhi, India.

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/).

See Also

gamlss, plot.gamlss

Examples

library(ggplot2)
data(rent)
r1<-gamlss(R~pb(Fl)+pb(A)+H+loc,family=GA,data=rent)
resid_index(r1)
resid_mu(r1)
resid_median(r1)
resid_param(r1)
resid_quantile(r1)
resid_xvar(r1, A)
resid_plots(r1)
resid_index(r1, no.lines=TRUE)+facet_wrap(~ cut_number(rent$A, 6))

gamlss.ggplots documentation built on May 29, 2024, 1:34 a.m.