==9871== Memcheck, a memory error detector
==9871== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==9871== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==9871== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla
==9871==
R Under development (unstable) (2016-11-04 r71624) -- "Unsuffered Consequences"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> pkgname <- "treatSens"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('treatSens')
>
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("sensPlot")
> ### * sensPlot
>
> flush(stderr()); flush(stdout())
>
> ### Name: sensPlot
> ### Title: Create a contour plot sumamrizing the result of the sensitivity
> ### analysis
> ### Aliases: sensPlot
>
> ### ** Examples
>
> #See the manual for treatSens.
>
>
>
> cleanEx()
> nameEx("summary")
> ### * summary
>
> flush(stderr()); flush(stdout())
>
> ### Name: summary.sensitivity.default
> ### Title: Summarizing sensitivity analysis results
> ### Aliases: summary.sensitivity summary.sensitivity.default
>
> ### ** Examples
>
> #See treatSens documentation
>
>
>
> cleanEx()
> nameEx("treatSens")
> ### * treatSens
>
> flush(stderr()); flush(stdout())
>
> ### Name: treatSens
> ### Title: Performing Dual-Parameter Sensitivity Analysis
> ### Aliases: treatSens
>
> ### ** Examples
>
> N = 300 #number of observations
>
> zetay = .5 #coefficient on U in the outcome model
> zetaz = .5 #coefficient on U in the treatment model
> betaz = c(.75,-.5,.25) #coefficients of X in the treatment model
> betay = c(.5,1,-1.5) #coefficients of X in the outcome model
> tau = .25 #treatment effect
>
> X = matrix(rnorm(3*N),N,3) #covariates
>
> ###################################
> # Example with continuous treatment
> set.seed(836)
> U = rnorm(N, 0, 1) #unmeasured confounder
> Z = rnorm(N,X %*% betaz + zetaz*U,1) #treatment variable
> Y = rnorm(N,X %*% betay + zetay*U + tau*Z,2) #outcome variable
>
> # sensitivity analysis
> out.cont <- treatSens(Y~Z+X, grid.dim = c(8,5), nsim = 5,
+ standardize = FALSE, verbose = TRUE, zero.loc = "full")
Gaussian family with identity link function is assumed in the treatment model.
Gaussian family with identity link function is assumed in the response model.
Normally distributed continous U is assumed.
Fitting null models...
Computing final grid...
Completed 1 of 45 cells.
Completed 2 of 45 cells.
Completed 3 of 45 cells.
Completed 4 of 45 cells.
Completed 5 of 45 cells.
Completed 6 of 45 cells.
Completed 7 of 45 cells.
Completed 8 of 45 cells.
Completed 9 of 45 cells.
Completed 10 of 45 cells.
Completed 11 of 45 cells.
Completed 12 of 45 cells.
Completed 13 of 45 cells.
Completed 14 of 45 cells.
Completed 15 of 45 cells.
Completed 16 of 45 cells.
Completed 17 of 45 cells.
Completed 18 of 45 cells.
Completed 19 of 45 cells.
Completed 20 of 45 cells.
Completed 21 of 45 cells.
Completed 22 of 45 cells.
Completed 23 of 45 cells.
Completed 24 of 45 cells.
Completed 25 of 45 cells.
Completed 26 of 45 cells.
Completed 27 of 45 cells.
Completed 28 of 45 cells.
Completed 29 of 45 cells.
Completed 30 of 45 cells.
Completed 31 of 45 cells.
Completed 32 of 45 cells.
Completed 33 of 45 cells.
Completed 34 of 45 cells.
Completed 35 of 45 cells.
Completed 36 of 45 cells.
Completed 37 of 45 cells.
Completed 38 of 45 cells.
Completed 39 of 45 cells.
Completed 40 of 45 cells.
Completed 41 of 45 cells.
Completed 42 of 45 cells.
Completed 43 of 45 cells.
Completed 44 of 45 cells.
Completed 45 of 45 cells.
>
> summary(out.cont) #Prints average value of tau (trt effect) for each cell in grid.
Coefficients on U where tau = 0:
Y Z
2.003 -0.041
1.737 -0.087
1.780 -0.408
1.964 -0.729
2.003 -0.771
Coefficients on U where significance level 0.05 is lost:
Y Z
2.003 -0.024
1.640 -0.087
1.868 -0.408
1.760 -0.729
2.003 -1.019
Estimated treatment effects
-1.049 -0.729 -0.408 -0.087 0 0.087 0.408 0.729 1.049
0 0.509 0.509 0.509 0.509 0.509 0.509 0.509 0.509 0.509
0.501 0.903 0.785 0.666 0.547 0.506 0.473 0.381 0.223 0.121
1.001 1.289 1.051 0.820 0.592 0.511 0.398 0.218 -0.034 -0.298
1.502 1.697 1.391 0.961 0.632 0.526 0.401 0.053 -0.307 -0.674
2.003 2.121 1.646 1.139 0.645 0.513 0.383 -0.101 -0.576 -1.095
>
> sensPlot(out.cont) # draw contour plot
Note: Predictors with negative coefficients for the response surface have been transformed through multiplication by -1 and are displayed as inverted triangles.
> # You can see when zetay=zetaz=.5, tau is about .25.
>
> ###############################
> # Example with binary treatment
> set.seed(725)
> U = rbinom(N,1,.5) #unmeasured confounder
> ps = pnorm(X%*%betaz + zetaz*(U-.5)) #propensity score
> Z = rbinom(N,1,ps) #treatment variable
> epsilon = rnorm(N,0,2) #error term
> Y0 = X%*%betay + zetay*(U-.5) + epsilon #potential outcome(Z=0)
> Y1 = X%*%betay + zetay*(U-.5) + tau + epsilon #potential outcome(Z=1)
> Y = Y0*(1-Z) + Y1*Z #realization of potential outcome
>
> # sensitivity analysis
> out.bin <- treatSens(Y~Z+X, trt.family = binomial(link="probit"), nsim = 3,
+ spy.range = c(0,4), spz.range = c(-2,2),grid.dim = c(5,3),
+ standardize = FALSE, verbose = TRUE)
Binomial family with probit link function is assumed in the treatment model.
Gaussian family with identity link function is assumed in the response model.
Binary U with binomial distribution is assumed.
Fitting null models...
Warning in calc.range.coef(grid.dim, zetaz.range, zetay.range, buffer, U.model, :
Sensitivity parameter range for Y inconsistent with possible values given data. Range restricted.
Computing final grid...
Completed 1 of 15 cells.
Completed 2 of 15 cells.
Completed 3 of 15 cells.
Completed 4 of 15 cells.
Completed 5 of 15 cells.
Completed 6 of 15 cells.
Completed 7 of 15 cells.
Completed 8 of 15 cells.
Completed 9 of 15 cells.
Completed 10 of 15 cells.
Completed 11 of 15 cells.
Completed 12 of 15 cells.
Completed 13 of 15 cells.
Completed 14 of 15 cells.
Completed 15 of 15 cells.
>
> summary(out.bin) #Prints average value of tau (trt effect) for each cell in grid.
Coefficients on U where tau = 0:
Y Z
2.322 2.000
2.712 0.333
3.727 0.169
Coefficients on U where significance level 0.05 is lost:
Y Z
3.145 -2.000
2.149 -0.333
3.727 -0.051
Estimated treatment effects
-2 -0.333 0 0.333 2
0 0.583 0.583 0.583 0.583 0.583
1.863 1.736 0.830 0.635 0.214 -0.565
3.727 3.117 1.183 0.472 0.016 -1.784
>
> sensPlot(out.bin) # draw contour plot
Note: Predictors with negative coefficients for the response surface have been transformed through multiplication by -1 and are displayed as inverted triangles.
>
>
>
>
> cleanEx()
> nameEx("treatSensBART")
> ### * treatSensBART
>
> flush(stderr()); flush(stdout())
>
> ### Name: treatSens.BART
> ### Title: Dual-Parameter Sensitivity Analysis Using BART
> ### Aliases: treatSens.BART
>
> ### ** Examples
>
> N <- 300 # number of observations
>
> zetay <- 0.5 # coefficient on U in the outcome model
> zetaz <- 0.5 # coefficient on U in the treatment model
> betaz <- c(0.75, -0.5, 0.25) # coefficients of X in the treatment model
> betay <- c(0.5, 1.0, -1.5) # coefficients of X in the outcome model
> tau <- 0.25 # treatment effect
>
> set.seed(725)
> X <- matrix(rnorm(3 * N), N) # covariates
>
> U <- rbinom(N, 1, 0.5) # unmeasured confounder
> ps <- pnorm(X %*% betaz + zetaz * (U - 0.5)) # propensity score
> Z <- rbinom(N, 1, ps) # treatment variable
> epsilon <- rnorm(N, 0.0, 2.0) # error term
>
> Y0 <- X %*% betay + zetay * (U - 0.5) + epsilon # potential outcome(Z=0)
> Y1 <- X %*% betay + zetay * (U - 0.5) + tau + epsilon # potential outcome(Z=1)
> Y <- Y0 * (1 - Z) + Y1 * Z # realization of potential outcome
>
> # sensitivity analysis
> out.bin <- treatSens.BART(Y ~ Z + X, nsim = 3, nthin = 2, nburn = 0,
+ spy.range = c(0, 4), spz.range = c(-2 , 2), grid.dim = c(5, 3),
+ standardize = FALSE, verbose = TRUE)
Binary U with binomial distribution is assumed.
"ATE" option is selected. Sensitivity analysis is performed with the default Weights for the average treatment effect.
Weight trimming is applied. The maximum size of weights is set to 30 , which is 10 % of the size of the inferential group.
Computing final grid...
==9871== Mismatched free() / delete / delete []
==9871== at 0x4C2D22A: operator delete(void*) (/builddir/build/BUILD/valgrind-3.11.0/coregrind/m_replacemalloc/vg_replace_malloc.c:576)
==9871== by 0x14D47BDC: (anonymous namespace)::parseProcCPUInfo(std::vector<(anonymous namespace)::Processor*, std::allocator<(anonymous namespace)::Processor*> >&) [clone .constprop.76] (packages/tests-vg/treatSens/src/guessNumCores.cpp:237)
==9871== by 0x14D482B4: cibart::guessNumCores(unsigned int*, unsigned int*) (packages/tests-vg/treatSens/src/guessNumCores.cpp:345)
==9871== by 0x14D46513: (anonymous namespace)::guessNumCores() (packages/tests-vg/treatSens/src/R_interface.cpp:333)
==9871== by 0x47A790: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==9871== by 0x4B86ED: Rf_eval (svn/R-devel/src/main/eval.c:725)
==9871== by 0x4BBADD: do_set (svn/R-devel/src/main/eval.c:2230)
==9871== by 0x4B852B: Rf_eval (svn/R-devel/src/main/eval.c:697)
==9871== by 0x4BAA9B: do_begin (svn/R-devel/src/main/eval.c:1838)
==9871== by 0x4B852B: Rf_eval (svn/R-devel/src/main/eval.c:697)
==9871== by 0x4B9C6E: Rf_applyClosure (svn/R-devel/src/main/eval.c:1163)
==9871== by 0x4B8350: Rf_eval (svn/R-devel/src/main/eval.c:744)
==9871== Address 0x15532270 is 0 bytes inside a block of size 4,096 alloc'd
==9871== at 0x4C2C8F9: operator new[](unsigned long) (/builddir/build/BUILD/valgrind-3.11.0/coregrind/m_replacemalloc/vg_replace_malloc.c:423)
==9871== by 0x14D47B4B: (anonymous namespace)::parseProcCPUInfo(std::vector<(anonymous namespace)::Processor*, std::allocator<(anonymous namespace)::Processor*> >&) [clone .constprop.76] (packages/tests-vg/treatSens/src/guessNumCores.cpp:208)
==9871== by 0x14D482B4: cibart::guessNumCores(unsigned int*, unsigned int*) (packages/tests-vg/treatSens/src/guessNumCores.cpp:345)
==9871== by 0x14D46513: (anonymous namespace)::guessNumCores() (packages/tests-vg/treatSens/src/R_interface.cpp:333)
==9871== by 0x47A790: do_dotcall (svn/R-devel/src/main/dotcode.c:1252)
==9871== by 0x4B86ED: Rf_eval (svn/R-devel/src/main/eval.c:725)
==9871== by 0x4BBADD: do_set (svn/R-devel/src/main/eval.c:2230)
==9871== by 0x4B852B: Rf_eval (svn/R-devel/src/main/eval.c:697)
==9871== by 0x4BAA9B: do_begin (svn/R-devel/src/main/eval.c:1838)
==9871== by 0x4B852B: Rf_eval (svn/R-devel/src/main/eval.c:697)
==9871== by 0x4B9C6E: Rf_applyClosure (svn/R-devel/src/main/eval.c:1163)
==9871== by 0x4B8350: Rf_eval (svn/R-devel/src/main/eval.c:744)
==9871==
running time (seconds): 30.035615
>
> summary(out.bin) # prints average value of tau (trt effect) for each cell in grid
Coefficients on U where tau = 0:
Y Z
4.000 -0.302
3.898 -0.333
4.000 -0.506
Coefficients on U where significance level 0.05 is lost:
Y Z
0.00 -0.683
0.71 -0.333
0.00 -0.290
Estimated treatment effects
-2 -0.333 0 0.333 2
0 0.300 0.653 0.597 0.102 0.308
2 0.995 0.530 0.651 0.275 -0.676
4 2.048 0.350 0.177 -0.032 -1.458
>
> sensPlot(out.bin) # draw contour plot
Note: Predictors with negative coefficients for the response surface have been transformed through multiplication by -1 and are displayed as inverted triangles.
>
>
>
>
> ### *