qrnn (version 2.0.5)

mcqrnn: Monotone composite quantile regression neural network (MCQRNN) for simultaneous estimation of multiple non-crossing quantiles

Description

High level wrapper functions for fitting and making predictions from a monotone composite quantile regression neural network (MCQRNN) model for multiple non-crossing regression quantiles (Cannon, 2018).

Uses composite.stack and monotonicity constraints in qrnn.fit or qrnn2.fit to fit MCQRNN models with one or two hidden layers. Note: Th must be a non-decreasing function to guarantee non-crossing.

Usage

mcqrnn.fit(x, y, n.hidden=2, n.hidden2=NULL, w=NULL,
           tau=c(0.1, 0.5, 0.9), iter.max=5000, n.trials=5,
           lower=-Inf, init.range=c(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5),
           monotone=NULL, eps.seq=2^seq(-8, -32, by=-4), Th=sigmoid,
           Th.prime=sigmoid.prime, penalty=0, n.errors.max=10,
           trace=TRUE, method=c("nlm", "adam"), ...)
mcqrnn.predict(x, parms, tau=NULL)

Arguments

x

covariate matrix with number of rows equal to the number of samples and number of columns equal to the number of variables.

y

response column matrix with number of rows equal to the number of samples.

n.hidden

number of hidden nodes in the first hidden layer.

n.hidden2

number of hidden nodes in the second hidden layer; NULL fits a model with a single hidden layer.

w

vector of weights with length equal to the number of samples times the length of tau; NULL gives equal weight to each sample. See composite.stack.

tau

desired tau-quantiles; NULL in mcqrnn.predict uses values from the original call to mcqrnn.fit.

iter.max

maximum number of iterations of the optimization algorithm.

n.trials

number of repeated trials used to avoid local minima.

lower

left censoring point.

init.range

initial weight range for input-hidden, hidden-hidden, and hidden-output weight matrices.

monotone

column indices of covariates for which the monotonicity constraint should hold.

eps.seq

sequence of eps values for the finite smoothing algorithm.

Th

hidden layer transfer function; use sigmoid, elu, softplus, or other non-decreasing function.

Th.prime

derivative of the hidden layer transfer function Th.

penalty

weight penalty for weight decay regularization.

n.errors.max

maximum number of nlm optimization failures allowed before quitting.

trace

logical variable indicating whether or not diagnostic messages are printed during optimization.

method

character string indicating which optimization algorithm to use when n.hidden2 != NULL.

...

additional parameters passed to the nlm or adam optimization routines.

parms

list containing MCQRNN weight matrices and other parameters.

References

Cannon, A.J., 2011. Quantile regression neural networks: implementation in R and application to precipitation downscaling. Computers & Geosciences, 37: 1277-1284. doi:10.1016/j.cageo.2010.07.005

Cannon, A.J., 2018. Non-crossing nonlinear regression quantiles by monotone composite quantile regression neural network, with application to rainfall extremes. Stochastic Environmental Research and Risk Assessment, 32(11): 3207-3225. doi:10.1007/s00477-018-1573-6

See Also

composite.stack, qrnn.fit, qrnn2.fit, qrnn.predict, qrnn2.predict, adam

Examples

Run this code
x <- as.matrix(iris[,"Petal.Length",drop=FALSE])
y <- as.matrix(iris[,"Petal.Width",drop=FALSE])

cases <- order(x)
x <- x[cases,,drop=FALSE]
y <- y[cases,,drop=FALSE]

set.seed(1)

## MCQRNN model w/ 2 hidden layers for simultaneous estimation of
## multiple non-crossing quantile functions
fit.mcqrnn <- mcqrnn.fit(x, y, tau=seq(0.1, 0.9, by=0.1),
                         n.hidden=2, n.hidden2=2, n.trials=1,
                         iter.max=500)
pred.mcqrnn <- mcqrnn.predict(x, fit.mcqrnn)

matplot(x, pred.mcqrnn, col="blue", type="l")
points(x, y)

Run the code above in your browser using DataCamp Workspace