README.md

Something fascinating

Georgiy Syunyaev 2017-11-05

pacman::p_load(knitr)

opts_chunk$set(include = TRUE, 
               results = "markup", 
               message = FALSE, 
               warning = FALSE, 
               error   = FALSE)

usefulr::analyses() functionality

Load the package

pacman::p_load_gh("gerasy1987/usefulr")

Linear models (model = "lm")

usefulr::analyses(DV = "gear",
                   treat = "vs",
                   model = "lm",
                   covs = NULL,
                   heterogenous = NULL,
                   cluster = "am",
                   subset = NULL,
                   FE = "carb",
                   status = c(T,T,F),
                   data = mtcars,
                   IPW = NULL,
                   treat_only = FALSE,
                   stars = FALSE)
## Call:
## usefulr::analyses(DV = "gear", treat = "vs", covs = NULL, heterogenous = NULL, 
##     subset = NULL, FE = "carb", cluster = "am", IPW = NULL, data = mtcars, 
##     model = "lm", treat_only = FALSE, status = c(T, T, F), stars = FALSE)
## 
## Estimation formula:
## [1] "gear ~ vs | carb | 0 | am"
## 
## Estimates:
##   term estimate std.error
## 1   vs    0.683     0.546
## 
## Summary:
## Adj. R2 = 0.280 , N = 32
usefulr::analyses(DV = "mpg",
                  treat = "cyl",
                  model = "lm",
                  covs = "carb",
                  heterogenous = "hp",
                  cluster = "gear",
                  subset = "disp >= 0 & disp <= 300",
                  FE = "vs",
                  status = c(T,T,F),
                  data = mtcars,
                  treat_only = TRUE,
                  stars = TRUE)
## Call:
## usefulr::analyses(DV = "mpg", treat = "cyl", covs = "carb", heterogenous = "hp", 
##     subset = "disp >= 0 & disp <= 300", FE = "vs", cluster = "gear", 
##     data = mtcars, model = "lm", treat_only = TRUE, status = c(T, 
##         T, F), stars = TRUE)
## 
## Estimation formula:
## [1] "mpg ~ cyl + cyl:hp + hp + carb | vs | 0 | gear"
## 
## Estimates:
##     term estimate std.error
## 1    cyl   -5.172     0.933
## 2 cyl:hp    0.026     0.006
## 
## Summary:
## Adj. R2 = 0.621 , N = 21

Binary outcomes models (model = "logit" or model = "probit")

usefulr::analyses(DV = "am",
                  treat = "vs",
                  model = "probit",
                  covs = "carb",
                  heterogenous = NULL,
                  cluster = "gear",
                  subset = NULL,
                  FE = NULL,
                  status = c(T,T,F),
                  data = mtcars,
                  IPW = NULL,
                  margin_at = NULL,
                  treat_only = TRUE,
                  stars = FALSE)
## Call:
## usefulr::analyses(DV = "am", treat = "vs", covs = "carb", heterogenous = NULL, 
##     subset = NULL, FE = NULL, cluster = "gear", IPW = NULL, data = mtcars, 
##     model = "probit", treat_only = TRUE, margin_at = NULL, status = c(T, 
##         T, F), stars = FALSE)
## 
## Estimation formula:
## [1] "am ~ vs + carb"
## 
## Estimates:
##   term estimate std.error
## 1   vs    0.788     0.963
## 
## Summary:
## Adj. R2 = -0.044 , N = 32
usefulr::analyses(DV = "am",
                  treat = "vs",
                  model = "logit",
                  covs = NULL,
                  heterogenous = NULL,
                  cluster = "gear",
                  subset = "disp >= 0 & disp <= 300",
                  FE = "gear",
                  status = c(F,F,F),
                  data = mtcars,
                  margin_at = TRUE,
                  treat_only = FALSE,
                  IPW = NULL,
                  stars = TRUE)
## Call:
## usefulr::analyses(DV = "am", treat = "vs", covs = NULL, heterogenous = NULL, 
##     subset = "disp >= 0 & disp <= 300", FE = "gear", cluster = "gear", 
##     IPW = NULL, data = mtcars, model = "logit", treat_only = FALSE, 
##     margin_at = TRUE, status = c(F, F, F), stars = TRUE)
## 
## Estimation formula:
## [1] "am ~ vs + factor(gear)"
## 
## Estimates:
##   term estimate std.error
## 1   vs   -2.122     0.152
## 
## Summary:
## Adj. R2 = 0.330 , N = 21

Ordered categorical outcomes (model = "ologit" or model = "oprobit")

usefulr::analyses(DV = "gear",
                  treat = "vs",
                  model = "ologit",
                  covs = NULL,
                  heterogenous = NULL,
                  cluster = "am",
                  subset = NULL,
                  FE = "am",
                  status = c(T,T,F),
                  data = mtcars,
                  margin_at = NULL,
                  IPW = NULL,
                  treat_only = FALSE,
                  stars = FALSE)
## Call:
## usefulr::analyses(DV = "gear", treat = "vs", covs = NULL, heterogenous = NULL, 
##     subset = NULL, FE = "am", cluster = "am", IPW = NULL, data = mtcars, 
##     model = "ologit", treat_only = FALSE, margin_at = NULL, status = c(T, 
##         T, F), stars = FALSE)
## 
## Estimation formula:
## [1] "gear ~ vs + factor(am)"
## 
## Estimates:
##   term estimate std.error
## 1   vs    0.552     2.794
## 
## Summary:
## Adj. R2 = 0.377 , N = 32
usefulr::analyses(DV = "gear",
                  treat = "vs",
                  model = "oprobit",
                  covs = NULL,
                  heterogenous = NULL,
                  cluster = "am",
                  subset = NULL,
                  FE = NULL,
                  status = c(T,T,F),
                  data = mtcars,
                  margin_at = "5",
                  IPW = NULL,
                  treat_only = TRUE,
                  stars = TRUE)
## Call:
## usefulr::analyses(DV = "gear", treat = "vs", covs = NULL, heterogenous = NULL, 
##     subset = NULL, FE = NULL, cluster = "am", IPW = NULL, data = mtcars, 
##     model = "oprobit", treat_only = TRUE, margin_at = "5", status = c(T, 
##         T, F), stars = TRUE)
## 
## Estimation formula:
## [1] "gear ~ vs"
## 
## Estimates:
##   term estimate std.error
## 1   vs    0.121     0.106
## 
## Summary:
## Adj. R2 = -0.005 , N = 32


gerasy1987/usefulr documentation built on Aug. 31, 2021, 4:25 p.m.