fit_model: Fit Dirichlet Process Regression model

View source: R/wrapper.R

fit_modelR Documentation

Fit Dirichlet Process Regression model

Description

Fit a Dirichlet Process Regression model using a specified fitting method. Outcome (y) should be Gaussian and scaled and centered; predictors (x) and covariates (w) should also be scaled and centered but may be of any distribution

Usage

fit_model(
  y,
  w,
  x,
  rotate_variables = FALSE,
  covariance_matrix = NULL,
  fitting_method = "VB",
  ...
)

Arguments

y

Numeric vector of outcome

w

Numeric matrix of covariates (default = rep(1, length(y)))

x

Numeric matrix of predictors

rotate_variables

Logical value indicating whether to rotate y, w and x using covariance_matrix (default = FALSE)

covariance_matrix

Numeric sample covariance matrix used for rotation of y, w and x - if NULL and rotate_variables is TRUE then the sample covariance matrix is computed from x

fitting_method

Character string indicating the method used for fitting the data - possible values are:

  • 'Gibbs' - full Bayesian inference with Gibbs sampler with a fixed n_k

  • 'Adaptive_Gibbs' - adaptive version of Gibbs sample that automatically chooses n_k

  • 'VB' - variational Bayes inference with a fixed n_k

...

arguments to pass through to internal methods.

Details

fit_model() can pass a number of additional parameters to the different fitting methods. These parameters are used for all modes:

  • n_k: number of mixture components in scale mixture of normals prior (default = 4)

  • l_min: minimum value of log-likelihood for initial parameter search (default = 1e-7, only modify if you know what you are doing)

  • l_max: maximum value of log-likelihood for initial parameter search (default = 1e5, only modify if you know what you are doing)

  • n_regions: number of regions over which to search for maximum log-likelihood (default = 10, only modify if you know what you are doing)

These parameters are only used for the Gibbs and Adaptive Gibbs modes:

  • w_step: number of burn-in steps for Gibbs sampler (default = 1000)

  • s_step: number of inference steps for Gibbs sampler (default = 1000)

  • m_n_k: maximum number of mixture components in scale mixture of normals prior (default = 6, Adaptive Gibbs only)

Value

returns an object of class 'DPR_Model'

Examples

file_path_x <- system.file("extdata", "data/in/x.rds", package = "RcppDPR")
file_path_y <- system.file("extdata", "data/in/y.rds", package = "RcppDPR")
file_path_w <- system.file("extdata", "data/in/w.rds", package = "RcppDPR")
x = readRDS(file_path_x)
y = readRDS(file_path_y)
w = readRDS(file_path_w)
dpr_model <- fit_model(y, w, x, fitting_method = "VB")

RcppDPR documentation built on April 3, 2025, 11:20 p.m.

Related to fit_model in RcppDPR...