dl.bamlss.Rd
This function interfaces keras infrastructures for highlevel neural networks. The function
can be used as a standalone model fitting engine such as bamlss
or as an on top
model engine to capture special features in the data that could not be captures by other
model fitting engines.
## Deep learning bamlss. dl.bamlss(object, offset = NULL, weights = NULL, eps = .Machine$double.eps^0.25, maxit = 100, force.stop = TRUE, epochs = 30, optimizer = NULL, batch_size = NULL, keras.model = NULL, verbose = TRUE, digits = 4, ...) ## Predict method. # S3 method for dl.bamlss predict(object, newdata, model = NULL, drop = TRUE, ...)
object  An object of class 

offset  A 
weights  Prior weights on the data. 
eps  The relative convergence tolerance of the algorithm. 
maxit  Integer, maximum number of iterations of the algorithm. 
force.stop  Logical. should the algorithm stop if relative change is smaller than

epochs  Number of times to iterate over the training data arrays, see

optimizer  Character or call to optimizer functions to be used within 
batch_size  Number of samples per gradient update, see 
keras.model  A compiled model using keras, e.g., using

verbose  Print information during runtime of the algorithm. 
digits  Set the digits for printing when 
newdata  A 
model  Character or integer specifying for which distributional parameter predictions should be computed. 
drop  If predictions for only one 
…  For function 
The default keras model is a sequential model with two hidden layers with "relu"
activation function and 100 units in each layer. Between each layer is a dropout layer with
0.1 dropout rate.
For function dl.bamlss()
an object of class "dl.bamlss"
. Note that extractor
functions fitted
and residuals.bamlss
can be applied.
For function predict.dl.bamlss()
a list or vector of predicted values.
The BAMLSS deep learning infrastructure is still experimental!
# NOT RUN { ## Simulate data. set.seed(123) n < 300 x < runif(n, 3, 3) fsigma < 2 + cos(x) y < sin(x) + rnorm(n, sd = exp(fsigma)) ## Setup model formula. f < list( y ~ x, sigma ~ x ) ## Fit neural network. library("keras") b < dl.bamlss(f) ## Plot estimated functions. par(mfrow = c(1, 2)) plot(x, y) plot2d(fitted(b)$mu ~ x, add = TRUE) plot2d(fitted(b)$sigma ~ x, ylim = range(c(fitted(b)$sigma, fsigma))) plot2d(fsigma ~ x, add = TRUE, col.lines = "red") ## Another example identifying structures that are ## not captured by the initial model. set.seed(123) d < GAMart() b1 < bamlss(num ~ s(x1) + s(x2) + s(x3), data = d, sampler = FALSE) b2 < dl.bamlss(num ~ lon + lat, data = d, offset = fitted(b1)) p < predict(b2, model = "mu") par(mfrow = c(1, 1)) plot3d(p ~ lon + lat, data = d, symmetric = FALSE) # }