MyNixOS website logo
Description

Language to Manage Many Models.

A system for describing and manipulating the many models that are generated in causal inference and data analysis projects, as based on the causal theory and criteria of Austin Bradford Hill (1965) <doi:10.1177/003591576505800503>. This system includes the addition of formal attributes that modify base `R` objects, including terms and formulas, with a focus on variable roles in the "do-calculus" of modeling, as described in Pearl (2010) <doi:10.2202/1557-4679.1203>. For example, the definition of exposure, outcome, and interaction are implicit in the roles variables take in a formula. These premises allow for a more fluent modeling approach focusing on variable relationships, and assessing effect modification, as described by VanderWeele and Robins (2007) <doi:10.1097/EDE.0b013e318127181b>. The essential goal is to help contextualize formulas and models in causality-oriented workflows.

rmdl

Lifecycle:experimental R-CMD-check Github commitfrequency test-coverage CRANstatus

Installation

This package can be downloaded from CRAN or from Github as below

# CRAN installation
install.packages("rmdl")
# Or remote/developmental version
remotes::install_github("shah-in-boots/rmdl")

Introduction

The package rmdl was intended as a way to handle causal- and epidemiology-based modeling by the following principles:

  1. Role determination of variables
  2. Generativity in formula creation
  3. Multiple model management

Usage

The package is simple to use. The mtcars dataset will serve as the example, and we will use linear regressions as the primary test. This toy example shows that we will be building six models in parallel, with the key exposure being the wt term, and the two outcomes being mpg and hp.

library(rmdl)
#> Loading required package: vctrs
#> Loading required package: tibble
#> 
#> Attaching package: 'tibble'
#> The following object is masked from 'package:vctrs':
#> 
#>     data_frame

f <- fmls(mpg + hp ~ .x(wt) + disp + cyl + am, pattern = "parallel")
m <- fit(f, .fn = lm, data = mtcars, raw = FALSE)
mt <- model_table(mileage = m)
print(mt)
#> <mdl_tbl>
#>   id        formula_index data_id name  model_call formula_call outcome exposure
#>   <chr>     <list>        <chr>   <chr> <chr>      <chr>        <chr>   <chr>   
#> 1 b4845f79… <dbl [6]>     mtcars  mile… lm         mpg ~ wt + … mpg     wt      
#> 2 7830bcbe… <dbl [6]>     mtcars  mile… lm         mpg ~ wt + … mpg     wt      
#> 3 e3cf8431… <dbl [6]>     mtcars  mile… lm         mpg ~ wt + … mpg     wt      
#> 4 9a66d0e5… <dbl [6]>     mtcars  mile… lm         hp ~ wt + d… hp      wt      
#> 5 62f89920… <dbl [6]>     mtcars  mile… lm         hp ~ wt + c… hp      wt      
#> 6 193d7c3e… <dbl [6]>     mtcars  mile… lm         hp ~ wt + am hp      wt      
#> # ℹ 7 more variables: mediator <chr>, interaction <chr>, strata <lgl>,
#> #   level <lgl>, model_parameters <list>, model_summary <list>,
#> #   fit_status <lgl>

Classes

There are several important extended classes that this package introduces, however they are primarily used for internal validation and for shortcuts to allow more effective communication.

  • fmls are a version of the base R formula object, but contain additional information and have extra features
  • tm are atomic elements used to describe individual variables, and departs from how terms are generally treated in the {stats} package
  • mdl and mdl_tbl exist primarily as tidy versions of class regression modeling

Advanced Usage

The {rmdl} package is intended to be flexible, extensible, and easy-to-use (albeit opinionated). Please see the vignettes for additional information.

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows