Git Product home page Git Product logo

target's Introduction

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

library('targeted')

# Simulation
m <- lvm(y[-2] ~ 1*x,
         lp.target[1] ~ 1,
         lp.nuisance[-1] ~ 2*x)
distribution(m, ~a) <- binomial.lvm('logit')
m <- binomial.rr(m, 'y', 'a', 'lp.target', 'lp.nuisance')
dd <- sim(m, 5e2, seed=1)

# Double-robust estimator
summary(fit <- targeted::riskreg(y ~ a | 1 | x | x, data=dd, type="rr"))
#
#  Relative risk model
#   Response:  y
#   Exposure:  a
#
#             Estimate Std.Err    2.5%    97.5%   P-value
# log(RR):
#  (Intercept)  0.86136 0.11574  0.6345  1.08820 9.895e-14
# log(OP):
#  (Intercept) -0.88518 0.22802 -1.3321 -0.43827 1.036e-04
#  x            2.35193 0.28399  1.7953  2.90854 1.213e-16
# logit(Pr):
#  (Intercept) -0.07873 0.08857 -0.2523  0.09485 3.740e-01
#  x            0.02894 0.08291 -0.1336  0.19145 7.270e-01

Python

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

import targeted as tg
from targeted.formula import riskreg

d = tg.getdata()
val = riskreg(d, 'y~a', interaction='x', nuisance='x+z')

print(val)
## Riskreg. Estimate: [ 1.17486406 -0.23623467]

C++

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

#include <target/target.h>
using namespace arma;

void main() {

  ...

  targeted::RR<double> model(y, a, x1, x2, x3, p, w);
  mat pp0 = model.TargetedBinary::pa();
  mat U = model.score(false);
  mat res = model.est(alpha);
}

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:

make test

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

make check coverage
make valgrind

R

The R package can be built and installed with

make r

Python

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

pip install targeted

or installed from source

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

target's People

Contributors

andreas-nordland avatar georgios-vassos1 avatar kkholst avatar sangmin-lee-maersk avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

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.