Skip to content

Commit

Permalink
Merge pull request #7 from LucasKook/dev
Browse files Browse the repository at this point in the history
Documentation and speed of examples
  • Loading branch information
LucasKook authored Sep 30, 2023
2 parents ebbdaaf + 4e81968 commit 0db71fa
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tramicp
Type: Package
Title: Model-Based Feature Selection for General Response Types
Title: Model-Based Causal Feature Selection for General Response Types
Version: 0.0-1
Authors@R: c(person("Lucas", "Kook", role = c("aut", "cre"),
comment = c("ORCID" = "0000-0002-7546-7356"),
Expand Down
32 changes: 25 additions & 7 deletions R/alias.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @examples
#' set.seed(123)
#' d <- dgp_dicp(mod = "boxcox", n = 300)
#' BoxCoxICP(Y ~ X2, data = d, env = ~ E)
#' BoxCoxICP(Y ~ X2, data = d, env = ~ E, type = "wald")
#'
BoxCoxICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand All @@ -40,13 +40,17 @@ BoxCoxICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "weibull", n = 300)
#' SurvregICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' ### or
#' # survregICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' # CoxphICP(Y ~ X2, data = d, env = ~ E)
#' # coxphICP(Y ~ X2, data = d, env = ~ E)
#' library("survival")
#' d$Y <- Surv(d$Y)
#' survregICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' CoxphICP(Y ~ X2, data = d, env = ~ E)
#' coxphICP(Y ~ X2, data = d, env = ~ E)
#' }
#'
SurvregICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand Down Expand Up @@ -107,9 +111,11 @@ coxphICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "colr", n = 300)
#' ColrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E, type = "wald", test = "wald")
#' ColrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' }
#'
ColrICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand Down Expand Up @@ -152,9 +158,11 @@ CoxphICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "coxph", n = 300)
#' LehmannICP(Y ~ X2, data = d, env = ~ E)
#' }
#'
LehmannICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand All @@ -177,11 +185,13 @@ LehmannICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "lm", n = 300)
#' LmICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' ### or
#' # lmICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' lmICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' }
#'
LmICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand Down Expand Up @@ -223,11 +233,13 @@ lmICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "polr", n = 300)
#' PolrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' ### or
#' # PolrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' PolrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' }
#'
PolrICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand Down Expand Up @@ -292,9 +304,11 @@ residuals.polr <- function(object, ...) {
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "binary", n = 300)
#' glmICP(Y ~ X1 + X2 + X3, data = d, env = ~ E, family = "binomial")
#' }
#'
glmICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand Down Expand Up @@ -327,9 +341,11 @@ glmICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "cotram", n = 300)
#' cotramICP(Y ~ X2, data = d, env = ~ E)
#' }
#'
cotramICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand All @@ -352,9 +368,11 @@ cotramICP <- function(formula, data, env, verbose = TRUE, type = "residual",
#' @export
#'
#' @examples
#' \donttest{
#' set.seed(123)
#' d <- dgp_dicp(mod = "binary", n = 300)
#' rangerICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' }
#'
rangerICP <- function(formula, data, env, verbose = TRUE, type = "residual",
test = "gcm.test", controls = NULL, alpha = 0.05,
Expand Down
2 changes: 1 addition & 1 deletion R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ summary.dICP <- function(object, print_all = FALSE, digits = 3, ...) {
#' @examples
#' set.seed(123)
#' d <- dgp_dicp(n = 1e3, mod = "polr")
#' res <- PolrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E)
#' res <- polrICP(Y ~ X1 + X2 + X3, data = d, env = ~ E, type = "wald")
#' pvalues(res, which = "predictor")
#' pvalues(res, which = "set")
#' pvalues(res, which = "all")
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ described in [the paper](https://doi.org/10.48550/arXiv.2309.12833).

# Installation

The `tramicp` package can be installed via:
The development version of `tramicp` package can be installed via:
```r
# install.packages("remotes")
remotes::install_github("LucasKook/tramicp")
```

A stable version is available on [CRAN](https://CRAN.R-project.org/package=tramicp):
```r
install.packages("tramicp")
```

# Using package `tramicp`

Consider the following data simulated from a structural causal model:
Expand Down
2 changes: 1 addition & 1 deletion man/pvalues.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 25 additions & 7 deletions man/tramicp-alias.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0db71fa

Please sign in to comment.