==12503== Memcheck, a memory error detector
==12503== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==12503== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==12503== Command: /data/blackswan/ripley/R/R-devel-vg/bin/exec/R --vanilla
==12503==
R Under development (unstable) (2016-02-21 r70195) -- "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...
==12503== Mismatched free() / delete / delete []
==12503== at 0x4A08184: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12503== by 0xFC92DCB: (anonymous namespace)::parseProcCPUInfo(std::vector<(anonymous namespace)::Processor*, std::allocator<(anonymous namespace)::Processor*> >&) [clone .constprop.73] (packages/tests-vg/treatSens/src/guessNumCores.cpp:237)
==12503== by 0xFC934C4: cibart::guessNumCores(unsigned int*, unsigned int*) (packages/tests-vg/treatSens/src/guessNumCores.cpp:345)
==12503== by 0xFC916C3: (anonymous namespace)::guessNumCores() (packages/tests-vg/treatSens/src/R_interface.cpp:333)
==12503== by 0x47A762: do_dotcall (svn/R-devel/src/main/dotcode.c:1251)
==12503== by 0x4AFBC9: Rf_eval (svn/R-devel/src/main/eval.c:713)
==12503== by 0x4B2FAD: do_set (svn/R-devel/src/main/eval.c:2196)
==12503== by 0x4AFA20: Rf_eval (svn/R-devel/src/main/eval.c:685)
==12503== by 0x4B1F58: do_begin (svn/R-devel/src/main/eval.c:1806)
==12503== by 0x4AFA20: Rf_eval (svn/R-devel/src/main/eval.c:685)
==12503== by 0x4B1166: Rf_applyClosure (svn/R-devel/src/main/eval.c:1134)
==12503== by 0x4AF850: Rf_eval (svn/R-devel/src/main/eval.c:732)
==12503== Address 0xcec15d0 is 0 bytes inside a block of size 4,096 alloc'd
==12503== at 0x4A077FD: operator new[](unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==12503== by 0xFC92D3B: (anonymous namespace)::parseProcCPUInfo(std::vector<(anonymous namespace)::Processor*, std::allocator<(anonymous namespace)::Processor*> >&) [clone .constprop.73] (packages/tests-vg/treatSens/src/guessNumCores.cpp:208)
==12503== by 0xFC934C4: cibart::guessNumCores(unsigned int*, unsigned int*) (packages/tests-vg/treatSens/src/guessNumCores.cpp:345)
==12503== by 0xFC916C3: (anonymous namespace)::guessNumCores() (packages/tests-vg/treatSens/src/R_interface.cpp:333)
==12503== by 0x47A762: do_dotcall (svn/R-devel/src/main/dotcode.c:1251)
==12503== by 0x4AFBC9: Rf_eval (svn/R-devel/src/main/eval.c:713)
==12503== by 0x4B2FAD: do_set (svn/R-devel/src/main/eval.c:2196)
==12503== by 0x4AFA20: Rf_eval (svn/R-devel/src/main/eval.c:685)
==12503== by 0x4B1F58: do_begin (svn/R-devel/src/main/eval.c:1806)
==12503== by 0x4AFA20: Rf_eval (svn/R-devel/src/main/eval.c:685)
==12503== by 0x4B1166: Rf_applyClosure (svn/R-devel/src/main/eval.c:1134)
==12503== by 0x4AF850: Rf_eval (svn/R-devel/src/main/eval.c:732)
==12503==
running time (seconds): 16.834297
>
> summary(out.bin) # prints average value of tau (trt effect) for each cell in grid
Coefficients on U where tau = 0:
Y Z
3.905 -2.000
3.788 -0.333
4.000 -0.280
Coefficients on U where significance level 0.05 is lost:
Y Z
0.614 -2.000
2.000 -0.631
3.292 -2.000
Estimated treatment effects
-2 -0.333 0 0.333 2
0 0.102 0.197 0.562 0.379 0.349
2 1.230 0.406 0.310 -0.045 -0.511
4 1.801 0.898 0.914 -0.067 -1.003
>
> 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.
>
>
>
>
> ### *