This function can be used to calculate the partial effect and the elasticity of a continuous explanatory variable `x`

.

By `partial effect' function we mean how `x`

is influence the parameter of interest given that the rest of explanatory terms for this parameter are on (specified) fixed values.

The function takes a GAMLSS object and for the range of the continuous variable `x`

,
(by fixing the rest of the explanatory terms at specified values),
calculates the effect that `x`

has on the specific distribution parameter (or its predictor).
The resulting function shows the effect that `x`

has on the distribution parameter.
The partial effect function which is calculated on a finite grit is then approximated using the `splinefun()`

in R and its is saved.

The saved function can be used to calculate the elasticity of `x`

. The elasticity is the first derivative of the partial effect function and shows the chance of the parameter of interest for a small change in in `x`

, by fixing the rest of the explanatory variables at specified values.

```
getPEF(obj = NULL, term = NULL, data = NULL, n.points = 100,
parameter = c("mu", "sigma", "nu", "tau"),
type = c("response", "link"), how = c("median", "last"),
fixed.at = list(), plot = FALSE)
```

A function is created which can be used to evaluate the partial effect function at different values of `x`

.

- obj
A

`gamlss`

object- term
the continuous explanatory variable

- data
the data.frame (not needed if is declared on

`obj`

)- n.points
the number of points in which the influence function for

`x`

need to be evaluated- parameter
which distribution parameter

- type
whether against the parameter,

`"response"`

, or the predictor`"link"`

- how
whether for continuous variables should use the median or the last observation in the data

- fixed.at
a list indicating at which values the rest of the explanatory terms should be fixed

- plot
whether to the plot the influence function and its first derivatives

Mikis Stasinopoulos, Vlasios Voudouris, Daniil Kiose

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. and Stasinopoulos, D. M (2013) Automatic smoothing parameter selection in GAMLSS with an application to centile estimation, *Statistical methods in medical research*.

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.

(see also https://www.gamlss.com/).

`gamlss`

```
m1 <- gamlss(R~pb(Fl)+pb(A), data=rent, family=GA)
# getting the Partial Efect function
pef <- getPEF(obj=m1,term="A", plot=TRUE)
# the value at 1980
pef(1980)
# the first derivative at 1980
pef(1980, deriv=1)
# the second derivative at 1980
pef(1980, deriv=2)
# plotting the first derivative
curve(pef(x, deriv=1), 1900,2000)
```

Run the code above in your browser using DataLab