GithubHelp home page GithubHelp logo

Comments (2)

pzivich avatar pzivich commented on August 26, 2024 1

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.

ChristelSwift avatar ChristelSwift commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.