abso_diff_est: Estimate the Gini's mean difference/mean absolute...

Description Usage Arguments References See Also Examples

View source: R/Abso_diff_est.R

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

1
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{β_0 + β_1*x_1 + ... + β_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

\insertRef

wang2017quantilequantoptr

See Also

The function IPWE_MADopt is based on this function.

Examples

 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
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))
}



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)

quantoptr documentation built on May 2, 2019, 4:03 p.m.