get_muahat: Estimation of regression function E(Y|A = a, X)

Description Usage Arguments Value Details References See Also Examples

View source: R/estimate_regressions.R

Description

get_muahat estimates the regression function E(Y|A = a, X) using the SuperLearner.

Usage

1
get_muahat(y, a, x, newx, aval, ymin, ymax, family = gaussian(), sl.lib)

Arguments

y

nx1 vector of outcomes in [0, 1]

a

nx1 vector of treatments

x

nxp data.frame of covariates

newx

qxp data.frame of values that the regression estimates are evaluated at

aval

Scalar specifying which regression to estimate E(Y|A=aval,X=x)

ymin

Infimum of the support of y, so that predictions will be forced to be >= ymin.

ymax

Supremum of the support of y, so that predictions will be forced to be <= ymax.

family

family specifying the error distribution for outcome regression, currently gaussian() or binomial() supported. Link should not be specified. Default is gaussian().

sl.lib

character vector specifying which libraries to use for the SL.

Value

A list containing estimates of E(Y | A = aval, X):

testvals

nrow(newx)-dimensional vector containing estimates of regression functions (computed using points x) evaluated at test points newx.

trainvals

nrow(x)-dimensional vector containing estimates of regression functions (computed using points x) evaluated at train points x.

Details

If the SuperLearner returns an error, a GLM is fitted instead. In this case the user is suggested to choose some other method of estimation and then pass the estimates as arguments to other functions. Sometimes SuperLearner returns warnings messages.

References

Van der Laan, M. J., Polley, E. C., & Hubbard, A. E. (2007). Super learner. Statistical applications in genetics and molecular biology, 6(1).

See Also

do_crossfit and get_piahat.

Examples

1
2
3
4
5
6
7
8
n <- 500
x <- data.frame(x1 = rnorm(n), x2 = runif(n))
newx <- data.frame(x1 = rnorm(20), x2 = runif(20))
a <- rbinom(n, 1, pnorm(x$x1))
y <- 2 + x$x1 - x$x2 + rnorm(n)
fits <- get_muahat(y, a, x, newx, 1, min(y), max(y), family = gaussian(), 
                   sl.lib = c("SL.mean", "SL.glm", "SL.gam"))
head(fits$testvals)

matteobonvini/sensitivitypuc documentation built on Dec. 9, 2020, 2:24 a.m.