Running examples in 'mediation-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: mediate
> ### Title: Causal Mediation Analysis
> ### Aliases: mediate
> 
> ### ** Examples
> 
> # Examples with JOBS II Field Experiment
> 
> # **For illustration purposes a small number of simulations are used**
> 
> data(jobs)
> 
> ####################################################
> # Example 1: Linear Outcome and Mediator Models
> ####################################################
> b <- lm(job_seek ~ treat + econ_hard + sex + age, data=jobs)
> c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data=jobs)
> 
> # Estimation via quasi-Bayesian approximation
> contcont <- mediate(b, c, sims=50, treat="treat", mediator="job_seek")
> summary(contcont)

Causal Mediation Analysis 

Quasi-Bayesian Confidence Intervals

               Estimate 95% CI Lower 95% CI Upper p-value
ACME            -0.0171      -0.0415         0.01    0.12
ADE             -0.0325      -0.1229         0.05    0.40
Total Effect    -0.0496      -0.1323         0.03    0.28
Prop. Mediated   0.2457      -1.9818         2.41    0.24

Sample Size Used: 899 


Simulations: 50 

> plot(contcont)
> 
> ## Not run: 
> ##D # Estimation via nonparametric bootstrap
> ##D contcont.boot <- mediate(b, c, boot=TRUE, sims=50, treat="treat", mediator="job_seek")
> ##D summary(contcont.boot)
> ## End(Not run)
> 
> # Allowing treatment-mediator interaction
> d <- lm(depress2 ~ treat + job_seek + treat:job_seek + econ_hard + sex + age, data=jobs)
> contcont.int <- mediate(b, d, sims=50, treat="treat", mediator="job_seek")
> summary(contcont.int)

Causal Mediation Analysis 

Quasi-Bayesian Confidence Intervals

                         Estimate 95% CI Lower 95% CI Upper p-value
ACME (control)            -0.0156      -0.0489         0.01    0.40
ACME (treated)            -0.0104      -0.0400         0.01    0.40
ADE (control)             -0.0482      -0.1294         0.03    0.28
ADE (treated)             -0.0430      -0.1281         0.03    0.32
Total Effect              -0.0586      -0.1369         0.01    0.24
Prop. Mediated (control)   0.1938     -17.9416         2.04    0.48
Prop. Mediated (treated)   0.1320     -15.7464         1.04    0.48
ACME (average)            -0.0130      -0.0446         0.01    0.40
ADE (average)             -0.0456      -0.1280         0.03    0.32
Prop. Mediated (average)   0.1629     -16.8440         1.53    0.48

Sample Size Used: 899 


Simulations: 50 

> 
> # Allowing ``moderated mediation'' with respect to age
> b.int <- lm(job_seek ~ treat*age + econ_hard + sex, data=jobs)
> d.int <- lm(depress2 ~ treat*job_seek*age + econ_hard + sex, data=jobs)
> contcont.age20 <- mediate(b.int, d.int, sims=50, treat="treat", mediator="job_seek",
+ 			covariates = list(age = 20))
> contcont.age70 <- mediate(b.int, d.int, sims=50, treat="treat", mediator="job_seek",
+ 			covariates = list(age = 70))
> summary(contcont.age20)

Causal Mediation Analysis 

Quasi-Bayesian Confidence Intervals

(Inference Conditional on the Covariate Values Specified in `covariates')

                         Estimate 95% CI Lower 95% CI Upper p-value
ACME (control)            -0.0350      -0.1098         0.02    0.28
ACME (treated)            -0.0276      -0.0786         0.01    0.28
ADE (control)             -0.0386      -0.1976         0.11    0.52
ADE (treated)             -0.0312      -0.1984         0.10    0.64
Total Effect              -0.0662      -0.2157         0.07    0.40
Prop. Mediated (control)   0.2324      -2.7059         2.12    0.60
Prop. Mediated (treated)   0.1808      -1.3722         1.85    0.60
ACME (average)            -0.0313      -0.0929         0.02    0.28
ADE (average)             -0.0349      -0.1986         0.10    0.60
Prop. Mediated (average)   0.2066      -2.0071         1.71    0.60

Sample Size Used: 899 


Simulations: 50 

> summary(contcont.age70)

Causal Mediation Analysis 

Quasi-Bayesian Confidence Intervals

(Inference Conditional on the Covariate Values Specified in `covariates')

                         Estimate 95% CI Lower 95% CI Upper p-value
ACME (control)            0.01293     -0.05446         0.09    0.72
ACME (treated)            0.01074     -0.04796         0.08    0.76
ADE (control)            -0.05589     -0.45814         0.19    0.72
ADE (treated)            -0.05808     -0.45970         0.20    0.72
Total Effect             -0.04515     -0.45693         0.21    0.84
Prop. Mediated (control)  0.03924     -0.71959         2.46    0.84
Prop. Mediated (treated)  0.00852     -2.51890         2.06    0.88
ACME (average)            0.01183     -0.03898         0.09    0.72
ADE (average)            -0.05699     -0.45892         0.20    0.72
Prop. Mediated (average)  0.02388     -1.58296         2.24    0.84

Sample Size Used: 899 


Simulations: 50 

> 
> # Continuous treatment
> jobs$treat_cont <- jobs$treat + rnorm(nrow(jobs))  # (hypothetical) continuous treatment
> b.contT <- lm(job_seek ~ treat_cont + econ_hard + sex + age, data=jobs)
> c.contT <- lm(depress2 ~ treat_cont + job_seek + econ_hard + sex + age, data=jobs)
> contcont.cont <- mediate(b.contT, c.contT, sims=50, 
+                     treat="treat_cont", mediator="job_seek",
+                     treat.value = 4, control.value = -2)
> summary(contcont.cont)

Causal Mediation Analysis 

Quasi-Bayesian Confidence Intervals

               Estimate 95% CI Lower 95% CI Upper p-value
ACME           -0.00927     -0.05022         0.05    0.64
ADE            -0.15828     -0.31997         0.05    0.12
Total Effect   -0.16755     -0.32456         0.03    0.16
Prop. Mediated  0.06179     -1.99497         0.77    0.64

Sample Size Used: 899 


Simulations: 50 

> 
> # Categorical treatment 
> ## Not run: 
> ##D b <- lm(job_seek ~ educ + sex, data=jobs)
> ##D c <- lm(depress2 ~ educ + job_seek + sex, data=jobs)
> ##D 
> ##D # compare two categories of educ --- gradwk and somcol
> ##D model.cat <- mediate(b, c, treat="educ", mediator="job_seek", sims=50, 
> ##D                      control.value = "gradwk", treat.value = "somcol")
> ##D summary(model.cat)
> ## End(Not run)
> 
> ######################################################
> # Example 2: Binary Outcome and Ordered Mediator
> ######################################################
> ## Not run: 
> ##D jobs$job_disc <- as.factor(jobs$job_disc)
> ##D b.ord <- polr(job_disc ~ treat + econ_hard + sex + age, data=jobs,
> ##D             method="probit", Hess=TRUE)
> ##D d.bin <- glm(work1 ~ treat + job_disc + econ_hard + sex + age, data=jobs,
> ##D             family=binomial(link="probit"))
> ##D ordbin <- mediate(b.ord, d.bin, sims=50, treat="treat", mediator="job_disc")
> ##D summary(ordbin)
> ##D 
> ##D # Using heteroskedasticity-consistent standard errors
> ##D ordbin.rb <- mediate(b.ord, d.bin, sims=50, treat="treat", mediator="job_disc",
> ##D             robustSE=TRUE)
> ##D summary(ordbin.rb)
> ##D 
> ##D # Using non-parametric bootstrap
> ##D ordbin.boot <- mediate(b.ord, d.bin, sims=50, treat="treat", mediator="job_disc",
> ##D             boot=TRUE)
> ##D summary(ordbin.boot)
> ## End(Not run)
> 
> ######################################################
> # Example 3: Quantile Causal Mediation Effect
> ######################################################
> require(quantreg)
Loading required package: quantreg
Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'quantreg'
> c.quan <- rq(depress2 ~ treat + job_seek + econ_hard + sex + age, data=jobs,
+             tau = 0.5)  # median
Error in rq(depress2 ~ treat + job_seek + econ_hard + sex + age, data = jobs,  : 
  could not find function "rq"
Execution halted