match_pred_fn: Replaces a call to a regression function with a call to the...

Description Usage Arguments Value Examples

View source: R/predictors.R

Description

'match_pred_fn' takes an expression capturing a call to either 'lm' or 'glm' and replaces that call with a call to 'lm.pred' or 'glm.pred'.

Usage

1
match_pred_fn(form_call_expr)

Arguments

form_call_expr

An expression containing a call to 'lm' or 'glm'.

Value

A list of functions.

Specifically, it returns the same as the functions 'lm.res' and 'glm.res'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(RGOB)
N <- 100
X <- rnorm(N)
Z <- sample(c(0,1), size=N, replace=TRUE)
Y <- 1 + 0.2 * X + 0.5*Z

lm_call <- expr(lm(Y ~ X + Z))
glm_call <- expr(glm(Y ~ X + Z))

match_pred_fn(lm_call) # equivalent to: lm.pred(Y ~ X + Z)
match_pred_fn(glm_call) # equivalent to: glm.pred(Y ~ X + Z)

## End(Not run)

gwb/RGOB documentation built on May 14, 2021, 7:39 a.m.