GithubHelp home page GithubHelp logo

ihmeuw-msca / mrtool Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 6.0 270 KB

Featured Nonlinear Mixed effects Models

Home Page: https://mrtool.readthedocs.io/en/latest

License: BSD 2-Clause "Simplified" License

Python 100.00%
meta-regression mixed-effects nonlinear-optimization

mrtool's People

Contributors

jiaweih avatar kels271828 avatar ramittal avatar zhengp0 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

mrtool's Issues

get_w_soln() undefined

For function
extract_data_info(signal_model,
linear_model,
ref_covs,
alt_covs,
exp_quantiles = c(0.15, 0.85),
exp_bounds = NULL,
num_points = 100L,
normalize_to = NULL)
signal_model to extract weights from get_w_soln()
However, get_w_soln() has not been defined by MRBeRT module
I want to know whether the followed code can replace the role of get_w_soln()
w <- t(do.call(rbind,
lapply(1:length(signal_model$sub_models),
function(i){signal_model$sub_models[[i]]$w_soln}))
) %*% signal_model$weights

Or what can I do to make extract_data_info() run correctly?

Issues regarding running MRBRT.fit_model

_**Dear MRTool Developers,

Recently I'm trying to use this tool to predict the exposure-response curves, but I have encountered some issues regarding the codes.

I have tested a sample you give in this website: https://mrtool.readthedocs.io/en/latest/examples/example_linear.html
Here shows my codes:**_
#-----------------------------------------------------------------

  1. @ruijing Ni([email protected])

  2. ###Code for fitting exposure-response function curve
  3. from mrtool import MRData
  4. from mrtool import LinearCovModel
  5. from mrtool import MRBRT
  6. import pandas as pd
  7. from limetr import LimeTr
  8. df=pd.DataFrame.from_dict(
  9. {'y':pd.Series([0.20,0.29,0.09,0.14,0.40]),
  10. 'x':pd.Series([0.0 ,0.1 ,0.2 ,0.3 ,0.4 ]),
  11. 'y_se':pd.Series([0.1,0.1,0.1,0.1,0.1]),
  12. 'study_id':pd.Series(['A','A','B','C','D'])
  13. }
  14. )
  15. #allocate MRData object
  16. data=MRData()
  17. #Data delivery
  18. data.load_df(
  19. df,
    
  20. col_obs='y',
    
  21. col_covs=['x'],
    
  22. col_obs_se='y_se',
    
  23. col_study_id='study_id'
    
  24. )
  25. #create covariate models
  26. cov_intercept = LinearCovModel('intercept', use_re=True)
  27. cov_x = LinearCovModel('x')
  28. #create fit model
  29. model = MRBRT(
  30. data,
    
  31. [cov_intercept, cov_x]
    
  32. )
  33. model.fit_model()

#-----------------------------------------------------------------

Then error occurs:
#-----------------------------------------------------------------
Traceback (most recent call last):
File "/raven/u/nirj/Python/Health_Impact/pro/Asthma_updated/dataset/../pro/data_test_MRData_t.py", line 39, in
model.fit_model()
File "/u/nirj/.local/lib/python3.9/site-packages/mrtool-0.0.1-py3.9.egg/mrtool/core/model.py", line 272, in fit_model
self.lt = LimeTr(n, k_beta, k_gamma,
TypeError: init() got an unexpected keyword argument 'S'
#-----------------------------------------------------------------

I have checked the function library 'LimeTr' called here,
#-----------------------------------------------------------------
def fit_model(self, **fit_options):
"""Fitting the model through limetr.

    ...

    **# create limetr object
    self.lt = LimeTr(n, k_beta, k_gamma,
                     y, x_fun, x_fun_jac, z_mat, S=s,
                     C=c_fun, JC=c_fun_jac, c=c_vec,
                     H=h_fun, JH=h_fun_jac, h=h_vec,
                     uprior=uprior, gprior=gprior, lprior=lprior,
                     inlier_percentage=self.inlier_pct)**

   ...

#-----------------------------------------------------

As the text shown in bold, a lot of variables are passing to LimeTr. But I found that, in the lastest version of LimeTr (v0.1.1), variables are not defined and passed in this way (shown below). While in the earliest version, it does (shown below).
#----lastest version 0.1.1 LimeTr--------------------
def init(self,
data: Data,
fevar: FeVariable,
revar: ReVariable,
inlier_pct: float = 1.0):
"""
#----lastest version 0.0.1 LimeTr--------------------
class LimeTr:
def init(self, n, k_beta, k_gamma, Y, F, JF, Z,
S=None, share_obs_std=False,
C=None, JC=None, c=None,
H=None, JH=None, h=None,
uprior=None, gprior=None, lprior=None,
certain_inlier_id=None,
inlier_percentage=1.0):
"""
#-----------------------------------------------------

_**So I guess the error occurs due to the version update or version compatibility issues. It seems that, MRTool has not been updated to adapt to the updates of LimeTr. I have tried to install the earliest version of LimeTr (v0.0.1), but it always failed.

Do you have any idea or advice on this? How can I successfully use MRTool? I'm looking forward to your replies.

Many thanks,
Ruijing Ni**_

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.