项目作者: kkholst

项目描述 :
Target: library for targeted inference https://targetlib.org/
高级语言: CMake
项目地址: git://github.com/kkholst/target.git
创建时间: 2020-04-09T13:36:01Z
项目社区:https://github.com/kkholst/target

开源协议:Apache License 2.0

下载


NOTE: Development has moved to https://github.com/kkholst/targeted

License
Build
Status
codecov

CRAN
PyPIversion
RTD

Introduction

This library provides C++ classes for targeted inference
and semi-parametric efficient estimators as
well as bindings for python and R. The library also contains
implementation of parametric models (including different discrete
choice models) and model diagnostics tools.

Relevant models includes binary regression models with binary exposure
and with nuisance models defined by additional covariates. Models for
the relative risk and risk differences where examined by (Richardson
et al 2017). Various missing data estimators and causal inference models
(Bang & Robins 2005, Tsiatis 2006) also fits into this framework.

Documentation

The main documentation can be found here:
https://targetlib.org/ (PDF version)

Examples

R

https://kkholst.github.io/targeted

  1. library('targeted')
  2. # Simulation
  3. m <- lvm(y[-2] ~ 1*x,
  4. lp.target[1] ~ 1,
  5. lp.nuisance[-1] ~ 2*x)
  6. distribution(m, ~a) <- binomial.lvm('logit')
  7. m <- binomial.rr(m, 'y', 'a', 'lp.target', 'lp.nuisance')
  8. dd <- sim(m, 5e2, seed=1)
  9. # Double-robust estimator
  10. summary(fit <- targeted::riskreg(y ~ a | 1 | x | x, data=dd, type="rr"))
  11. #
  12. # Relative risk model
  13. # Response: y
  14. # Exposure: a
  15. #
  16. # Estimate Std.Err 2.5% 97.5% P-value
  17. # log(RR):
  18. # (Intercept) 0.86136 0.11574 0.6345 1.08820 9.895e-14
  19. # log(OP):
  20. # (Intercept) -0.88518 0.22802 -1.3321 -0.43827 1.036e-04
  21. # x 2.35193 0.28399 1.7953 2.90854 1.213e-16
  22. # logit(Pr):
  23. # (Intercept) -0.07873 0.08857 -0.2523 0.09485 3.740e-01
  24. # x 0.02894 0.08291 -0.1336 0.19145 7.270e-01

Python

https://pypi.org/project/targeted/

  1. import targeted as tg
  2. from targeted.formula import riskreg
  3. d = tg.getdata()
  4. val = riskreg(d, 'y~a', interaction='x', nuisance='x+z')
  5. print(val)
  6. ## Riskreg. Estimate: [ 1.17486406 -0.23623467]

C++

https://www.targetlib.org/cppapi/

  1. #include <target/target.h>
  2. using namespace arma;
  3. void main() {
  4. ...
  5. targeted::RR<double> model(y, a, x1, x2, x3, p, w);
  6. mat pp0 = model.TargetedBinary::pa();
  7. mat U = model.score(false);
  8. mat res = model.est(alpha);
  9. }

Installation

This program may be compiled as a shared library or as stand-alone
python and R libraries.

To compile and run the unit tests:

  1. make test

Syntax checks (requires cppcheck and cclint), code coverage,
and check for memory leaks

  1. make check coverage
  2. make valgrind

R

The R package can be built and installed with

  1. make r

Python

The python package can be installed directly from PyPi (wheels
available for Mac OS X and Linux):

  1. pip install targeted

or installed from source

  1. make py

Dependencies

The following dependencies are included as submodules:

  1. Armadillo http://arma.sourceforge.net/docs.html
  2. doctest (unit tests only) https://github.com/onqtam/doctest
  3. pybind11++ (python bindings only) https://pybind11.readthedocs.io
  4. spdlog (logging) https://github.com/gabime/spdlog