Skip to contents

Extract or Compute the Model Matrices related to a fevd Object.

Usage

# S3 method for fevd
modelMatrices(object, newdata = NULL, threshold = NULL, trace = 1, ...)

Arguments

object

An object with class "fevd" representing a non-stationary POT model, either Poisson-GP (type = "GP") or NHPP (type = "PP").

newdata

A data frame containing the covariates.

threshold

The threshold. This can be either a suitable vector of an object representing a quantile regression, inheriting from "rq".

trace

Level of verbosity

...

Not used yet.

Value

A list of "design" matrices.

Author

Yves Deville

Examples


## use centimetres as precipitation unit
data(Fort) 
Fort <- within(Fort, Prec <- 2.54 * Prec)
tau <- 0.97; u0 <- quantile(Fort$Prec, prob = tau)
fit0 <- fevd(x = Prec, data = Fort, threshold = u0, type = "GP")
p0 <- predict(fit0)
rq <- rq(Prec ~ cos(2 * pi * tobs / 365.25) + sin(2 * pi * tobs / 365.25),
         data = Fort, tau = tau)
summary(rq)
#> 
#> Call: rq(formula = Prec ~ cos(2 * pi * tobs/365.25) + sin(2 * pi * 
#>     tobs/365.25), tau = tau, data = Fort)
#> 
#> tau: [1] 0.97
#> 
#> Coefficients:
#>                           Value     Std. Error t value   Pr(>|t|) 
#> (Intercept)                 0.96776   0.02542   38.07484   0.00000
#> cos(2 * pi * tobs/365.25)  -0.60217   0.03264  -18.44866   0.00000
#> sin(2 * pi * tobs/365.25)   0.09192   0.02930    3.13736   0.00171
## compute the threshold and extract the fitted coefficients
u <- predict(rq, newdata = Fort)
beta_u <- coef(rq)
fit1 <- fevd(x = Prec, data = Fort, type = "GP",
             scale.fun = ~ cos(2 * pi * tobs / 365.25) + sin(2 * pi * tobs / 365.25),
             threshold = beta_u,
             threshold.fun = ~ cos(2 * pi * tobs / 365.25) + sin(2 * pi * tobs / 365.25))

mM <- modelMatrices(fit1)
#> Error in eval(object$call$threshold): object 'beta_u' not found
names(mM)
#> Error in eval(expr, envir, enclos): object 'mM' not found
head(mM$threshold)
#> Error in eval(expr, envir, enclos): object 'mM' not found
lapply(mM, dim)
#> Error in eval(expr, envir, enclos): object 'mM' not found