Skip to content

Commit

Permalink
Add robust evaluation of the relative risk function (#54)
Browse files Browse the repository at this point in the history
* add absolute value to robustify the log relative risk evaluation

* update license and installation
  • Loading branch information
zhengp0 authored Jul 12, 2023
1 parent 78092ec commit 73fd53e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 45 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 2-Clause License

Copyright (c) 2020, IHME Math Sciences
Copyright (c) 2023, IHME Math Sciences
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
21 changes: 20 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[project]
name = "mrtool"
version = "0.1.3"
description = "Featured nonlinear mixed effects model"
readme = "README.rst"
requires-python = ">=3.10"
license = { file = "LICENSE" }
authors = [
{ name = "IHME Math Sciences", email = "[email protected]" },
]
dependencies = ["numpy", "pandas", "scipy", "xspline", "xarray", "limetr==0.0.6"]

[project.optional-dependencies]
dev = ["pytest", "pytest-mock"]
doc = ["sphinx", "sphinx-autodoc-typehints", "furo"]

[project.urls]
github = "https://github.com/ihmeuw-msca/mrtool"
36 changes: 0 additions & 36 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

8 changes: 5 additions & 3 deletions src/mrtool/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,16 @@ def mat_to_log_fun(alt_mat, ref_mat=None, add_one=True):
else:
if ref_mat is None or ref_mat.size == 0:
def fun(beta):
return np.log(shift + alt_mat.dot(beta))
alt_val = np.abs(shift + alt_mat.dot(beta))
return np.log(alt_val)

def jac_fun(beta):
return alt_mat/(shift + alt_mat.dot(beta)[:, None])
else:
def fun(beta):
return np.log(shift + alt_mat.dot(beta)) - \
np.log(shift + ref_mat.dot(beta))
alt_val = np.abs(shift + alt_mat.dot(beta))
ref_val = np.abs(shift + ref_mat.dot(beta))
return np.log(alt_val) - np.log(ref_val)

def jac_fun(beta):
return alt_mat/(shift + alt_mat.dot(beta)[:, None]) - \
Expand Down

0 comments on commit 73fd53e

Please sign in to comment.