Comments (2)
yes, that is an old format (that I need to correct). The updated function is IPTW.treatment_model()
see here.
The updated version of that trick would be something like
# Specifying models
modeln = 'enter + enter_q + enter_c'
modeld = ('enter + enter_q + enter_c + male + age0 + age0_q + age0_c + dvl0 + cd40 + '
'cd40_q + cd40_c + dvl + cd4 + cd4_q + cd4_c')
# Restricting to only the previously untreated data
dfs = df.loc[df['lagart']==0].copy()
# Calculating probabilities for IPTW
ipw = IPTW(dfs, treatment='art',
outcome='dead') # placeholder outcome is needed to prevent error
ipw.treatment_model(model_denominator=modeld, model_numerator=modeln)
# no .fit() call since IPTW is calculated in .treatment_model() step
# No Extracting Needed
# df['__numer__']
# df['__denom_']
More broadly, that code above is a hack to get the IPTW
estimator to work with time-varying exposures. It is on the slate to be replaced by a specific longitudinal IPTW function for time-varying exposures. However, there is no specific timeline for that implementation
from zepid.
is it possible that the code in the documentation has changed when some functions got updated? for example in https://zepid.readthedocs.io/en/latest/Time-Varying%20Exposure.html the following code doesn't seem to work:
# Specifying models
modeln = 'enter + enter_q + enter_c'
modeld = ('enter + enter_q + enter_c + male + age0 + age0_q + age0_c + dvl0 + cd40 + '
'cd40_q + cd40_c + dvl + cd4 + cd4_q + cd4_c')
# Restricting to only the previously untreated data
dfs = df.loc[df['lagart']==0].copy()
# Calculating probabilities for IPTW
ipt = IPTW(dfs, treatment='art')
ipt.regression_models(model_denominator=modeld, model_numerator=modeln)
ipt.fit()
# Extracting probabilities for later manipulation
df['p_denom'] = ipt.ProbabilityDenominator
df['p_numer'] = ipt.ProbabilityNumerator
The error seems to be a combination of wrong variable names (e.g. cd4_q should be cd4_sq, cd4_c should be cd4_cu etc...) and updated function syntax for iptw as it doesn't accept the regression_models
argument.
from zepid.
Related Issues (20)
- IPTW handle PerfectSeparationErrors in the marginal structural model better
- AIPW for survival analysis ? HOT 1
- Dual treatments
- ValueError better pytest strategy
- Package compatibility? HOT 2
- MonteCarloGFormula
- Add Odds Ratio and other estimands for AIPTW and TMLE
- Addition of meta-analysis tools
- add p-value column in a forrest plot/ effectmeasureplot HOT 2
- Enhancement in graphics.py to change odds text size HOT 1
- Saving DAGs programatically HOT 11
- sklearn dependancy in setup.py should be scikit-learn HOT 1
- AIPW formula equivalent to what's in the literature? HOT 2
- Perfect separation error for using `SingleCrossfitTMLE` HOT 2
- Superlearn check weights HOT 2
- SingleCrossFit `invalid value encountered in log` HOT 8
- Unable to install latest 0.9.0 version through pip HOT 7
- Risk Ratio Summary HOT 1
- The default regression argument of zepid.base.interaction_contrast_ratio differs from the description in the documentation. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zepid.