Description Usage Arguments Value Examples
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.
1 2 | lm_pai_cvboot_fit(formula, DV, TreatVar, dat, boot = TRUE, k, holdouts,
yhigherisbetter = TRUE)
|
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 |
A three dimensional array with cases on the first dimension, multiple estimates calculated on the second dimension, and bootstrap resamples on the third dimension.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.