family_pdf {gamlss.ggplots} | R Documentation |
Plotting Probabilities Density Functions (pdf's) for GAMLSS
Description
The function family_pdf()
takes a GAMLSS family distribution and plots different pdf's according to the specified parameters.
The function fitted_pdf()
takes a gamlss fitted object and plots the fitted distributions for specified observations.
The function fitted_pdf_data()
it does the same as fitted_pdf()
but it adds also the observation values as grey vertical lines.
The function predict_pdf()
takes a fitted object and test data and plots the predictive pdf's.
Usage
family_pdf(family = NO(), mu = NULL, sigma = NULL, nu = NULL, tau = NULL,
title, from = 0, to = 10, no.points = 201,
alpha = 0.4, col.fill = hcl.colors(lobs, palette = "viridis"),
size.seqment = 1.5, plot.point = TRUE, size.point = 1,
plot.line = TRUE, size.line = 0.2, ...)
fitted_pdf(model, obs, title, from = 0, to = 10, no.points = 201, alpha = 0.4,
col.fill = hcl.colors(lobs, palette = "viridis"),
size.seqment = 1.5, plot.point = TRUE, size.point = 1, plot.line = TRUE,
size.line = 0.2, ...)
fitted_pdf_data(model, obs, from, to, ...)
predict_pdf(model, newdata, title, from = 0, to = 10, no.points = 201,
alpha = 0.4, col.fill = hcl.colors(lobs, palette = "viridis"),
size.seqment = 1.5, plot.point = TRUE, size.point = 1,
plot.line = TRUE, size.line = 0.2, ...)
Arguments
family |
A GAMLSS family |
model |
A GAMLSS fitted model |
obs |
observations to plot fitted distributions |
newdata |
for test data |
mu |
the |
sigma |
the |
nu |
the |
tau |
the |
title |
a diferent title for the default |
from |
minimum value for the response |
to |
maximum value for the response |
no.points |
number of points (relevant for continuous responses) |
alpha |
trasparency factor |
col.fill |
the colour pallet default is |
size.seqment |
for discrete responses the size of the bars |
plot.point |
for discrete responses whether to put poits on the top of the bars |
size.point |
for discrete responses |
plot.line |
for discrete responses whether to joint the bars with lines |
size.line |
for discrete responses the size of the joining lines |
... |
for extra argumnets |
Details
The functions family_pdf()
and fitted_pdf()
are ggplot version of the function pdf.plot()
used to plot fitted distributions of GAMLSS family at specified observation values. Note that the range of the response has to be specified using the argument from
to
.
For discrete fitted distributions maybe increase the value of alpha
for clearer plot.
For binomial type of data (discrete response with upper limit) the function family_pdf()
takes the argument to
as the binomial denominator,
For fitted model with binomial type responses the function fitted_pdf()
takes the binomial denominator form the fitted model and set the argument to
to the maximum of those binomial denominators.
Value
Creates a plot
Author(s)
Mikis Stasinopoulos, Bob Rigby and Fernanda De Bastiani
References
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/).
See Also
Examples
###################################
# function fitted_pdf
# continuous variabe
a1 <- gamlss(y~pb(x),sigma.fo=~pb(x), data=abdom, family=LO)
fitted_pdf(a1, obs=c(10,15,20), from=30, to=100)
# count data
p1 <- gamlss(y~pb(x)+qrt, data=aids, family=NBI)
fitted_pdf(p1, obs=c(10:15), from=25, to=130, alpha=.9)
# binomial type
h<-gamlss(y~ward+loglos+year, sigma.formula=~year+ward, family=BB, data=aep)
fitted_pdf(h, obs=c(10:15), alpha=.9)
###################################
# function predict_pdf
predict_pdf(a1, newdata=abdom[10:20, ], from=30, to=100)
# count data
predict_pdf(p1, newdata=aids[10:15, ], from=30, to=150)
# binomial
predict_pdf(h, newdata=aep[10:15, ], from=0, to=20)
###################################
# function family_pdf
# continuous
family_pdf(from=-5,to=5, mu=0, sigma=c(.5,1,2))
# count data
family_pdf(NBI, to=15, mu=1, sigma=c(.5,1,2), alpha=.9, size.seqment = 3)
# binomial type
family_pdf(BB, to=15, mu=.5, sigma=c(.5,1,2), alpha=.9, , size.seqment = 3)