Learn R Programming

quantoptr (version 0.1.3)

abso_diff_est: Estimate the Gini's mean difference/mean absolute difference(MAD) for a Given Treatment Regime

Description

Estimate the MAD if the entire population follows a treatment regime indexed by the given parameters. This function supports the IPWE_MADopt function.

Usage

abso_diff_est(beta, x, y, a, prob, Cnobs)

Arguments

beta

a vector indexing the treatment regime. It indexes a linear treatment regime: $$ d(x)= I\{\beta_0 + \beta_1 x_1 + ... + \beta_k x_k > 0\}. $$

x

a matrix of observed covariates from the sample. Notice that we assumed the class of treatment regimes is linear. This is important that columns in x matches with beta.

y

a vector, the observed responses from a sample

a

a vector of 0s and 1s, the observed treatments from a sample

prob

a vector, the propensity scores of getting treatment 1 in the samples

Cnobs

A matrix with two columns, enumerating all possible combinations of pairs of indexes. This can be generated by combn(1:n, 2), where n is the number of unique observations.

References

wang2017quantilequantoptr

See Also

The function IPWE_MADopt is based on this function.

Examples

Run this code
# NOT RUN {
library(stats)
GenerateData.MAD <- function(n)
{
  x1 <- runif(n)
  x2 <- runif(n)
  tp <- exp(-1+1*(x1+x2))/(1+exp(-1+1*(x1+x2)))
  a<-rbinom(n = n, size = 1, prob=tp)
  error <- rnorm(length(x1))
  y <- (1 + a*0.3*(-1+x1+x2<0) +  a*-0.3*(-1+x1+x2>0)) * error
  return(data.frame(x1=x1,x2=x2,a=a,y=y))
}
# }
# NOT RUN {
# }
# NOT RUN {
n <- 500
testData <- GenerateData.MAD(n)
logistic.model.tx <- glm(formula = a~x1+x2, data = testData, family=binomial)
ph <- as.vector(logistic.model.tx$fit)
Cnobs <- combn(1:n, 2)
abso_diff_est(beta=c(1,2,-1), 
              x=model.matrix(a~x1+x2, testData),
              y=testData$y,
              a=testData$a,
              prob=ph,
              Cnobs = Cnobs)
# }

Run the code above in your browser using DataLab