fit_model {RcppDPR}R 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:

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

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")

[Package RcppDPR version 0.1.10 Index]