Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation (and possibly re-organize) #156

Open
pzivich opened this issue Dec 30, 2020 · 2 comments
Open

Update documentation (and possibly re-organize) #156

pzivich opened this issue Dec 30, 2020 · 2 comments
Labels

Comments

@pzivich
Copy link
Owner

pzivich commented Dec 30, 2020

I wrote most of the ReadTheDocs documentation 2-3 years ago now. It is dated (and my understanding has expanded), so I should go back and review everything after the v0.9.0 release

Here are some things to consider

  • Use a different split than time-fixed and time-varying exposures
  • Add a futures section (rather than having embedded in documents)
  • Update the LIPTW / SIPTW info (once done)
  • Replace Chat Gitter button with GitHub Discussions
  • Add SuperLearner page to docs
@pzivich pzivich added enhancement help wanted Website Updates for the website labels Dec 30, 2020
@ChristelSwift
Copy link

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.

@pzivich
Copy link
Owner Author

pzivich commented Nov 7, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants