Description Usage Arguments Value Examples
This is the function for testing whether a discrete covariate is an effect modifier with user specified nuisance functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | drdrtest_em(
y,
a,
l,
class_label,
arange,
pifunc,
mufunc,
h = NULL,
b = 1000,
dist = "TwoPoint",
pi.low = 0.01,
a.grid.size = 401
)
|
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 |
A list containing
P value of the test result
Value of the observed test statistic
A vector containing test statistic values from Bootstrap samples
Bandwidth used in kernel regression
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.