The function pe_param()
is similar to the function getPEF()
of the gamlss package. It plot the partial effect that a particular term has one of the parameters of the distribution or its predictor eta
.
The function pe2_param()
is build for partial effects from two terms and it is suitable to display first order interactions.
pe_param(obj = NULL, term = NULL, data = NULL, n.points = 100,
parameter = c("mu", "sigma", "nu", "tau"),
type = c("parameter", "eta"), scenario = list(),
how = c("median", "last", "fixed"),
col = "darkblue", size = 1.3, name.obj = NULL,
rug.plot = TRUE, rug.col = "gray", rug.size = 0.5,
data.plot = FALSE, data.col = "lightblue",
data.size = 0.1, factor.size = 15,
data.alpha = 0.9, bins = 30,
filled = FALSE, ylim = NULL,
title) pe_1_param(obj = NULL, term = NULL, data = NULL, n.points = 100,
parameter = c("mu", "sigma", "nu", "tau"),
type = c("parameter", "eta"),
how = c("median", "last", "fixed"),
scale.from = c("mean", "median", "none"),
scenario = list(), col = "darkblue", size = 1.3,
name.obj = NULL, data.plot = FALSE,
data.col = "lightblue",data.size = 0.1,
data.alpha = 0.9, rug.plot = TRUE, rug.col = "gray",
rug.size = 0.5, factor.size = 15,
ylim = NULL, title)
pe_2_param(obj = NULL, terms = NULL, data = NULL, n.points = 100,
parameter = c("mu", "sigma", "nu", "tau"),
type = c("parameter", "eta"),
how = c("median", "last", "fixed"),
scenario = list(), col = "darkblue",
size = 1.3, data.plot = TRUE,
data.col = "lightblue", data.size = 0.1,
data.alpha = 0.9,bins = 30,
filled = FALSE, name.obj = NULL, title)
pe_param_grid(model, terms, maxcol = 2, maxrow = 3, ylim=NULL, ...)
It is plotting the partial effect or is producing the resulting function
a GAMLSS fitted object
a GAMLSS fitted model
the model term we want to investigate can be one i.e. "Fl" or two c("Fl", "A")
a list of model terms for example
list(c("Fl","A"), "H", "loc" ))
the data frame used otherwise it takes it from the fitted model
the number of points for the evaluation of the term
the distribution parameter in which the term is fitted
here you specify or the distribution parameter i.e "parameter"
or its prediction, "eta"
how to set all the other terms in the model
this can be a list of values for the rest of the terms in the model for the distribution parameter
whether to plot the result
the colour of the partial effect of the term
the size of the line of partial effect of the term
the number of binds for the contour plot
whether to display the values in the contour
the title if different from the default
this is a way to pass the name of the object
the maximum columns in the grid plot
the maximum rowss in the grid plot
whether to plot the data
whether to print the rug bellow the figure
the size of the rug
the colour of the rug
the color of the data points
the size of the data points
the trnsparance constant of the data points
the size of the symbol if a factor is plotted
if a common y limit is required
whethet to substact from the mean the median or from zero
for passing argument from the function pe_param_grid
to the function pe_param
Mikis Stasinopulos, Rober Rigby and Fernanda de Bastiani
The functions pe_param()
and pe_param_grid()
can be used to help the use the interpretation of a GAMLSS model.
The functions pe_param()
provides the partial effect of one or two terms of a specified parameter of the distribution while the rest of the terms in the model are set on specific values or scenarios. The function pe_param()
calls pe_1param()
if the argument terms is one i.e. "Fl" or the function
pe_2param()
if the terms are two i.e. c("Fl"","A").
The pe_param_grid()
plots multiple plots specified by the list used in the term
argument.
Similar functions are
pe_quantile()
and pe_moment()
.
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. 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/).
getPEF
m1 <- gamlss(R~pb(Fl)+pb(A)+loc+H, data=rent, gamily=GA)
pe_param(m1, "A")
pe_param(m1, c("Fl","A"), filled=TRUE)
pe_param_grid(m1, list(c("Fl","A"), c("H","loc")), filled=TRUE)
# the terms are additive no interaction
Run the code above in your browser using DataLab