xregControl: Formula, start value, and custom criterion function fitting...

Description Usage Arguments Author(s) Examples

View source: R/xregControl_function.R

Description

Allows a list of formulas and fitting functions to be used for each type or set of data,

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
xregControl(
  formulas,
  start_values = numeric(),
  fixed_values = numeric(),
  p_fun = cont_normal,
  p_aggregation_fun = function(d_df) return(-d_df$p * d_df$internal_count),
  weights_var = NA,
  name = NA,
  censor_bounds = c(-Inf, Inf),
  lower = NA,
  upper = NA
)

Arguments

formulas

List of formulas to be fitted for data.frames with same name. If more thann one formula is provided, a column named like the the left-hand side will be generated in the data.frame during calculation, which can then be used in subsequent formulas. See examples

start_values

List or named vector of start values for parmaeters to be fitted

fixed_values

List or named vector of fixed values to be used in formulas.

p_fun

function to generate likelihood for each observation or interval of observations. Some standard functions are provided. Defaults to least-squares using normally distributed maximum likelihood.

weights_var

optional parameter. If provided, should match a column in provided data.frame, and will be used as a frequency weight when aggregating likelihoods.

name

Name of control-set. If none is provided, names will be set by the order of controlsets. data.frames will be matched to control-sets using these names (or order).

censor_bounds

Optional observation bounds for interval regression, e.g. c(1, 2). Defaults to c(-Inf, Inf)

lower

Named vector of optional box constraint lower bounds for fitting of parameters. E.g. c(VAR1 = 0) will force VAR1 to be >=0.

upper

Named vector of optional box constraint upper bounds for fitting of parameters. E.g. c(VAR1 = 1) will force VAR1 to be <=1.

p_aggregatio_fun

function to aggregate likelihoods (or similar), to be returned to optim

Author(s)

Kim Rand

Examples

1
2
3
4
control_continuous <- xregControl(formulas = list(x ~ y * YVAR + z + ZVAR, value ~ INTERCEPT + x * XVAR), start_values = c(INTERCEPT = 0, XVAR = 1, YVAR = 1, ZVAR = 1), p_fun = cont_normal, name = "CONTINUOUS")
control_dichotomos <- xregControl(formulas = list(value ~ INTERCEPT2 + z * ZVAR), start_values = c(INTERCEPT2 = 0, ZVAR = 1), p_fun = dich_logistic, name = "DICHOTOMOUS")
joint_control <- c(control_continuous, control_dichotomous)
xreg(controlList = joint_control, dataList = list(CONTINUOUS = df1, DICHOTOMUS = df2))

intelligentaccident/xreg documentation built on Jan. 17, 2021, 7:38 a.m.