Learn R Programming

deepregression (version 2.2.0)

Fitting Deep Distributional Regression

Description

Allows for the specification of semi-structured deep distributional regression models which are fitted in a neural network as proposed by Ruegamer et al. (2023) . Predictors can be modeled using structured (penalized) linear effects, structured non-linear effects or using an unstructured deep network model.

Copy Link

Version

Install

install.packages('deepregression')

Monthly Downloads

351

Version

2.2.0

License

GPL-3

Maintainer

David Ruegamer

Last Published

December 2nd, 2024

Functions in deepregression (2.2.0)

form_control

Options for formula parsing
family_to_trochd

Character-torch mapping function
get_nodedata

Extract attributes/hyper-parameters of the node term
get_weight_by_opname

Function to return weight given model and name
tib_layer

Hadamard-type layers
fitted.drEnsemble

Method for extracting the fitted values of an ensemble
makeInputs

Convenience layer function
loop_through_pfc_and_call_trafo

Function to loop through parsed formulas and apply data trafo
get_partial_effect

Return partial effect of one smooth term
get_gamdata

Extract property of gamdata
get_gam_part

Extract gam part from wrapped term
get_gamdata_reduced_nr

Extract number in matching table of reduced gam term
layer_dense_module

Function to create custom nn_linear module to overwrite reset_parameters
layer_spline_torch

Function to define spline as Torch layer
from_preds_to_dist

Define Predictor of a Deep Distributional Regression Model
family_to_trafo_torch

Character-to-transformation mapping function
get_help_forward_torch

Helper function to calculate amount of layers Needed when shared layers are used, because of layers have same names
layer_dense_torch

Function to define a torch layer similar to a tf dense layer
log_score

Function to return the log_score
get_processor_name

Extract processor name from term
from_distfun_to_dist_torch

Function to define output distribution based on dist_fun
extractval

Formula helpers
gam_plot_data

used by gam_processor
from_preds_to_dist_torch

Define Predictor of a Deep Distributional Regression Model
get_type_pfc

Function to subset parsed formulas
get_layer_by_opname

Function to return layer given model and name
from_dist_to_loss_torch

Function to transform a distribution layer output into a loss function
get_ensemble_distribution

Obtain the conditional ensemble distribution
get_names_pfc

Extract term names from the parsed formula content
make_generator

creates a generator for training
orthog_P

Function to compute adjusted penalty when orthogonalizing
orthog_control

Options for orthogonalization
handle_gam_term

Function to define smoothness and call mgcv's smooth constructor
make_folds

Generate folds for CV out of one hot encoded matrix
simplyconnected_layer_torch

Hadamard-type layers torch
from_dist_to_loss

Function to transform a distritbution layer output into a loss function
get_distribution

Function to return the fitted distribution
extractvar

Extract variable from term
family_to_tfd

Character-tfd mapping function
get_node_term

Extract variables from wrapped node term
plot_cv

Plot CV results from deepregression
precalc_gam

Pre-calculate all gam parts from the list of formulas
import_packages

Function to import required packages
get_special

Extract terms defined by specials in formula
import_tf_dependings

Function to import required packages for tensorflow @import tensorflow tfprobability keras
multioptimizer

Function to define an optimizer combining multiple optimizers
re_layer

random effect layer
na_omit_list

Function to exclude NA values
get_weight_by_name

Function to retrieve the weights of a structured layer
get_layernr_by_opname

Function to return layer number given model and name
get_layernr_trainable

Function to return layer numbers with trainable weights
keras_dr

Compile a Deep Distributional Regression Model
tf_repeat

TensorFlow repeat function which is not available for TF 2.0
plot.deepregression

Generic functions for deepregression models
get_luz_dataset

Helper function to create an function that generates R6 instances of class dataset
reinit_weights

Generic function to re-intialize model weights
import_torch_dependings

Function to import required packages for torch @import torch torchvision luz
tf_row_tensor

Row-wise tensor product using TensorFlow
prepare_data

Function to prepare data based on parsed formulas
layer_sparse_batch_normalization

Sparse Batch Normalization layer
layer_spline

Function to define spline as TensorFlow layer
nn_init_no_grad_constant_deepreg

custom nn_linear module to overwrite reset_parameters # nn_init_constant works only if value is scalar; so warmstarts for gam does'not work
layer_node

NODE/ODTs Layer
names_families

Returns the parameter names for a given family
layer_sparse_conv_2d

Sparse 2D Convolutional layer
make_generator_from_matrix

Make a DataGenerator from a data.frame or matrix
penalty_control

Options for penalty setup in the pre-processing
model_torch

Function to initialize a nn_module Forward functions works with a list. The entries of the list are the input of the subnetworks
prepare_data_torch

Function to additionally prepare data for fit process (torch)
orthog_structured_smooths_Z

Orthogonalize structured term by another matrix
orthog_post_fitting

Orthogonalize a Semi-Structured Model Post-hoc
weight_control

Options for weights of layers
tf_stride_last_dim_tensor

Function to index tensors last dimension
tfd_mse

For using mean squared error via TFP
update_miniconda_deepregression

Function to update miniconda and packages
torch_dr

Compile a Deep Distributional Regression Model (Torch)
prepare_torch_distr_mixdistr

Prepares distributions for mixture process
%>%

Pipe operator
process_terms

Control function to define the processor for terms in the formula
tf_stride_cols

Function to index tensors columns
tf_split_multiple

Split tensor in multiple parts
layer_generator

Function that creates layer for each processor
subnetwork_init_torch

Initializes a Subnetwork based on the Processed Additive Predictor
subnetwork_init

Initializes a Subnetwork based on the Processed Additive Predictor
quant

Generic quantile function
makelayername

Function that takes term and create layer name
predict_gen

Generator function for deepregression objects
prepare_input_list_model

Function to prepare input list for fit process, due to different approaches
prepare_newdata

Function to prepare new data based on parsed formulas
predict_gam_handler

Handler for prediction with gam terms
stddev

Generic sd function
reinit_weights.deepregression

Method to re-initialize weights of a "deepregression" model
separate_define_relation

Function to define orthogonalization connections in the formula
stop_iter_cv_result

Function to get the stoppting iteration from CV
tfd_zinb

Implementation of a zero-inflated negbinom distribution for TFP
tfd_zip

Implementation of a zero-inflated poisson distribution for TFP
create_family

Function to create (custom) family
create_penalty

Function to create mgcv-type penalty
collect_distribution_parameters

Character-to-parameter collection function needed for mixture of same distribution (torch)
layer_add_identity

Convenience layer function
check_input_args_fit

Function to check if inputs are supported by corresponding fit function
choose_kernel_initializer_torch

Function to choose a kernel initializer for a torch layer
extract_S

Convenience function to extract penalty matrix and value
check_and_install

Function to check python environment and install necessary packages
coef.drEnsemble

Method for extracting ensemble coefficient estimates
combine_penalties

Function to combine two penalties
create_family_torch

Function to create (custom) family
make_tfd_dist

Families for deepregression
deepregression

Fitting Semi-Structured Deep Distributional Regression
cv

Generic cv function
extract_pure_gam_part

Extract the smooth term from a deepregression term specification
ensemble

Generic deep ensemble function
distfun_to_dist

Function to define output distribution based on dist_fun
ensemble.deepregression

Ensembling deepregression models
family_to_trafo

Character-to-transformation mapping function