zEpid icon indicating copy to clipboard operation
zEpid copied to clipboard

IPTW diagnostics and MSM access

Open pzivich opened this issue 3 years ago • 0 comments

A few items have come up regarding IPTW. One additional diagnostic plot to add is a weighted histogram for continuous variables. This way it can be visually assessed whether the densities are similar between the weighted population by treatment. In the mean time this can be accomplished via:

ipw = IPTW(data, exposure="A", outcome="Y")
ipw.treatment_model("L")
# Extracting the estimated IPTW from the IPTW class
data['iptw'] = ipw.iptw
# Subset by treatment status
treat = data.loc[data["A"] == 1].copy()
nottr = data.loc[data["A"] == 0].copy()
# Weighted histogram
plt.hist(treat['L'],  weights=treat['iptw'], color='blue', alpha=0.4)
plt.hist(nottr['L'],  weights=nottr['iptw'], color='red', alpha=0.4)
plt.show()

Next, IPTW should allow access to the fitted statsmodels objects. This way proportions (and the correct CL) can be calculated for any combination of interest to users. It is easier to have the statsmodels objects directly changed rather than building my own wrapper to extract any combination correctly (since it requires manipulation of the variance-covariance matrix). But may consider depending on user feedback

pzivich avatar Sep 29 '20 21:09 pzivich