regfit2: Fit robust logistic regression models to values of an input...

Description Usage Arguments Details Value Examples

View source: R/regfit2.R

Description

This function is basically a wrapper for function robustlogrm to fit a logistic regression model on each value of an input variable of the data set.

Usage

1
regfit2(formula, data, id.vars, targetValue = "", cond, suffix = "_ed", ...)

Arguments

formula

an object of class formula (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under ‘Details’.

data

data frame, list or environment (or object coercible by as.data.table to a data.table) containing the variables in the model (see 'Details').

id.vars

names of the identification variables for each unit in the input data set data.

cond

parameter indicating the model to adjust according to:

  1. '' for the π model (marginal probability for the target variable value).

  2. '0' (or 0 or FALSE) for the model conditional on value 0 for the target binary variable value).

  3. '1' (or 1 or TRUE) for the model conditional on value 1 for the target binary variable value).

suffix

parameter for the name of the edited version of the variable under analysis (see 'Details').

...

extra arguments to be used to form the default control argument.

Details

Regarding formula see robustlogrm. Although the target variables for models with cond='', on the one hand, and with cond=0,1, on the other hand, are different (edited in the first case and raw in the latter), it is not necessary to specify the suffix in the formula.

The input data set data must contain at least the following colums:

  1. id.vars: columns with the identification variables of each unit.

  2. raw target variable: column with the raw values of the variable under analysis. This is the LHS variable of formula.

  3. edited target variable: column with the edited values of the variable under analysis. The name must be the same as that of the raw target variable with a suffix specified in the parameter suffix.

  4. regressors: columns corresponding to the variables specified in the RHS of formula.

Value

A data.table with two colums named with the LHS variable of formula and fit. The first column contains every single value of this variable in the input data set data. The second column contains a glm object with the fit of the model for each variable value.

Examples

1
2
3
4
## Not run: 
regfit2(formula= 'y ~ x1', data= trainDT, id.vars= 'ID', cond= '', suffix= '')

## End(Not run)

david-salgado/categObsPredModelParam documentation built on Dec. 3, 2020, 1:42 p.m.