diff --git a/dev/index.html b/dev/index.html
index 6cfb80e..119fde4 100644
--- a/dev/index.html
+++ b/dev/index.html
@@ -80,20 +80,19 @@
Installation
-
Install the released version of bpbounds
from CRAN:
+
Install the released version of bpbounds from CRAN:
-
Or install the development version from GitHub with:
+
or from the MRCIEU R-universe
-# Uncomment the next command if you don't have the remotes packages installed.
-# The tidyverse have moved some functions out of the devtools package.
-# install.packages("remotes")
-
-# I call install_github() with these options to build the vignette.
-remotes::install_github("remlapmot/bpbounds",
- build_opts = c("--no-resave-data", "--no-manual"),
- build_vignettes = TRUE)
-
To update the development version of the package, simply run this command again.
+
install.packages("bpbounds", repos = c("https://mrcieu.r-universe.dev", "https://cloud.r-project.org"))
+Or install the development version from my r-universe
+
+install.packages("bpbounds", repos = c("https://remlapmot.r-universe.dev", "https://cloud.r-project.org"))
+Or install the development version from GitHub with:
+
+# install.packages("remotes")
+remotes::install_github("remlapmot/bpbounds")
Shiny App
diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml
index cd0bd80..119ad09 100644
--- a/dev/pkgdown.yml
+++ b/dev/pkgdown.yml
@@ -3,7 +3,7 @@ pkgdown: 2.0.9
pkgdown_sha: ~
articles:
bpbounds: bpbounds.html
-last_built: 2024-06-13T12:34Z
+last_built: 2024-06-13T12:42Z
urls:
reference: https://remlapmot.github.io/bpbounds/reference
article: https://remlapmot.github.io/bpbounds/articles
diff --git a/dev/search.json b/dev/search.json
index 7475af0..a37b120 100644
--- a/dev/search.json
+++ b/dev/search.json
@@ -1 +1 @@
-[{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"short vignette demonstrates use bpbounds package. R implementation nonparametric bounds average causal effect Balke Pearl (1997) extensions. Currently R package port bpbounds Stata package (Palmer et al. (2011)). code implements approach calculating bounds outlined Ramsahai (2007), Ramsahai (2008), Ramsahai (2012). start loading package others needed code vignette.","code":"library(bpbounds) library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(tidyr)"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"features-of-the-bpbounds-package","dir":"Articles","previous_headings":"","what":"Features of the bpbounds package","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"Currently package one function, bpbounds(), can accommodate four scenarios implemented Stata command. calculate bounds binary outcome, binary treatment/phenotype, : binary instrumental variable; 3 category instrumental variable, e.g. genotype Mendelian randomization; Bounds scenarios can calculated either trivariate data (three variables measured one dataset); bivariate data (treatment/phenotype instrument measured one dataset outcome instrument measured another sample).","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"vitamin-a-supplementation-example","dir":"Articles","previous_headings":"","what":"Vitamin A supplementation example","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"example taken Table 1 Balke Pearl (1997). study Vitamin supplementation consisting children 450 villages. , 221 villages assigned control 229 treatment. outcome mortality. First setup data.frame cell counts convert table. follow notation x received treatment, y outcome, z randomized treatment (instrumental variable). Next use prop.table() calculate conditional probabilities, \\(P(Y,X|Z)\\), run bpbounds() assuming data trivariate. Although call bpbounds() using table cell counts xt directly, .e. bpbounds(xt). Therefore, average causal effect bounded -0.1946 0.0054. estimate ACE found \\[\\text{ACE} = \\frac{\\text{cov}(Y,Z)}{\\text{cov}(X,Z)}\\] follows.","code":"tab1dat <- data.frame( z = c(0, 0, 1, 1, 1, 1, 0, 0), x = c(0, 0, 0, 0, 1, 1, 1, 1), y = c(0, 1, 0, 1, 0, 1, 0, 1), freq = c(74, 11514, 34, 2385, 12, 9663, 0, 0) ) tab1inddat <- uncount(tab1dat, freq) xt <- xtabs(~ x + y + z, data = tab1inddat) xt #> , , z = 0 #> #> y #> x 0 1 #> 0 74 11514 #> 1 0 0 #> #> , , z = 1 #> #> y #> x 0 1 #> 0 34 2385 #> 1 12 9663 p <- prop.table(xt, margin = 3) p #> , , z = 0 #> #> y #> x 0 1 #> 0 0.0063859165 0.9936140835 #> 1 0.0000000000 0.0000000000 #> #> , , z = 1 #> #> y #> x 0 1 #> 0 0.0028113114 0.1972052257 #> 1 0.0009922276 0.7989912353 bpres <- bpbounds(p) sbp <- summary(bpres) print(sbp) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 covyz <- cov(tab1inddat$y, tab1inddat$z) covxz <- cov(tab1inddat$x, tab1inddat$z) ace <- covyz / covxz ace #> [1] 0.003228039"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"entering-the-data-as-conditional-probabilities","dir":"Articles","previous_headings":"Vitamin A supplementation example","what":"Entering the data as conditional probabilities","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"already know conditional probabilities pass bpbounds() follows.","code":"condprob <- c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp <- array(condprob, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) )) %>% as.table() bpbounds(tabp) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"treating-the-data-as-bivariate","dir":"Articles","previous_headings":"Vitamin A supplementation example","what":"Treating the data as bivariate","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"demonstrate features command can treat data bivariate.","code":"gtab <- xtabs( ~ y + z, data = tab1inddat) gp <- prop.table(gtab, margin = 2) gp #> z #> y 0 1 #> 0 0.006385916 0.003803539 #> 1 0.993614084 0.996196461 ttab <- xtabs( ~ x + z, data = tab1inddat) tp <- prop.table(ttab, margin = 2) tp #> z #> x 0 1 #> 0 1.0000000 0.2000165 #> 1 0.0000000 0.7999835 bpres2 <- bpbounds(p = gp, t = tp, fmt = \"bivariate\") sbp2 <- summary(bpres2) print(sbp2) #> #> Data: bivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1974342 0.006385916 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7961799 1.196212998 #> CRR 0.8012969 1.203901009 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1974342 0.006385916 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7961799 1.002582378 #> CRR 0.8012969 1.009025933"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"mendelian-randomization-example","dir":"Articles","previous_headings":"","what":"Mendelian randomization example","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"Mendelian randomization approach epidemiology due Davey Smith Ebrahim (2003) genotypes established robustly associated phenotypes used instrumental variables order better estimate causal effect phenotype disease outcome. example uses data Meleady et al. (2003). trivariate data 3 category instrument binary phenotype outcomes. instrument 677CT polymorphism (rs1801133) Methylenetetrahydrofolate Reductase gene, involved folate metabolism, instrumental variable investigate effect homocysteine cardiovascular disease. data presented us conditional probabilities, take care enter correct position vectors. see example monotonicity inequality satisfied.","code":"mt3 <- c(.83, .05, .11, .01, .88, .06, .05, .01, .72, .05, .20, .03) p3 = array(mt3, dim = c(2, 2, 3), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1, 2) )) p3 <- as.table(p3) bpres3 <- bpbounds(p3) sbp3 <- summary(bpres3) print(sbp3) #> #> Data: trivariate #> Instrument categories: 3 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.09 0.74000 #> P(Y|do(X=0)) 0.06 0.12000 #> P(Y|do(X=1)) 0.03 0.80000 #> CRR 0.25 13.33333 #> #> Monotonicity inequality: FALSE"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"simulated-example-that-does-not-satisy-the-iv-conditions","dir":"Articles","previous_headings":"","what":"Simulated example that does not satisy the IV conditions","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"example recreates found section 8.3 Stata Journal paper uses simulated data show IV inequality always detect violations underlying model assumptions. simulate two outcomes, y1 y2, assumptions violated direct effect instrument, z, outcome. However, direct effect y2 much smaller magnitude direct effect y1. Due strong direct effect instrument outcome, instrumental variable monotonicity inequalities satisifed. However, weaker direct effect see satisfied true underlying data generating model satisfy instrumental variable assumptions.","code":"set.seed(2232011) n <- 10000 z <- rbinom(n, 1, .5) u <- rbinom(n, 1, .5) px <- .05 + .1 * z + .1 * u x <- rbinom(n, 1, px) p1 <- .1 + .2 * z + .05 * x + .1 * u y1 <- rbinom(n, 1, p1) p2 <- .1 + .05 * z + .05 * x + .1 * u y2 <- rbinom(n, 1, p2) tab1 <- xtabs(~ x + y1 + z) p1 <- prop.table(tab1, margin = 3) bpres1 <- bpbounds(p1) sbp1 <- summary(bpres1) print(sbp1) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: FALSE #> #> Monotonicity inequality: FALSE tab2 <- xtabs(~ x + y2 + z) p2 <- prop.table(tab2, margin = 3) bpres2 <- bpbounds(p2) sbp2 <- summary(bpres2) print(sbp2) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.18711965 0.6700688 #> P(Y|do(X=0)) 0.17159525 0.2384172 #> P(Y|do(X=1)) 0.05129753 0.8416640 #> CRR 0.21515868 4.9049378 #> #> Monotonicity inequality: FALSE"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"conclusion, demonstrated use bpbounds package implementing nonparametric bounds average causal effect range data scenarios.","code":""},{"path":[]},{"path":"https://remlapmot.github.io/bpbounds/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Tom Palmer. Author, maintainer. Roland Ramsahai. Author. Vanessa Didelez. Author. Nuala Sheehan. Author.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Palmer T, Ramsahai R, Didelez V, Sheehan N (2018). bpbounds: R package implementing Balke-Pearl bounds average causal effect. https://github.com/remlapmot/bpbounds.","code":"@Manual{bpbounds-package, author = {T.M. Palmer and R. Ramsahai and V. Didelez and N.A. Sheehan}, title = {bpbounds: R package implementing Balke-Pearl bounds for the average causal effect}, year = {2018}, url = {https://github.com/remlapmot/bpbounds}, }"},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"bpbounds-nonparametric-bounds-for-the-average-causal-effect-for-one-sample-bivariate-and-two-sample-trivariate-data","dir":"","previous_headings":"","what":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"R package implementing nonparametric bounds average causal effect Balke Pearl (1997).","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Install released version bpbounds CRAN: install development version GitHub : update development version package, simply run command .","code":"install.packages(\"bpbounds\") # Uncomment the next command if you don't have the remotes packages installed. # The tidyverse have moved some functions out of the devtools package. # install.packages(\"remotes\") # I call install_github() with these options to build the vignette. remotes::install_github(\"remlapmot/bpbounds\", build_opts = c(\"--no-resave-data\", \"--no-manual\"), build_vignettes = TRUE)"},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"shiny-app","dir":"","previous_headings":"","what":"Shiny App","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Shiny app demonstrating package : https://remlapmot.shinyapps.io/bpbounds.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"package-website","dir":"","previous_headings":"","what":"Package website","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"helpfiles vignette shown package website : https://remlapmot.github.io/bpbounds/.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"authors","dir":"","previous_headings":"","what":"Authors","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Tom Palmer (maintainer, tom.palmer@bristol.ac.uk), Roland Ramsahai, Vanessa Didelez, Nuala Sheehan.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Balke , Pearl J. Bounds Treatment Effects studies imperfect compliance. Journal American Statistical Association, 1997, 92, 439, 1171-1176, doi: 10.1080/01621459.1997.10474074.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds-package.html","id":null,"dir":"Reference","previous_headings":"","what":"bpbounds: Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions — bpbounds-package","title":"bpbounds: Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions — bpbounds-package","text":"Implementation nonparametric bounds average causal effect instrumental variable model Balke Pearl (Bounds Treatment Effects Studies Imperfect Compliance, JASA, 1997, 92, 439, 1171-1176, doi:10.2307/2965583 ). package can calculate bounds binary outcome, binary treatment/phenotype, instrument either 2 3 categories. package implements bounds situations 3 variables measured dataset (trivariate data) outcome instrument measured one study treatment/phenotype instrument measured another study (bivariate data).","code":""},{"path":[]},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"bpbounds: Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions — bpbounds-package","text":"Maintainer: Tom Palmer remlapmot@hotmail.com (ORCID) Authors: Roland Ramsahai (ORCID) Vanessa Didelez (ORCID) Nuala Sheehan (ORCID)","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":null,"dir":"Reference","previous_headings":"","what":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"Nonparametric Bounds Average Causal Effect due Balke Pearl.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"","code":"bpbounds(p, t = NULL, fmt = \"trivariate\")"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"p Object class \"table\" containing either cell counts conditional probabilities. trivariate data phenotype/treatment-outcome association given Z, .e. P(X, Y | Z). Cell counts generated xtabs(~ x + y + z, data = data). conditional probabilities obatained calling prop.table(..., margins = 3) object xtabs(). know conditional probabilities can enter , e.g. Balke Pearl Vitamin example: call bpbounds() using object. bivariate data object contains cell conditional probabilities outcome-instrument (Y|Z) association. t Specified bivariate data. Object treatment/phenotype-instrument cell counts conditional probabilities, .e. (X|Z). fmt character string sould either \"bivariate\" (.e. X, Z one dataset Y, Z another dataset) \"trivariate\" (X, Y, Z dataset).","code":"cp <- c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp <- as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) ))"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"List following elements: fmt whether data bivariate trivariate nzcats 2 3, . instrument categories inequality Logical, indicating whether IV inquality satisfied bplb Lower bound ACE bpub Upper bound ACE bplower Vector lower bound probabilities bpupper Vector upper bound probabilities p11low Lower bound P(Y=1|(X=1)) p11upp Upper bound P(Y=1|(X=1)) p10low Lower bound P(Y=1|(X=0)) p10upp Upper bound P(Y=1|(X=0)) p11lower Vector probabilities lower bound P(Y=1|(X=1)) p11upper Vector probabilities upper bound P(Y=1|(X=1)) p10lower Vector probabilities lower bound P(Y=1|(X=0)) p10upper Vector probabilities upper bound P(Y=1|(X=0)) crrlb Lower bound CRR crrub Upper bound CRR monoinequality Logical, indicating whether monoticity inequality satisfied monobplb Lower bound ACE assuming monotonicity monobpub Upper bound ACE assuming monotonicity monobplower Vector probabilities lower bound ACE assuming monotonicity monobpupper Vector probabilities upper bound ACE assuming monotonicity monop11low Lower bound P(Y=1|(X=1)) assuming monotonicity monop11upp Upper bound P(Y=1|(X=1)) assuming monotonicity monop10low Lower bound P(Y=1|(X=0)) assuming monotonicity monop10upp Upper bound P(Y=1|(X=0)) assuming monotonicity monop11lower Vector corresponding bound monop11upper Vector corresponding bound monop10lower Vector corresponding bound monop10upper Vector corresponding bound monocrrlb Lower bound CRR assuming monotonicity monocrrub Upper bound CRR assuming monotonicity","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"","code":"# \\donttest{ # Vitamin A example, using cell counts require(tidyr) #> Loading required package: tidyr require(bpbounds) tab1dat <- data.frame( z = c(0, 0, 1, 1, 1, 1, 0, 0), x = c(0, 0, 0, 0, 1, 1, 1, 1), y = c(0, 1, 0, 1, 0, 1, 0, 1), freq = c(74, 11514, 34, 2385, 12, 9663, 0, 0) ) tab1inddat <- uncount(tab1dat, freq) xt <- xtabs(~ x + y + z, data = tab1inddat) p <- prop.table(xt, margin = 3) bpres <- bpbounds(p) sbpres <- summary(bpres) print(sbpres) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 #> # } # \\donttest{ # Vitamin A example, using conditional probabilities require(bpbounds) cp = c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp = as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) )) bpbounds(tabp) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435 #> # }"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":null,"dir":"Reference","previous_headings":"","what":"Run Shiny App demonstrating the package — runExample","title":"Run Shiny App demonstrating the package — runExample","text":"Run Shiny App demonstrating package","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run Shiny App demonstrating the package — runExample","text":"","code":"runExample(...)"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run Shiny App demonstrating the package — runExample","text":"... passed shiny::runApp(), e.g. port, launch.browser","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run Shiny App demonstrating the package — runExample","text":"","code":"if (interactive() && requireNamespace(\"shiny\", quietly = TRUE)) { bpbounds::runExample() }"},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-0159000","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.5.9000","title":"bpbounds 0.1.5.9000","text":"Tweak formatting code helpfile examples vignette Bumped minimum required version R least 4.0.0 now required evaluate, dependency knitr. Bumped version roxygen2 used create package documentation Minor edits README.md","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-015","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.5","title":"bpbounds 0.1.5","text":"CRAN release: 2023-05-03 Additional email address affiliation edits. Remove LazyData DESCRIPTION. Update roxygen2 version number DESCRIPTION. Simplify NAMESPACE importing functions packages. Improve accompanying pkgdown site","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-014","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.4","title":"bpbounds 0.1.4","text":"CRAN release: 2020-01-21 Fixed typo vignette. Changed email address.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-013","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.3","title":"bpbounds 0.1.3","text":"CRAN release: 2019-02-10 Added Nuala’s ORCID DESCRIPTION.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-012","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.2","title":"bpbounds 0.1.2","text":"Added Roland’s ORCID DESCRIPTION.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-011","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.1","title":"bpbounds 0.1.1","text":"CRAN release: 2018-12-19 Added runExample() launch Shiny App included ./inst/shiny-examples/myapp .","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-010","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.0","title":"bpbounds 0.1.0","text":"CRAN release: 2018-11-18 R version bpbounds Stata command distributed Palmer et al., Stata Journal, 2011, 11, 3, 345-367 https://www.stata-journal.com/article.html?article=st0232. First submission CRAN.","code":""}]
+[{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"short vignette demonstrates use bpbounds package. R implementation nonparametric bounds average causal effect Balke Pearl (1997) extensions. Currently R package port bpbounds Stata package (Palmer et al. (2011)). code implements approach calculating bounds outlined Ramsahai (2007), Ramsahai (2008), Ramsahai (2012). start loading package others needed code vignette.","code":"library(bpbounds) library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(tidyr)"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"features-of-the-bpbounds-package","dir":"Articles","previous_headings":"","what":"Features of the bpbounds package","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"Currently package one function, bpbounds(), can accommodate four scenarios implemented Stata command. calculate bounds binary outcome, binary treatment/phenotype, : binary instrumental variable; 3 category instrumental variable, e.g. genotype Mendelian randomization; Bounds scenarios can calculated either trivariate data (three variables measured one dataset); bivariate data (treatment/phenotype instrument measured one dataset outcome instrument measured another sample).","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"vitamin-a-supplementation-example","dir":"Articles","previous_headings":"","what":"Vitamin A supplementation example","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"example taken Table 1 Balke Pearl (1997). study Vitamin supplementation consisting children 450 villages. , 221 villages assigned control 229 treatment. outcome mortality. First setup data.frame cell counts convert table. follow notation x received treatment, y outcome, z randomized treatment (instrumental variable). Next use prop.table() calculate conditional probabilities, \\(P(Y,X|Z)\\), run bpbounds() assuming data trivariate. Although call bpbounds() using table cell counts xt directly, .e. bpbounds(xt). Therefore, average causal effect bounded -0.1946 0.0054. estimate ACE found \\[\\text{ACE} = \\frac{\\text{cov}(Y,Z)}{\\text{cov}(X,Z)}\\] follows.","code":"tab1dat <- data.frame( z = c(0, 0, 1, 1, 1, 1, 0, 0), x = c(0, 0, 0, 0, 1, 1, 1, 1), y = c(0, 1, 0, 1, 0, 1, 0, 1), freq = c(74, 11514, 34, 2385, 12, 9663, 0, 0) ) tab1inddat <- uncount(tab1dat, freq) xt <- xtabs(~ x + y + z, data = tab1inddat) xt #> , , z = 0 #> #> y #> x 0 1 #> 0 74 11514 #> 1 0 0 #> #> , , z = 1 #> #> y #> x 0 1 #> 0 34 2385 #> 1 12 9663 p <- prop.table(xt, margin = 3) p #> , , z = 0 #> #> y #> x 0 1 #> 0 0.0063859165 0.9936140835 #> 1 0.0000000000 0.0000000000 #> #> , , z = 1 #> #> y #> x 0 1 #> 0 0.0028113114 0.1972052257 #> 1 0.0009922276 0.7989912353 bpres <- bpbounds(p) sbp <- summary(bpres) print(sbp) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 covyz <- cov(tab1inddat$y, tab1inddat$z) covxz <- cov(tab1inddat$x, tab1inddat$z) ace <- covyz / covxz ace #> [1] 0.003228039"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"entering-the-data-as-conditional-probabilities","dir":"Articles","previous_headings":"Vitamin A supplementation example","what":"Entering the data as conditional probabilities","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"already know conditional probabilities pass bpbounds() follows.","code":"condprob <- c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp <- array(condprob, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) )) %>% as.table() bpbounds(tabp) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"treating-the-data-as-bivariate","dir":"Articles","previous_headings":"Vitamin A supplementation example","what":"Treating the data as bivariate","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"demonstrate features command can treat data bivariate.","code":"gtab <- xtabs( ~ y + z, data = tab1inddat) gp <- prop.table(gtab, margin = 2) gp #> z #> y 0 1 #> 0 0.006385916 0.003803539 #> 1 0.993614084 0.996196461 ttab <- xtabs( ~ x + z, data = tab1inddat) tp <- prop.table(ttab, margin = 2) tp #> z #> x 0 1 #> 0 1.0000000 0.2000165 #> 1 0.0000000 0.7999835 bpres2 <- bpbounds(p = gp, t = tp, fmt = \"bivariate\") sbp2 <- summary(bpres2) print(sbp2) #> #> Data: bivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1974342 0.006385916 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7961799 1.196212998 #> CRR 0.8012969 1.203901009 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1974342 0.006385916 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7961799 1.002582378 #> CRR 0.8012969 1.009025933"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"mendelian-randomization-example","dir":"Articles","previous_headings":"","what":"Mendelian randomization example","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"Mendelian randomization approach epidemiology due Davey Smith Ebrahim (2003) genotypes established robustly associated phenotypes used instrumental variables order better estimate causal effect phenotype disease outcome. example uses data Meleady et al. (2003). trivariate data 3 category instrument binary phenotype outcomes. instrument 677CT polymorphism (rs1801133) Methylenetetrahydrofolate Reductase gene, involved folate metabolism, instrumental variable investigate effect homocysteine cardiovascular disease. data presented us conditional probabilities, take care enter correct position vectors. see example monotonicity inequality satisfied.","code":"mt3 <- c(.83, .05, .11, .01, .88, .06, .05, .01, .72, .05, .20, .03) p3 = array(mt3, dim = c(2, 2, 3), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1, 2) )) p3 <- as.table(p3) bpres3 <- bpbounds(p3) sbp3 <- summary(bpres3) print(sbp3) #> #> Data: trivariate #> Instrument categories: 3 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.09 0.74000 #> P(Y|do(X=0)) 0.06 0.12000 #> P(Y|do(X=1)) 0.03 0.80000 #> CRR 0.25 13.33333 #> #> Monotonicity inequality: FALSE"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"simulated-example-that-does-not-satisy-the-iv-conditions","dir":"Articles","previous_headings":"","what":"Simulated example that does not satisy the IV conditions","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"example recreates found section 8.3 Stata Journal paper uses simulated data show IV inequality always detect violations underlying model assumptions. simulate two outcomes, y1 y2, assumptions violated direct effect instrument, z, outcome. However, direct effect y2 much smaller magnitude direct effect y1. Due strong direct effect instrument outcome, instrumental variable monotonicity inequalities satisifed. However, weaker direct effect see satisfied true underlying data generating model satisfy instrumental variable assumptions.","code":"set.seed(2232011) n <- 10000 z <- rbinom(n, 1, .5) u <- rbinom(n, 1, .5) px <- .05 + .1 * z + .1 * u x <- rbinom(n, 1, px) p1 <- .1 + .2 * z + .05 * x + .1 * u y1 <- rbinom(n, 1, p1) p2 <- .1 + .05 * z + .05 * x + .1 * u y2 <- rbinom(n, 1, p2) tab1 <- xtabs(~ x + y1 + z) p1 <- prop.table(tab1, margin = 3) bpres1 <- bpbounds(p1) sbp1 <- summary(bpres1) print(sbp1) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: FALSE #> #> Monotonicity inequality: FALSE tab2 <- xtabs(~ x + y2 + z) p2 <- prop.table(tab2, margin = 3) bpres2 <- bpbounds(p2) sbp2 <- summary(bpres2) print(sbp2) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.18711965 0.6700688 #> P(Y|do(X=0)) 0.17159525 0.2384172 #> P(Y|do(X=1)) 0.05129753 0.8416640 #> CRR 0.21515868 4.9049378 #> #> Monotonicity inequality: FALSE"},{"path":"https://remlapmot.github.io/bpbounds/dev/articles/bpbounds.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Nonparametric bounds for the average causal effect: bpbounds examples","text":"conclusion, demonstrated use bpbounds package implementing nonparametric bounds average causal effect range data scenarios.","code":""},{"path":[]},{"path":"https://remlapmot.github.io/bpbounds/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Tom Palmer. Author, maintainer. Roland Ramsahai. Author. Vanessa Didelez. Author. Nuala Sheehan. Author.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Palmer T, Ramsahai R, Didelez V, Sheehan N (2018). bpbounds: R package implementing Balke-Pearl bounds average causal effect. https://github.com/remlapmot/bpbounds.","code":"@Manual{bpbounds-package, author = {T.M. Palmer and R. Ramsahai and V. Didelez and N.A. Sheehan}, title = {bpbounds: R package implementing Balke-Pearl bounds for the average causal effect}, year = {2018}, url = {https://github.com/remlapmot/bpbounds}, }"},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"bpbounds-nonparametric-bounds-for-the-average-causal-effect-for-one-sample-bivariate-and-two-sample-trivariate-data","dir":"","previous_headings":"","what":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"R package implementing nonparametric bounds average causal effect Balke Pearl (1997).","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Install released version bpbounds CRAN: MRCIEU R-universe install development version r-universe install development version GitHub :","code":"install.packages(\"bpbounds\") install.packages(\"bpbounds\", repos = c(\"https://mrcieu.r-universe.dev\", \"https://cloud.r-project.org\")) install.packages(\"bpbounds\", repos = c(\"https://remlapmot.r-universe.dev\", \"https://cloud.r-project.org\")) # install.packages(\"remotes\") remotes::install_github(\"remlapmot/bpbounds\")"},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"shiny-app","dir":"","previous_headings":"","what":"Shiny App","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Shiny app demonstrating package : https://remlapmot.shinyapps.io/bpbounds.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"package-website","dir":"","previous_headings":"","what":"Package website","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"helpfiles vignette shown package website : https://remlapmot.github.io/bpbounds/.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"authors","dir":"","previous_headings":"","what":"Authors","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Tom Palmer (maintainer, tom.palmer@bristol.ac.uk), Roland Ramsahai, Vanessa Didelez, Nuala Sheehan.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions","text":"Balke , Pearl J. Bounds Treatment Effects studies imperfect compliance. Journal American Statistical Association, 1997, 92, 439, 1171-1176, doi: 10.1080/01621459.1997.10474074.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds-package.html","id":null,"dir":"Reference","previous_headings":"","what":"bpbounds: Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions — bpbounds-package","title":"bpbounds: Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions — bpbounds-package","text":"Implementation nonparametric bounds average causal effect instrumental variable model Balke Pearl (Bounds Treatment Effects Studies Imperfect Compliance, JASA, 1997, 92, 439, 1171-1176, doi:10.2307/2965583 ). package can calculate bounds binary outcome, binary treatment/phenotype, instrument either 2 3 categories. package implements bounds situations 3 variables measured dataset (trivariate data) outcome instrument measured one study treatment/phenotype instrument measured another study (bivariate data).","code":""},{"path":[]},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"bpbounds: Nonparametric Bounds for the Average Causal Effect Due to Balke and Pearl and Extensions — bpbounds-package","text":"Maintainer: Tom Palmer remlapmot@hotmail.com (ORCID) Authors: Roland Ramsahai (ORCID) Vanessa Didelez (ORCID) Nuala Sheehan (ORCID)","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":null,"dir":"Reference","previous_headings":"","what":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"Nonparametric Bounds Average Causal Effect due Balke Pearl.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"","code":"bpbounds(p, t = NULL, fmt = \"trivariate\")"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"p Object class \"table\" containing either cell counts conditional probabilities. trivariate data phenotype/treatment-outcome association given Z, .e. P(X, Y | Z). Cell counts generated xtabs(~ x + y + z, data = data). conditional probabilities obatained calling prop.table(..., margins = 3) object xtabs(). know conditional probabilities can enter , e.g. Balke Pearl Vitamin example: call bpbounds() using object. bivariate data object contains cell conditional probabilities outcome-instrument (Y|Z) association. t Specified bivariate data. Object treatment/phenotype-instrument cell counts conditional probabilities, .e. (X|Z). fmt character string sould either \"bivariate\" (.e. X, Z one dataset Y, Z another dataset) \"trivariate\" (X, Y, Z dataset).","code":"cp <- c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp <- as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) ))"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"List following elements: fmt whether data bivariate trivariate nzcats 2 3, . instrument categories inequality Logical, indicating whether IV inquality satisfied bplb Lower bound ACE bpub Upper bound ACE bplower Vector lower bound probabilities bpupper Vector upper bound probabilities p11low Lower bound P(Y=1|(X=1)) p11upp Upper bound P(Y=1|(X=1)) p10low Lower bound P(Y=1|(X=0)) p10upp Upper bound P(Y=1|(X=0)) p11lower Vector probabilities lower bound P(Y=1|(X=1)) p11upper Vector probabilities upper bound P(Y=1|(X=1)) p10lower Vector probabilities lower bound P(Y=1|(X=0)) p10upper Vector probabilities upper bound P(Y=1|(X=0)) crrlb Lower bound CRR crrub Upper bound CRR monoinequality Logical, indicating whether monoticity inequality satisfied monobplb Lower bound ACE assuming monotonicity monobpub Upper bound ACE assuming monotonicity monobplower Vector probabilities lower bound ACE assuming monotonicity monobpupper Vector probabilities upper bound ACE assuming monotonicity monop11low Lower bound P(Y=1|(X=1)) assuming monotonicity monop11upp Upper bound P(Y=1|(X=1)) assuming monotonicity monop10low Lower bound P(Y=1|(X=0)) assuming monotonicity monop10upp Upper bound P(Y=1|(X=0)) assuming monotonicity monop11lower Vector corresponding bound monop11upper Vector corresponding bound monop10lower Vector corresponding bound monop10upper Vector corresponding bound monocrrlb Lower bound CRR assuming monotonicity monocrrub Upper bound CRR assuming monotonicity","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/bpbounds.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Nonparametric Bounds for the Average Causal Effect due to Balke and Pearl. — bpbounds","text":"","code":"# \\donttest{ # Vitamin A example, using cell counts require(tidyr) #> Loading required package: tidyr require(bpbounds) tab1dat <- data.frame( z = c(0, 0, 1, 1, 1, 1, 0, 0), x = c(0, 0, 0, 0, 1, 1, 1, 1), y = c(0, 1, 0, 1, 0, 1, 0, 1), freq = c(74, 11514, 34, 2385, 12, 9663, 0, 0) ) tab1inddat <- uncount(tab1dat, freq) xt <- xtabs(~ x + y + z, data = tab1inddat) p <- prop.table(xt, margin = 3) bpres <- bpbounds(p) sbpres <- summary(bpres) print(sbpres) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946228 0.005393689 #> P(Y|do(X=0)) 0.9936141 0.993614084 #> P(Y|do(X=1)) 0.7989912 0.999007772 #> CRR 0.8041263 1.005428354 #> # } # \\donttest{ # Vitamin A example, using conditional probabilities require(bpbounds) cp = c(.0064, 0, .9936, 0, .0028, .001, .1972, .799) tabp = as.table(array( cp, dim = c(2, 2, 2), dimnames = list( x = c(0, 1), y = c(0, 1), z = c(0, 1) ) )) bpbounds(tabp) #> #> Data: trivariate #> Instrument categories: 2 #> #> Instrumental inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435 #> #> Monotonicity inequality: TRUE #> Causal parameter Lower bound Upper bound #> ACE -0.1946000 0.005400 #> P(Y|do(X=0)) 0.9936000 0.993600 #> P(Y|do(X=1)) 0.7990000 0.999000 #> CRR 0.8041465 1.005435 #> # }"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":null,"dir":"Reference","previous_headings":"","what":"Run Shiny App demonstrating the package — runExample","title":"Run Shiny App demonstrating the package — runExample","text":"Run Shiny App demonstrating package","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run Shiny App demonstrating the package — runExample","text":"","code":"runExample(...)"},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run Shiny App demonstrating the package — runExample","text":"... passed shiny::runApp(), e.g. port, launch.browser","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/reference/runExample.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run Shiny App demonstrating the package — runExample","text":"","code":"if (interactive() && requireNamespace(\"shiny\", quietly = TRUE)) { bpbounds::runExample() }"},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-0159000","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.5.9000","title":"bpbounds 0.1.5.9000","text":"Tweak formatting code helpfile examples vignette Bumped minimum required version R least 4.0.0 now required evaluate, dependency knitr. Bumped version roxygen2 used create package documentation Minor edits README.md","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-015","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.5","title":"bpbounds 0.1.5","text":"CRAN release: 2023-05-03 Additional email address affiliation edits. Remove LazyData DESCRIPTION. Update roxygen2 version number DESCRIPTION. Simplify NAMESPACE importing functions packages. Improve accompanying pkgdown site","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-014","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.4","title":"bpbounds 0.1.4","text":"CRAN release: 2020-01-21 Fixed typo vignette. Changed email address.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-013","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.3","title":"bpbounds 0.1.3","text":"CRAN release: 2019-02-10 Added Nuala’s ORCID DESCRIPTION.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-012","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.2","title":"bpbounds 0.1.2","text":"Added Roland’s ORCID DESCRIPTION.","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-011","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.1","title":"bpbounds 0.1.1","text":"CRAN release: 2018-12-19 Added runExample() launch Shiny App included ./inst/shiny-examples/myapp .","code":""},{"path":"https://remlapmot.github.io/bpbounds/dev/news/index.html","id":"bpbounds-010","dir":"Changelog","previous_headings":"","what":"bpbounds 0.1.0","title":"bpbounds 0.1.0","text":"CRAN release: 2018-11-18 R version bpbounds Stata command distributed Palmer et al., Stata Journal, 2011, 11, 3, 345-367 https://www.stata-journal.com/article.html?article=st0232. First submission CRAN.","code":""}]