mcqrnn | R Documentation |
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.
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)
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; |
w |
if |
tau |
desired tau-quantiles; |
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. If supplied with a list
of weight matrices from a prior run of |
monotone |
column indices of covariates for which the monotonicity constraint should hold. |
eps.seq |
sequence of |
Th |
hidden layer transfer function; use |
Th.prime |
derivative of the hidden layer transfer function |
penalty |
weight penalty for weight decay regularization. |
n.errors.max |
maximum number of |
trace |
logical variable indicating whether or not diagnostic messages are printed during optimization. |
method |
character string indicating which optimization algorithm to use when |
... |
additional parameters passed to the |
parms |
list containing MCQRNN weight matrices and other parameters. |
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
composite.stack
, qrnn.fit
,
qrnn2.fit
, qrnn.predict
,
qrnn2.predict
, adam
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.