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

> ### Name: bcrm
> ### Title: Bayesian Continual Reassessment Method for Phase I
> ###   Dose-Escalation Trials
> ### Aliases: bcrm
> 
> ### ** Examples
> 
> ## Dose-escalation cancer trial example as described in Neuenschwander et al 2008.
> ## Pre-defined doses
> dose<-c(1,2.5,5,10,15,20,25,30,40,50,75,100,150,200,250)
> ## Pre-specified probabilities of toxicity
> ## [dose levels 11-15 not specified in the paper, and are for illustration only]
> p.tox0<-c(0.010,0.015,0.020,0.025,0.030,0.040,0.050,0.100,0.170,0.300,0.400,0.500,0.650
+   ,0.800,0.900)
> ## Data from the first 5 cohorts of 18 patients
> data<-data.frame(patient=1:18,dose=rep(c(1:4,7),c(3,4,5,4,2)),tox=rep(0:1,c(16,2)))
> ## Target toxicity level
> target.tox<-0.30
> 
> ## A 1-parameter power model is used, with standardised doses calculated using 
> ## the plug-in prior median
> ## Prior for alpha is lognormal with mean 0 (on log scale) 
> ## and standard deviation 1.34 (on log scale)
> ## The recommended dose for the next cohort if posterior mean is used
> Power.LN.bcrm<-bcrm(stop=list(nmax=18),data=data,p.tox0=p.tox0,dose=dose
+   ,ff="power",prior.alpha=list(3,0,1.34^2),target.tox=target.tox,constrain=FALSE
+   ,sdose.calculate="median",pointest="mean")

 Stopping: Reached maximum sample size
> print(Power.LN.bcrm)
 Estimation method:  exact 

 Model:  1-parameter power 

 Prior:  Lognormal( Mean:0, Variance:1.7956) 

 Standardised doses (skeleton): 
    1   2.5     5    10    15    20    25    30    40    50    75   100   150 
0.010 0.015 0.020 0.025 0.030 0.040 0.050 0.100 0.170 0.300 0.400 0.500 0.650 
  200   250 
0.800 0.900 

 Unmodified (unconstrained) CRM used 

 Posterior mean estimate of probability of toxicity used to select next dose 

 Toxicities observed: 
            Doses
             1 2.5 5 10 15 20 25 30 40 50 75 100 150 200 250
  n          3   4 5  4  0  0  2  0  0  0  0   0   0   0   0
  Toxicities 0   0 0  0  0  0  2  0  0  0  0   0   0   0   0

 Posterior estimates of toxicity: 
        Doses
              1    2.5      5     10     15     20     25    30    40    50
  Mean   0.0702 0.0866 0.1010 0.1130 0.1250 0.1460 0.1650 0.244 0.333 0.467
  SD     0.0558 0.0630 0.0686 0.0731 0.0769 0.0831 0.0879 0.102 0.109 0.108
  Median 0.0561 0.0723 0.0865 0.0995 0.1110 0.1330 0.1530 0.237 0.330 0.471
        Doses
             75   100   150    200    250
  Mean   0.5580 0.641 0.757 0.8650 0.9330
  SD     0.0996 0.088 0.066 0.0398 0.0205
  Median 0.5640 0.648 0.764 0.8700 0.9360
         Doses
Quantiles       1     2.5      5     10     15     20     25     30    40    50
    2.5%  0.00493 0.00787 0.0110 0.0142 0.0175 0.0244 0.0316 0.0702 0.130 0.249
    25%   0.02860 0.03910 0.0488 0.0579 0.0667 0.0833 0.0990 0.1690 0.255 0.395
    50%   0.05610 0.07230 0.0865 0.0995 0.1110 0.1330 0.1530 0.2370 0.330 0.471
    75%   0.09710 0.11900 0.1380 0.1540 0.1690 0.1960 0.2190 0.3120 0.408 0.544
    97.5% 0.21300 0.24400 0.2690 0.2900 0.3080 0.3400 0.3660 0.4620 0.552 0.668
         Doses
Quantiles    75   100   150   200   250
    2.5%  0.347 0.450 0.608 0.773 0.886
    25%   0.493 0.586 0.717 0.842 0.922
    50%   0.564 0.648 0.764 0.870 0.936
    75%   0.629 0.704 0.804 0.893 0.948
    97.5% 0.735 0.792 0.865 0.928 0.965

 Next recommended dose:  40 
> plot(Power.LN.bcrm)
> 
> ## Simulate 10 replicate trials of size 36 (cohort size 3) using this design 
> ## with constraint (i.e. no dose-skipping) and starting at lowest dose
> ## True probabilities of toxicity are set to pre-specified probabilities (p.tox0) 
> Power.LN.bcrm.sim<-bcrm(stop=list(nmax=36),p.tox0=p.tox0,dose=dose,ff="power"
+   ,prior.alpha=list(3,0,1.34^2),target.tox=target.tox,constrain=TRUE
+   ,sdose.calculate="median",pointest="mean",start=1,simulate=TRUE,nsims=10,truep=p.tox0)
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
> print(Power.LN.bcrm.sim)
Operating characteristics based on  10  simulations: 
 
              
Sample size 36

                            Doses
                                  1    2.5      5     10     15     20     25
  Experimentation proportion 0.0833 0.0833 0.0833 0.0833 0.0833 0.0833 0.0833
  Recommendation proportion  0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
                            Doses
                                 30    40    50    75    100 150 200 250
  Experimentation proportion 0.0833 0.108 0.133 0.075 0.0167   0   0   0
  Recommendation proportion  0.0000 0.100 0.500 0.200 0.2000   0   0   0

                            Probability of DLT
                             [0,0.2] (0.2,0.4] (0.4,0.6] (0.6,0.8] (0.8,1]
  Experimentation proportion   0.775     0.208    0.0167         0       0
  Recommendation proportion    0.100     0.700    0.2000         0       0
> plot(Power.LN.bcrm.sim)
Warning: Ignoring unknown aesthetics: bw
> 
> ## Comparing this CRM design with the standard 3+3 design 
> ## (only considering the first 12 dose levels)
> ## Not run: 
> ##D Power.LN.bcrm.compare.sim<-bcrm(stop=list(nmax=36),p.tox0=p.tox0[1:12],dose=dose[1:12]
> ##D   ,ff="power",prior.alpha=list(3,0,1.34^2),target.tox=target.tox,constrain=TRUE
> ##D   ,sdose.calculate="median",pointest="mean",start=1,simulate=TRUE,nsims=50
> ##D   ,truep=p.tox0[1:12],threep3=TRUE)
> ##D print(Power.LN.bcrm.compare.sim,threep3=TRUE)
> ##D plot(Power.LN.bcrm.compare.sim,threep3=TRUE)
> ## End(Not run)
> 
> ## A 2-parameter model, using priors as specified in Neuenschwander et al 2008.
> ## Posterior mean used to choose the next dose
> ## Standardised doses using reference dose, 250mg
> sdose<-log(dose/250)
> ## Bivariate lognormal prior for two parameters
> mu<-c(2.15,0.52)
> Sigma<-rbind(c(0.84^2,0.134),c(0.134,0.80^2))
> ## Using rjags (requires JAGS to be installed)
> TwoPLogistic.mean.bcrm<-bcrm(stop=list(nmax=18),data=data,sdose=sdose
+   ,dose=dose,ff="logit2",prior.alpha=list(4,mu,Sigma),target.tox=target.tox
+   ,constrain=FALSE,pointest="mean",method="rjags")
Error: .onLoad failed in loadNamespace() for 'rjags', details:
  call: fun(libname, pkgname)
  error: The environment variable JAGS_HOME is set to
c:/Program Files/JAGS/JAGS-4.0.0
but no JAGS installation can be found there
Execution halted