lm_pai_cvboot_fit: Calculate Personalized Advantage Index (PAI)

Description Usage Arguments Value Examples

View source: R/cvboot.R

Description

Calculates the PAI for each observation in the dataset using simple linear regression, but with cross-validation and optionally bootstrapping in order to construct confidence intervals.

Usage

1
2
lm_pai_cvboot_fit(formula, DV, TreatVar, dat, boot = TRUE, k, holdouts,
  yhigherisbetter = TRUE)

Arguments

formula

An R formula, but without dependent variable

DV

a character string indicating the name of the dependent variable

TreatVar

a character string indicating the name of the treatment variable (note that values must be coded as 0/1 for the treatment variable.

dat

A dataset to use

boot

A logical value whether to bootstrap or not

k

The number of bootstrap resamples to take

holdouts

The holdouts to be used. If a vector from 1 to the number of cases available in the dataset, it is equivalent to leave-one-out. Must be constructed manually.

yhigherisbetter

A logical value whether higher scores indicate better treatment response on the dependent variable

Value

A three dimensional array with cases on the first dimension, multiple estimates calculated on the second dimension, and bootstrap resamples on the third dimension.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
# builtin dataset with 32 cases
dat <- mtcars
dat$cyl <- factor(dat$cyl)
formula <- ~ cyl + am * (mpg + hp + drat + wt)
DV <- "disp"
TreatVar <- "am"
k <- 50 # use a few just for speed
holdouts <- 1:32 # for leave-one-out

# for 10 fold cross-validation
holdouts <- by(sample(1:32), cut(1:32, ceiling(seq(from = 0, to = 32, length.out = 11))), function(x) x)
# remove names
names(holdouts) <- NULL

m <- lm_pai_cvboot_fit(formula, DV, TreatVar, dat, boot = TRUE, k = k, holdouts = holdouts)

# see result from first bootstrap resample
m[, , 1]

## End(Not run)

JWiley/pai documentation built on May 7, 2019, 10:15 a.m.