Open Sandy4321 opened 6 years ago
https://github.com/BIDData/BIDMach/wiki/Causal-Inference
BIDMach has several basic causal estimators. IPTW stands for Inverse Probability of Treatment Weighting and is a widely used method technique for causal inference with binary treatments. We start with some data features <math>X</math>, a response <math>Y</math>, and a "treatment" <math>Z</math>. In causal inference we are interested in the effects of directly changing <math>Z</math> on <math>Y</math>. This is different from the conditional probability of <math>Y</math> given <math>Z</math> which depends on joint probability distribution of the system "as is"
so formatting failed to be shown in chrome and EI
may you help find links to read more about this, pls
it should be like this
IPTW BIDMach has several basic causal estimators. IPTW stands for Inverse Probability of Treatment Weighting and is a widely used method technique for causal inference with binary treatments. We start with some data features , a response , and a "treatment" . In causal inference we are interested in the effects of directly changing on . This is different from the conditional probability of given which depends on joint probability distribution of the system "as is". The causal effect instead models a change to the system where we force to a new value. The simplest approach is to regress on , using linear or logistic regression. The coefficient of in the regression model captures the direct influence of on . If the regression model is exact, i.e. if really is a linear function of the inputs, then this coefficient accurately captures the influence of on (for logistic regression we need to use instead the influence of the regression coefficient, which is for a particular input X, where is the logistic predictor).
However, a regression model often wont be exact, and a different kind of estimate is needed. The next approach is to simulate randomization of . If we had randomly assigned each user to classes and we could simply use the difference in responses as the causal effect. This is the approach taken in randomized trials. But given a dataset, we can't change the assignments to that were made. The actual assignment could depend in an arbitrary fashion on the other features and then the difference in response will depend on the influence of those features as well as . We could partition or cluster the data according to , and then look within each subset at the difference in outcome for samples with and . But this is very difficult with high-dimensional features, and there turns out to be a much more efficient approach based on the propensity score. The propensity score is the probability of the treatment assignment, i.e. , and the notations and are often used. Stratification by the propensity score turns out to be sufficient for accurate estimation of the causal effect.
For a regression-based estimate, we can treat the propensity score as a sampling bias. By dividing by it, we create a pseudo-sample in which units have equal (and random) probability of assignment to or . Then the IPTW estimator for the causal effect is defined as:
where and are the responses when is forced respectively to 0 or 1. There is a simple estimator for IPTW effects in the causal package. It concurrently computes using logistic regression and the estimator above. It expects a targets option which encodes both the treatment(s) and the effects . It can analyze k effects at once, and targets should be a 2k x nfeats matrix. The first k rows encode the k treatments, and the next k rows encode the corresponding effects. The treatment and effects should therefore be among the input features, and the row of targets will normally be zeros with a single 1 in the position of the feature that encodes the treatment. The row should have a single 1 in the position that encodes the feature for the effect.
The output is in the learner's modelmats(1) field. This will be an FMat with k entries corresponding to the k effects.
A-IPTW Regression estimates will be inaccurate if the outcome is not accurately modeled as a linear or logistic function of . IPTW estimates can be quite inaccurate if the model used for is poor. Doubly-Robust estimators combine regression and propensity score estimators in such a way that if either estimator is accurate, the errors from the other estimator cancel out. In other words, a doubly robust estimator is accurate if either the base regression model or the propensity score are accurate. One class of these estimators are called A-IPTW for Augmented IPTW.
where and are derived from a regression model for given . and .
Creation of an A-IPTW model is the same as for an IPTW model. Both estimators are computed by the same IPTW class. IPTW estimates appear in modelmats(1), while the A-IPTW estimates are in modelmats(2).
Data Preparation We assume that there is a data matrix dat which is nfeatures x nsamples, and which holds the vectors above. We further assume that the treatment and outcome are encoded as features in dat as well, and that there are maps and that select and . So and should be zero-one-valued matrices. when feature encodes and when feature encodes . Thus and should have the same size. For efficiency the are combined into a single target matrix. Thus preparing a causal estimation run should look like this:
val (nn, opts) = IPTW.learner(dat) opts.targets = A on B As with regression modeling, its essential to mask out these features so that they are not allowed to predict themselves. Thus the rmask matrix should have the same size as opts.targets, and (at least) zeros wherever opts.targets has ones. Furthermore, we dont now allow outcome features (Y) to be used to predict treatment (X), so the corresponding values in rmask should also be set to zero. Then
opts.rmask = 1 - opts.targets // Zero Y --> Z terms as well nn.train ... By default, the IPTW class trains logistic models for Z and Y. You can change that by setting opts.links which has the same behavior as for the GLM class. When training is done, nn.modelmats(1) and nn.modelmats(2) contain vectors (GMat or FMat) of estimates for the IPTW and A-IPTW estimators respectively. You can retrieve them as FMats with:
val iptw = FMat(nn.modelmats(1)) val aiptw = FMat(nn.modelmats(2))
https://github.com/BIDData/BIDMach/wiki/Causal-Inference it is how it is shown IPTW BIDMach has several basic causal estimators. IPTW stands for Inverse Probability of Treatment Weighting and is a widely used method technique for causal inference with binary treatments. We start with some data features , a response , and a "treatment" . In causal inference we are interested in the effects of directly changing on . This is different from the conditional probability of given which depends on joint probability distribution of the system "as is".