plot_gps {riAFTBART} | R Documentation |
Plot the propensity score by treatment
Description
This function estimates the propensity score for each treatment group and then plot the propensity score by each treatment to check covariate overlap.
Usage
plot_gps(trt, X, cluster.id, method = "Multinomial")
Arguments
trt |
A numeric vector representing the treatment groups. |
X |
A dataframe or matrix, including all the covariates but not treatments, with rows corresponding to observations and columns to variables. |
cluster.id |
A vector of integers representing the clustering id. The cluster id should be an integer and start from 1. |
method |
A character indicating how to estimate the propensity score. The default is "Multinomial", which uses multinomial regression to estimate the propensity score. |
Value
A plot
Examples
library(riAFTBART)
set.seed(20181223)
n = 5 # number of clusters
k = 50 # cluster size
N = n*k # total sample size
cluster.id = rep(1:n, each=k)
tau.error = 0.8
b = stats::rnorm(n, 0, tau.error)
alpha = 2
beta1 = 1
beta2 = -1
sig.error = 0.5
censoring.rate = 0.02
x1 = stats::rnorm(N,0.5,1)
x2 = stats::rnorm(N,1.5,0.5)
trt.train = sample(c(1,2,3), N, prob = c(0.4,0.3,0.2), replace = TRUE)
plot_gps(trt = trt.train, X = cbind(x1, x2), cluster.id = cluster.id)
[Package riAFTBART version 0.3.3 Index]