GithubHelp home page GithubHelp logo

ohdsi / empiricalcalibration Goto Github PK

View Code? Open in Web Editor NEW
10.0 18.0 9.0 19.68 MB

An R package for performing empirical calibration of observational study estimates

Home Page: http://ohdsi.github.io/EmpiricalCalibration/

R 95.48% Shell 0.27% Perl 0.20% C++ 4.05%
hades

empiricalcalibration's Introduction

EmpiricalCalibration

Build Status codecov.io CRAN_Status_Badge CRAN_Status_Badge

EmpiricalCalibration is part of HADES.

Introduction

This R package contains routines for performing empirical calibration of observational study estimates. By using a set of negative control hypotheses we can estimate the empirical null distribution of a particular observational study setup. This empirical null distribution can be used to compute a calibrated p-value, which reflects the probability of observing an estimated effect size when the null hypothesis is true taking both random and systematic error into account, as described in the paper Interpreting observational studies: why empirical calibration is needed to correct p-values.

Also supported is empirical calibration of confidence intervals, based on the results for a set of negative and positive controls, as described in the paper Empirical confidence interval calibration for population-level effect estimation studies in observational healthcare data.

Features

  • Estimate the empirical null distribution given the effect estimates of a set of negative controls.
  • Estimate the calibrated p-value of a given hypothesis given the estimated empirical null distribution.
  • Estimate a systematic error distribution given the effect estimates for a set of negative and positive controls.
  • Estimate the calibrated confidence interval for a given estimate given the systematic error distribution.
  • Estimate a calibrated log likelihood ratio, for use in maximum sequential probability ratio testing (MaxSPRT).
  • Produce various plots for evaluating the empirical calibration.
  • Contains the data sets from the papers for illustration.

Screenshots and examples

Calibration effect plot

data(sccs) #Load one of the included data sets
negatives <- sccs[sccs$groundTruth == 0,] #Select the negative controls
null <- fitNull(logRr = negatives$logRr, seLogRr = negatives$seLogRr) #Fit the null distribution
positive <- sccs[sccs$groundTruth == 1,]  #Select the positive control

#Create the plot above:
plotCalibrationEffect(logRrNegatives = negatives$logRr,
                      seLogRrNegatives = negatives$seLogRr,
                      logRrPositives = positive$logRr,
                      seLogRrPositives = positive$seLogRr,
                      null = null)

#Compute the calibrated p-value:
calibrateP(null = null, logRr = positive$logRr, seLogRr = positive$seLogRr) #Compute calibrated p-value
[1] 0.8390598

Technology

This is a pure R package.

System requirements

Requires R (version 3.1.0 or newer).

Installation

In R, use the following commands to install the latest stable version from CRAN:

install.packages("EmpiricalCalibration")

To install the latest development version directly from GitHub, use:

install.packages("remotes")
library(remotes)
install_github("ohdsi/EmpiricalCalibration", ref = "develop")

User Documentation

Documentation can be found on the package website.

PDF versions of the documentation is also available:

Support

Contributing

Read here how you can contribute to this package.

License

EmpiricalCalibration is licensed under Apache License 2.0

Development

This package has been developed in RStudio.

Development status

This package is ready for use.

empiricalcalibration's People

Contributors

azimov avatar cynthiayang525 avatar egarcialara avatar hak16 avatar keesvanbochove avatar msuchard avatar rekkasa avatar schuemie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

empiricalcalibration's Issues

GGPLOT2 V3.3.0 throwing Errors

I had upgraded all my packages to run PLE and was getting this issue in plotCalibrationEffect

ggplot2::ggsave(fileName, plot, width = 6, height = 4.5, dpi = 400)

Error in frame[[1]] == ".signalSimpleWarning" : comparison (1) is possible only for atomic and list types

Rolling back GGPLOT to V3.2.0 fixed it:
devtools::install_github("tidyverse/ggplot2",ref = "v3.2.0")

plotCalibrationEffect hides extreme values

PR incoming

Bug description

When using plotCalibrationEffect with values far to the left or right they are hidden from display.

Steps to reproduce

Produce a plot with crazy values, e.g.

inputDf <- data.frame(logRr = c( 1.1, 1.3, 1, 2, 1.1, 1.3, 1, 2, 1.1, 1.3, 1, 2), seLogRr = c(0.1, 0.5, 0.3))
EmpiricalCalibration::plotCalibrationEffect(inputDf$logRr, inputDf$seLogRr, logRrPositives = c(-3,-2), seLogRrPositives = c(0.1, 1.2))

Warning: Removed 2 rows containing missing values (geom_point).

Proposed solution

Allow x axis limits to be flexible, instead of being fixed at ~0.25 - 10.

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.