zEpid icon indicating copy to clipboard operation
zEpid copied to clipboard

Update documentation (and possibly re-organize)

Open pzivich opened this issue 3 years ago • 2 comments

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 avatar Dec 30 '20 00:12 pzivich

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.

ChristelSwift avatar Nov 07 '22 17:11 ChristelSwift

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

pzivich avatar Nov 07 '22 17:11 pzivich