drdrtest_em {DRDRtest} | R Documentation |
The base function for testing a effect modifier with user specified nuisance functions
Description
This is the function for testing whether a discrete covariate is an effect modifier with user specified nuisance functions
Usage
drdrtest_em(
y,
a,
l,
class_label,
arange,
pifunc,
mufunc,
h = NULL,
b = 1000,
dist = "TwoPoint",
pi.low = 0.01,
a.grid.size = 401
)
Arguments
y |
A vector containing the outcomes for each observation |
a |
A vector containing the treatment levels (dosage) for each observation |
l |
A data.frame containing the observations of covariates |
class_label |
A vector containing the class label (label for the effect modifier) for each observation. |
arange |
A vector of length 2 giving the lower bound and upper bound of treatment levels |
pifunc |
A user specifid function or wapper that takes treatment a as the first argument and covariates l as the second argument and return propensit scores |
mufunc |
A user specifid function or wapper that takes treatment a as the first argument and covariates l as the second argument and return outcome regression values |
h |
bandwidth to be used in kernel regression. If not specified, will by default use "rule of thumb" bandwidth selector |
b |
number of Bootstrap samples to be generated |
dist |
distibution used to generate residuals for Bootstrap samples. Currently only have two options, "TwoPoint" and "Rademachar" |
pi.low |
Lower bound to truncate propensity scores |
a.grid.size |
size of equally spaced grid points over |
Value
A list containing
- p.value:
P value of the test result
- test.stat:
Value of the observed test statistic
- Bootstrap.samples:
A vector containing test statistic values from Bootstrap samples
- bandwidth:
Bandwidth used in kernel regression
Examples
d <- 4
n <- 200
sigma <- 0.5
delta <- 1
height <-1
arange <- c(0,5)
triangle <- function(a,height){
y <- exp(-a^2/((1/2)^2))*height
return(y)
}
mu.mod<-function(a,l,delta,height){
mu <- as.numeric(l%*%c(0.2,0.2,0.3,-0.1*delta))+
triangle(a-2.5,height)+a*(-0.1*l[,1]+0.1*delta*l[,4])
return(mu)
}
l <- matrix(rnorm(n*d),ncol=d)
l[,4] <- ifelse(l[,4]>0,1,0)
colnames(l) <- paste("l",1:4,sep="")
logit.lambda <- as.numeric(l%*%c(0.1,0.1,-0.1,0))
lambda <- exp(logit.lambda)/(1+exp(logit.lambda))
a <- rbeta(n, shape1 = lambda, shape2 =1-lambda)*5
mu <- mu.mod(a,l,delta,height)
residual.list <- rnorm(n,mean=0,sd =sigma)
y <- mu+residual.list
class_label <- l[,4]
pifunc <- function(a,l){
l <- as.matrix(l)
logit.lambda <- as.numeric(l%*%c(0.1,0.1,-0.1,0))
lambda <- exp(logit.lambda)/(1+exp(logit.lambda))
return(pmin(dbeta(a/5,shape=lambda,shape2=1-lambda)/5,100))
}
mufunc <- function(a,l){
return(mu.mod(a,as.matrix(l),delta,height))
}
out <- drdrtest_em(y,a,l,class_label,arange,pifunc,mufunc)