fitGEV  R Documentation 
Describe
fitGEV(
formula,
data,
scoring = c("fisher", "quasi"),
mu.link = "identity",
sigma.link = "log",
xi.link = "identity",
stepLength = 1,
stepAttempts = 2,
stepReduce = 2,
steps = FALSE,
...
)
formula 
a formula object, with the response on the left of an ~ operator, and the terms, separated by 
data 
a data frame containing the variables occurring in the formula, e.g. 
scoring 
A character scalar. If 
mu.link , sigma.link , xi.link 
Character scalars to set the respective
link functions for the location ( 
stepLength 
A numeric vector of positive values. The initial
values of the step lengths 
stepAttempts 
A nonnegative integer. If the first call to

stepReduce 
A number greater than 1. The factor by which the step
lengths in 
steps 
A logical scalar. Pass 
... 
Further arguments passed to

See gamlss::gamlss()
for information about
the model and the fitting algorithm.
Returns a gamlss
object. See the Value section of
gamlss::gamlss()
. The class of the returned object is
c("gamlssx", "gamlss", "gam", "glm", "lm")
.
GEV
,
gamlss.dist::gamlss.family()
,
gamlss::gamlss()
# Load gamlss, for the function pb()
library(gamlss)
##### Simulated data
set.seed(17012023)
n < 100
x < stats::runif(n)
mu < 1 + 2 * x
sigma < 1
xi < 0.25
y < nieve::rGEV(n = 1, loc = mu, scale = sigma, shape = xi)
data < data.frame(y = as.numeric(y), x = x)
plot(x, y)
# Fit model using the default RS method with Fisher's scoring
mod < fitGEV(y ~ gamlss::pb(x), data = data)
# Summary of model fit
summary(mod)
# Residual diagnostic plots
plot(mod, xlab = "x", ylab = "y")
# Data plus fitted curve
plot(data$x, data$y, xlab = "x", ylab = "y")
lines(data$x, fitted(mod))
# Fit model using the mixed method and quasiNewton scoring
# Use trace = FALSE to prevent writing the global deviance to the console
mod < fitGEV(y ~ pb(x), data = data, method = mixed(), scoring = "quasi",
trace = FALSE)
# Fit model using the CG method
# The default step length of 1 needs to be reduced to enable convergence
# Use steps = TRUE to write the step lengths to the console
mod < fitGEV(y ~ pb(x), data = data, method = CG(), steps = TRUE)
##### Fremantle annual maximum sea levels
##### See also the gamlssx package README file
# Transform Year so that it is centred on 0
fremantle < transform(fremantle, cYear = Year  median(Year))
# Plot sea level against year and against SOI
plot(fremantle$Year, fremantle$SeaLevel, xlab = "year", ylab = "sea level (m)")
plot(fremantle$SOI, fremantle$SeaLevel, xlab = "SOI", ylab = "sea level (m)")
# Fit a model with Pspline effects of cYear and SOI on location and scale
# The default links are identity for location and log for scale
mod < fitGEV(SeaLevel ~ pb(cYear) + pb(SOI),
sigma.formula = ~ pb(cYear) + pb(SOI),
data = fremantle)
# Summary of model fit
summary(mod)
# Model diagnostic plots
plot(mod)
# Worm plot
wp(mod)
# Plot of the fitted component smooth functions
# Note: gamlss::term.plot() does not include uncertainty about the intercept
# Location mu
term.plot(mod, rug = TRUE, pages = 1)
# Scale sigma
term.plot(mod, what = "sigma", rug = TRUE, pages = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.