Learn R Programming

catalytic (version 0.1.0)

cat_glm: Catalytic Generalized Linear Models (GLMs) Fitting Function with Fixed Tau

Description

Fits a Catalytic Generalized Linear Models (GLMs) by using observed and synthetic data.

Usage

cat_glm(formula, cat_init, tau = NULL)

Value

A list containing the values of all the arguments and the following components:

coefficients

Estimated coefficient vector.

model

Fitted GLMs object (stats::glm).

Arguments

formula

A formula specifying the GLMs. Should at least include response variables (e.g. ~ .).

cat_init

A list generated from cat_glm_initialization.

tau

Optional numeric scalar controlling the weight of the synthetic data in the coefficient estimation. Defaults to the number of predictors / 4 for Gaussian models or the number of predictors otherwise.

Examples

Run this code
gaussian_data <- data.frame(
  X1 = stats::rnorm(10),
  X2 = stats::rnorm(10),
  Y = stats::rnorm(10)
)

cat_init <- cat_glm_initialization(
  formula = Y ~ 1, # formula for simple model
  data = gaussian_data,
  syn_size = 100, # Synthetic data size
  custom_variance = NULL, # User customized variance value
  gaussian_known_variance = TRUE, # Indicating whether the data variance is known
  x_degree = c(1, 1), # Degrees for polynomial expansion of predictors
  resample_only = FALSE, # Whether to perform resampling only
  na_replace = stats::na.omit # How to handle NA values in data
)

cat_model <- cat_glm(
  formula = ~.,
  cat_init = cat_init, # Only accept object generated from `cat_glm_initialization`
  tau = 1 # Weight for synthetic data
)
cat_model

Run the code above in your browser using DataLab