Skip to contents

[Stable]

This is the function that actually runs the JAGS MCMC machinery to produce posterior samples from all model parameters and required derived values. It is a generic function, so that customized versions may be conveniently defined for specific subclasses of GeneralData, GeneralModel, and McmcOptions input.

Usage

mcmc(data, model, options, ...)

# S4 method for class 'GeneralData,GeneralModel,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)

# S4 method for class 'GeneralData,DualEndpointRW,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)

# S4 method for class 'GeneralData,DualEndpointBeta,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)

# S4 method for class 'GeneralData,DualEndpointEmax,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)

# S4 method for class 'GeneralData,OneParLogNormalPrior,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)

# S4 method for class 'GeneralData,OneParExpPrior,McmcOptions'
mcmc(data, model, options, from_prior = data@nObs == 0L, ...)

# S4 method for class 'DataMixture,GeneralModel,McmcOptions'
mcmc(
  data,
  model,
  options,
  from_prior = data@nObs == 0L & data@nObsshare == 0L,
  ...
)

# S4 method for class 'Data,LogisticIndepBeta,McmcOptions'
mcmc(data, model, options, ...)

# S4 method for class 'DataDual,Effloglog,McmcOptions'
mcmc(data, model, options, ...)

# S4 method for class 'DataDual,EffFlexi,McmcOptions'
mcmc(data, model, options, ...)

# S4 method for class 'DataOrdinal,LogisticLogNormalOrdinal,McmcOptions'
mcmc(data, model, options, ...)

Arguments

data

(GeneralData)
an input data.

model

(GeneralModel)
an input model.

options

(McmcOptions)
MCMC options.

...

not used.

from_prior

(flag)
sample from the prior only? Default to TRUE when number of observations in data is 0. For some models it might be necessary to specify it manually here though.

Value

The posterior samples, an object of class Samples.

Functions

  • mcmc(data = GeneralData, model = GeneralModel, options = McmcOptions): Standard method which uses JAGS.

  • mcmc(data = GeneralData, model = DualEndpointRW, options = McmcOptions): Standard method which uses JAGS. For the DualEndpointRW model, it is required that there are at least two (in case of random walk prior of the first order on the biomarker level) or three doses in the grid.

  • mcmc(data = GeneralData, model = DualEndpointBeta, options = McmcOptions): Standard method which uses JAGS. For the DualEndpointBeta model, it is required that the value of ref_dose_beta slot is greater than the maximum dose in a grid. This requirement comes from definition of the beta function that is used to model dose-biomarker relationship in DualEndpointBeta model. The other requirement is that there must be at least one dose in the grid.

  • mcmc(data = GeneralData, model = DualEndpointEmax, options = McmcOptions): Standard method which uses JAGS. For the DualEndpointEmax model, it is required that there is at least one dose in the grid.

  • mcmc(data = GeneralData, model = OneParLogNormalPrior, options = McmcOptions): Standard method which uses JAGS. For the OneParLogNormalPrior model, it is required that the length of skeleton prior probabilities vector should be equal to the length of the number of doses.

  • mcmc(data = GeneralData, model = OneParExpPrior, options = McmcOptions): Standard method which uses JAGS. For the OneParExpPrior model, it is required that the length of skeleton prior probabilities vector should be equal to the length of the number of doses.

  • mcmc(data = DataMixture, model = GeneralModel, options = McmcOptions): Method for DataMixture with different from_prior default

  • mcmc(data = Data, model = LogisticIndepBeta, options = McmcOptions): Obtain posterior samples for the model parameters based on the pseudo 'LogisticsIndepBeta' DLE model. The joint prior and posterior probability density function of the intercept \(\phi_1\) (phi1) and the slope \(\phi_2\) (phi2) are given in Whitehead and Williamson (1998) and TsuTakawa (1975). However, since asymptotically, the joint posterior probability density will be bivariate normal and we will use the bivariate normal distribution to generate posterior samples of the intercept and the slope parameters. For the prior samples of of the intercept and the slope a bivariate normal distribution with mean and the covariance matrix given in Whitehead and Williamson (1998) is used.

  • mcmc(data = DataDual, model = Effloglog, options = McmcOptions): Obtain the posterior samples for the model parameters in the Efficacy log log model. Given the value of \(\nu\), the precision of the efficacy responses, the joint prior or the posterior probability of the intercept \(\theta_1\) (theta1) and the slope \(\theta_2\) (theta2) is a bivariate normal distribution. The \(\nu\) (nu), the precision of the efficacy responses is either a fixed value or has a gamma distribution. If a gamma distribution is used, the samples of nu will be first generated. Then the mean of the of the nu samples will be used the generate samples of the intercept and slope parameters of the model

  • mcmc(data = DataDual, model = EffFlexi, options = McmcOptions): Obtain the posterior samples for the estimates in the Efficacy Flexible form. This is the mcmc procedure based on what is described in Lang and Brezger (2004) such that samples of the mean efficacy responses at all dose levels, samples of sigma2 \(sigma^2\), the variance of the efficacy response and samples of sigma2betaW \(sigma^2_{beta_W}\), the variance of the random walk model will be generated. Please refer to Lang and Brezger (2004) for the procedures and the form of the joint prior and posterior probability density for the mean efficacy responses. In addition, both sigma2 and sigma2betaW can be fixed or having an inverse-gamma prior and posterior distribution. Therefore, if the inverse gamma distribution(s) are used, the parameters in the distribution will be first updated and then samples of sigma2 and sigma2betaW will be generated using the updated parameters.

  • mcmc( data = DataOrdinal, model = LogisticLogNormalOrdinal, options = McmcOptions ): Obtain the posterior samples for the model parameters in the LogisticLogNormalOrdinal.

    The generic mcmc method returns a Samples object with elements of the data slot named alpha[1], alpha[2], ..., alpha[k] and beta when passed a LogisticLogNormalOrdinal object. This makes the "alpha elements" awkward to access and is inconsistent with other Model objects. So rename the alpha elements to alpha1, alpha2, ..., alpha<k> for ease and consistency.

Note

The type of Random Number Generator (RNG) and its initial seed used by JAGS are taken from the options argument. If no initial values are supplied (i.e RNG kind or seed slot in options has NA), then they will be generated automatically by JAGS.

Examples

# Create some data from the class `Data`.
my_data <- Data(
  x = c(0.1, 0.5, 1.5, 3, 6, 10, 10, 10),
  y = c(0, 0, 0, 0, 0, 0, 1, 0),
  doseGrid = c(0.1, 0.5, 1.5, 3, 6, seq(from = 10, to = 80, by = 2))
)
#> Used default patient IDs!
#> Used best guess cohort indices!

# Initialize the CRM model.
my_model <- LogisticLogNormal(
  mean = c(-0.85, 1),
  cov = matrix(c(1, -0.5, -0.5, 1), nrow = 2),
  ref_dose = 56
)

# Sample from the posterior distribution.
my_options <- McmcOptions(
  burnin = 100,
  step = 2,
  samples = 1000
)

samples <- mcmc(data = my_data, model = my_model, options = my_options)
samples
#> An object of class "Samples"
#> Slot "data":
#> $alpha0
#>    [1] -0.2789247629 -0.5848393590 -0.5848393590 -0.5848393590 -0.8540240206
#>    [6] -0.8540240206 -0.8540240206 -0.8540240206 -0.8540240206 -0.8540240206
#>   [11] -0.8540240206 -0.0229775175 -0.0229775175  0.6884719868  0.6884719868
#>   [16]  0.6884719868  0.6884719868  0.2733888822  0.2733888822  0.2733888822
#>   [21]  0.0128418940  0.5376035928  1.2469571039  1.2469571039  0.6461698368
#>   [26]  1.0211938524  0.5201329118  0.0369999677 -0.0889753845  0.7430501605
#>   [31]  0.9231047633  0.7673132905  1.4590244729  1.4590244729  1.4590244729
#>   [36]  1.4590244729  0.3152521791  1.4924496951  1.4924496951  0.0989419022
#>   [41] -0.2085315111 -0.2085315111 -0.2085315111 -0.2085315111 -1.4685891001
#>   [46] -1.4685891001 -1.8774945327 -1.8774945327 -0.7766766719 -0.4046756689
#>   [51] -0.4046756689 -0.4046756689 -0.4046756689 -0.4046756689  1.0044862181
#>   [56] -0.2575406125 -0.2575406125 -0.6655824637 -0.6655824637 -0.6655824637
#>   [61] -0.7566217149  0.7448962127  1.4237783960  1.4237783960  0.1897848613
#>   [66]  0.1897848613  0.3722919853 -0.8407600623  0.0552410869  0.0552410869
#>   [71]  0.2357147684  0.5711772336  0.5711772336  0.3093625173  0.3093625173
#>   [76] -0.1374460543  0.6444616667  0.6444616667  0.6444616667  0.6444616667
#>   [81]  0.0579045999 -0.0743443006  0.5215960307 -0.2309753513 -0.2309753513
#>   [86] -0.2309753513 -0.2309753513 -0.2309753513 -0.4534116251 -0.4534116251
#>   [91] -0.4534116251 -0.7643259158 -0.7643259158 -0.8169621797  0.1153796100
#>   [96]  0.1153796100 -0.5448809711 -1.1552379323 -1.1552379323 -0.0295717982
#>  [101] -0.0295717982  0.4950584679  0.4950584679  0.4950584679  0.4950584679
#>  [106]  0.4950584679  0.4950584679  0.4950584679  0.4950584679  0.4950584679
#>  [111]  0.2242851377 -0.9768958660  0.9709090280  0.9709090280  0.0092199067
#>  [116]  1.2907766250 -1.4849927920 -0.5677465513 -0.5677465513 -0.5677465513
#>  [121] -0.5677465513 -0.3417965966 -0.3417965966 -0.3417965966 -1.3231413417
#>  [126] -1.2682606840 -1.2719226619 -1.2719226619 -1.2719226619 -1.5920564893
#>  [131] -0.7339201258 -0.7339201258 -0.6187707647 -0.6187707647 -0.0294585204
#>  [136] -0.0294585204 -0.0294585204 -0.0294585204 -0.0294585204 -0.0294585204
#>  [141] -0.0371178091 -0.0371178091 -0.0371178091 -0.4559068012  0.2445547119
#>  [146]  0.2445547119 -1.2319737852 -1.1011397282 -1.2302397487 -0.1111315898
#>  [151] -1.1824928854  0.0612757097  0.7285323422  0.7183455359  0.2830059642
#>  [156] -0.3347441950  0.0860798436  0.0860798436  0.0860798436  0.0860798436
#>  [161]  0.0860798436  0.0860798436  0.0860798436  0.0860798436  0.0860798436
#>  [166]  0.0860798436  0.0860798436  0.9892624279  0.6931452467  0.9133195719
#>  [171]  0.9133195719  0.2851495003  0.2851495003  0.2851495003  0.2851495003
#>  [176]  0.2851495003  0.2851495003  0.2851495003  0.2851495003  0.2201291263
#>  [181]  0.5751578648  0.5751578648  0.5751578648  1.3329708745  1.3329708745
#>  [186]  1.3329708745  0.6840777720  0.6840777720  0.8619210767  0.8619210767
#>  [191]  0.4793964791  1.3860738530  1.0605483684  1.0605483684  1.4811294691
#>  [196]  1.4811294691  1.7187364356  1.7187364356  0.7488446608  0.7488446608
#>  [201] -0.3175449061 -0.7146408127 -0.7146408127 -0.7146408127 -0.3347318813
#>  [206] -0.0520079560  0.1429737182  0.1429737182  0.1429737182  0.0146660216
#>  [211] -0.8016279552 -0.8473887127 -0.8473887127 -0.0921158688 -0.0921158688
#>  [216] -0.8077369555 -0.4068883152 -0.4068883152 -0.4068883152 -0.4068883152
#>  [221] -0.4068883152 -0.4068883152 -0.4068883152 -0.4068883152 -0.4068883152
#>  [226] -0.4068883152  0.7736266147  0.7736266147  0.3371760516 -0.3869537033
#>  [231] -0.3869537033 -0.3869537033 -0.3869537033 -0.3869537033 -0.0947487838
#>  [236] -0.3307907890  0.3001039593  0.7058124421  0.2855028851  0.2855028851
#>  [241] -1.2390930005 -1.2390930005 -1.2390930005 -0.4486311861  1.6732694350
#>  [246]  0.1791437021  0.1791437021 -0.8822887542 -0.8822887542 -0.8822887542
#>  [251] -0.8822887542 -0.6797363867 -0.6797363867  0.1823012303  0.7901203752
#>  [256]  1.3675661250  1.5818082393  1.1232779076  1.2533602064 -0.2746341347
#>  [261] -1.4028235822 -1.4028235822  0.1285931622  0.1285931622  0.1850139277
#>  [266]  0.1850139277  0.1850139277 -0.1765152740 -0.4644768664 -0.4644768664
#>  [271] -0.4644768664  0.2312343526 -0.3018411601  0.2586391691  0.2586391691
#>  [276] -0.0583815088 -0.0583815088 -0.0583815088  0.5476904812 -1.4699444748
#>  [281] -0.8648598638  0.1140637477 -0.9597084334 -0.9597084334 -0.3372232833
#>  [286] -0.3372232833 -0.3372232833 -0.3372232833  0.5752466728  0.5752466728
#>  [291]  0.5752466728  0.5752466728 -0.3733802888  0.5969755364  0.5969755364
#>  [296]  0.5969755364 -0.1056852807 -0.1056852807  0.4765854301  0.4765854301
#>  [301]  1.2524961775  0.8913799316  0.8913799316  0.8913799316  0.8913799316
#>  [306]  0.8913799316  0.8913799316 -0.2544775291  0.3420758443 -0.5804245865
#>  [311] -1.2959793190 -0.9539456373  0.0668329393  0.0668329393 -0.2037804855
#>  [316] -0.2037804855 -0.2037804855 -0.2037804855 -0.5915989287 -0.0222599296
#>  [321]  0.3138585462  0.3138585462  0.3138585462  0.1479125451  0.1479125451
#>  [326]  0.1479125451  0.1479125451  0.0493229562  0.3379182511  0.3379182511
#>  [331]  0.3379182511  0.2235778244  0.6672682577  0.6672682577  0.6672682577
#>  [336]  0.2051983547  0.2051983547  0.2051983547  0.2051983547  0.2051983547
#>  [341]  0.2051983547  0.2051983547  0.1967926979  0.1967926979  0.1967926979
#>  [346] -0.3619026329 -0.7417220379 -0.7417220379 -0.7417220379 -0.7417220379
#>  [351] -1.0952203452 -0.2481673689 -0.6820256429 -1.5115377399 -0.0714515292
#>  [356]  0.1511765104  0.1511765104  0.1511765104  0.1511765104  0.1511765104
#>  [361]  0.6414901841  0.6414901841  0.2470277082  0.2299585067 -0.0168610388
#>  [366] -0.1091362831  0.3774515694  0.3774515694  0.3774515694  0.3774515694
#>  [371]  0.3774515694  0.3774515694  0.3774515694  0.3774515694  0.3774515694
#>  [376]  0.3774515694  0.4884810668 -0.3121106106 -0.3121106106 -0.1363910629
#>  [381] -0.1363910629 -0.1363910629 -0.0599360846 -0.0599360846 -1.2706278187
#>  [386] -1.2706278187 -1.2706278187  1.1443001219  0.9847367663  0.5127784563
#>  [391]  0.5127784563  0.5127784563  0.7257882148 -1.0524168045 -1.0524168045
#>  [396] -1.0524168045 -1.0524168045 -1.0524168045  0.5104459044  0.1524290391
#>  [401]  0.1524290391  0.1524290391  0.2395729084  0.2395729084  0.4155570697
#>  [406]  0.1099553946  1.2518670014  1.5446053670 -1.0705658468 -0.1787017253
#>  [411] -0.1787017253  0.5940577855  0.5940577855  0.6787058223  0.6787058223
#>  [416]  1.1464358586  1.1464358586  1.1464358586 -0.6229318868 -0.6229318868
#>  [421] -0.1136841798 -0.1136841798 -0.1136841798 -0.8088505876 -1.5906152692
#>  [426] -1.5906152692 -1.4045488450 -1.4045488450 -1.4045488450 -1.4045488450
#>  [431] -2.9920611818 -1.9766943696 -0.3422476297 -1.3684482742  0.2008093928
#>  [436]  0.2008093928 -1.5196633937  0.5828530237  0.7506377306  0.7506377306
#>  [441] -1.4702086505 -0.9587451086 -0.1185839202  0.4408096930  0.4408096930
#>  [446]  0.4408096930  0.4408096930  0.4408096930  0.4408096930  0.4408096930
#>  [451] -0.1999161592 -0.1999161592  0.2445224306 -0.2757826420  0.2121813050
#>  [456]  0.2121813050 -0.3991654427 -0.3991654427  0.7063746869 -0.2628511171
#>  [461] -0.2628511171 -0.2628511171 -0.2628511171 -0.2628511171 -0.2628511171
#>  [466] -0.0739984032  0.5348548980  0.0849862772  0.0849862772  0.2339800041
#>  [471]  0.2339800041  0.2339800041 -0.2738836363 -0.0520003193 -0.0520003193
#>  [476] -0.0520003193 -0.0520003193 -0.0520003193 -0.0520003193 -0.0001678255
#>  [481] -0.0001678255  0.0433383847  0.0433383847  0.0433383847 -0.5153772128
#>  [486]  0.2751040826  0.2751040826  0.2751040826 -0.6858838329 -0.6858838329
#>  [491] -0.6788931539 -0.4572962419 -0.9128263091  0.4183272827  0.4183272827
#>  [496]  0.1649144765  0.1649144765  0.1649144765  0.1649144765  0.1649144765
#>  [501]  0.1649144765  0.1649144765  1.2320914655  0.5419044280  1.1762809110
#>  [506]  1.1619162000  1.1892601718  1.1892601718  1.2100277116  1.2100277116
#>  [511]  1.2100277116  1.0439363670 -0.4386744191 -0.0214549784  0.8441750279
#>  [516]  0.8441750279  0.4391227851  0.4391227851  0.4391227851  0.7053634731
#>  [521]  0.7053634731  0.2445508021  0.2445508021  0.2445508021  0.2445508021
#>  [526]  0.2445508021  0.2445508021  0.2445508021 -0.0524938224 -0.0524938224
#>  [531] -0.0524938224  0.1001351064  0.1001351064  0.1001351064 -0.0732030248
#>  [536] -0.0732030248 -0.0732030248 -0.0732030248 -0.0732030248  1.7661703963
#>  [541]  0.8755321171 -0.4531564763  1.0076625496  1.0076625496 -0.1100819709
#>  [546] -0.1100819709 -0.1100819709  0.4704418866  0.4704418866  0.4704418866
#>  [551]  0.6369217909  0.4242983037 -0.1362754885  0.8797532074  0.8797532074
#>  [556] -0.5740557929 -0.5740557929 -0.5740557929 -0.5740557929 -0.5740557929
#>  [561] -0.5740557929 -0.5740557929 -0.5740557929  0.1383106263  0.2512459149
#>  [566]  0.2512459149  0.2512459149  0.2512459149  0.2512459149  0.2512459149
#>  [571]  0.5319346786  0.5319346786  1.2439266939  0.9198700810  0.9198700810
#>  [576]  0.3065420622 -1.0404212754 -1.0404212754 -0.4439581028 -0.4439581028
#>  [581] -0.2561669598 -0.2561669598 -0.2561669598 -0.1406227326 -0.1406227326
#>  [586] -0.1406227326 -0.4357520850 -0.4357520850 -0.1863314773 -0.2121890379
#>  [591] -0.2121890379 -0.1262712295  0.7055453777  0.5813393722  0.5456868355
#>  [596]  0.3411493593 -0.9257258563 -0.0681838927 -0.0681838927 -0.0681838927
#>  [601]  0.6266944609 -0.6308512396 -0.6308512396  0.4146919412  0.4146919412
#>  [606] -1.2815690305 -1.2815690305  0.6753723562 -0.1528599520 -0.1528599520
#>  [611] -0.1528599520 -0.1528599520 -0.1528599520 -0.5512462244  0.4366943764
#>  [616]  0.5743864039  0.5743864039  0.5743864039  0.1535567138  0.1535567138
#>  [621]  0.1535567138  0.2231412254  0.2231412254 -0.7165493669 -0.7165493669
#>  [626] -0.7165493669 -1.1382133627 -1.1382133627 -1.1382133627 -0.3787506675
#>  [631] -0.5029225552 -0.6504626475 -0.9865086289 -0.9865086289 -1.3369491974
#>  [636] -0.9319784612 -0.8048827528  1.3617526688 -0.1395185504  1.1904504474
#>  [641]  0.4527180797  0.4527180797  0.4527180797  0.4527180797  0.4527180797
#>  [646] -0.1921493238 -1.0209722137 -0.8496704176 -0.8496704176 -0.7598133961
#>  [651] -0.3879877526 -0.3879877526 -0.3879877526 -0.3879877526 -0.9995791974
#>  [656]  0.3206360006  0.3206360006 -0.3535417181 -0.3535417181 -0.5931665608
#>  [661] -0.5931665608 -0.5931665608 -0.5931665608  0.4676137752  0.4676137752
#>  [666] -0.0668948360 -0.0668948360  0.3242007891  0.3242007891  0.3242007891
#>  [671]  0.1219552302 -0.0184701605 -0.0184701605 -0.0184701605  0.9143528165
#>  [676]  0.9143528165 -0.0300081353 -0.0300081353  0.3271789692  0.3271789692
#>  [681] -1.7223749742 -1.7223749742 -1.7223749742 -1.7223749742 -0.5809834548
#>  [686] -0.1168966739 -0.1168966739 -0.4648793486 -0.4648793486 -0.4648793486
#>  [691] -0.5006350258 -0.5006350258 -0.5006350258  0.7839470293  0.4573026832
#>  [696]  0.4573026832 -0.4423272498 -0.6592063062 -0.5412110539 -0.5412110539
#>  [701] -0.5412110539 -0.5412110539 -0.5412110539 -1.3112515128 -0.5071983180
#>  [706]  0.8026695692  0.4426289843  0.2716349475  0.2716349475  0.2716349475
#>  [711] -0.3035281733 -0.3035281733  0.1064224509  0.1064224509  0.1064224509
#>  [716]  0.5706866210  0.5706866210  0.5706866210  0.5706866210  0.5706866210
#>  [721] -0.0243116256 -0.0243116256 -0.0243116256 -0.0243116256 -0.4959305166
#>  [726]  0.0747937540  0.0747937540 -1.3831791278 -0.9786488791 -0.9786488791
#>  [731] -0.9786488791 -0.9786488791 -0.4306054231 -0.4306054231 -0.4306054231
#>  [736] -0.4306054231 -0.4306054231 -0.4306054231 -0.4306054231 -0.4306054231
#>  [741] -0.4306054231  0.0431050406  0.0431050406  0.0431050406  0.2861192112
#>  [746]  0.4461791599  0.1891788954  0.1891788954  0.1891788954  0.1891788954
#>  [751] -0.8008058753 -0.8008058753 -0.8008058753 -0.8797823635 -0.8797823635
#>  [756] -0.8797823635 -0.8797823635 -0.8797823635 -0.8797823635 -0.8797823635
#>  [761] -1.1502253391 -1.1502253391 -0.6312266062 -0.6312266062 -0.9270884253
#>  [766] -0.8338752802 -0.8338752802 -0.0126255875 -0.0126255875  0.4955656777
#>  [771]  0.4955656777  0.0230706875 -0.0974190189 -0.0974190189 -0.1289675176
#>  [776] -1.7762397470 -1.7762397470 -2.3739982335 -1.1589991386 -0.6222810504
#>  [781]  0.3015949293  0.3015949293  0.5101239900 -0.3597120430 -0.3597120430
#>  [786] -0.7570206963 -0.7570206963 -0.7570206963  0.3988643348 -0.5652083914
#>  [791]  0.6438960358 -0.1874808303 -0.1874808303  0.4913786728  0.4913786728
#>  [796]  0.4913786728  0.6969927538  0.8714100233  0.6767942820  0.6767942820
#>  [801] -0.0760334300 -0.0760334300 -0.2238351700 -0.2238351700 -0.2238351700
#>  [806] -1.0954240061 -1.1393879818 -0.6587317215 -0.6587317215 -0.6587317215
#>  [811] -0.6587317215 -1.2228277508 -0.9723361195  0.5670514161  0.5670514161
#>  [816]  0.5670514161  0.3773675241 -0.4758891368 -1.2439027377 -1.2439027377
#>  [821] -1.2439027377  1.3798605370  1.3798605370  1.3798605370  1.3798605370
#>  [826]  1.3798605370  1.3798605370  1.3798605370  0.8069968117  0.0793401355
#>  [831]  0.1186284954  0.1186284954  0.1186284954 -0.8070869976 -0.1964304377
#>  [836] -0.1964304377 -0.1964304377  1.4981362409  1.2575107407  0.6088525258
#>  [841]  0.9996541072  0.9996541072 -0.7811786255 -0.6999631124 -0.9142893131
#>  [846] -0.0549314992 -0.0549314992 -0.0549314992 -0.0549314992 -0.6099354842
#>  [851] -0.6099354842 -0.6099354842 -0.6099354842 -0.6099354842 -0.6099354842
#>  [856] -0.6099354842  0.4442797562  0.4442797562  0.4442797562  0.4442797562
#>  [861]  0.3331138115 -1.0806960885 -2.5460799861 -1.1419800340 -1.1419800340
#>  [866] -1.2970879656 -1.0658567729  0.7780676848  0.0208477846 -0.1701820009
#>  [871]  0.1205218104  0.1205218104  0.1205218104  0.1205218104  1.2791437366
#>  [876] -0.5549837737 -0.2721690691 -0.2721690691 -0.2721690691 -0.2721690691
#>  [881] -0.2721690691 -0.2721690691 -0.2721690691 -0.2721690691 -0.2721690691
#>  [886] -0.2721690691  0.0932418433  0.0932418433 -0.8600979592 -0.8600979592
#>  [891]  0.4624754344  0.4624754344  0.4030225351  0.4030225351  0.4030225351
#>  [896]  0.4030225351  0.4030225351  0.4030225351  0.8341661450  0.8341661450
#>  [901]  0.8341661450 -0.0694440153 -0.0694440153 -0.5706627459 -0.9011093800
#>  [906] -0.3230145786 -0.3230145786 -0.1863553343 -0.1863553343 -1.3815705321
#>  [911] -1.2276565959 -1.4273334465 -1.4273334465 -1.4273334465 -1.4273334465
#>  [916] -1.4273334465 -1.4273334465 -1.4273334465 -1.4273334465 -1.4273334465
#>  [921] -0.7639531761 -0.7639531761 -0.7639531761 -1.5985596538 -1.5985596538
#>  [926] -1.5985596538 -1.5985596538 -1.5985596538 -1.5294132325 -1.2979977392
#>  [931] -0.3094790044 -0.3094790044 -0.3094790044 -1.3034091089 -1.6683091076
#>  [936] -1.6683091076 -0.7651386101 -0.7075692818 -0.7075692818 -0.7075692818
#>  [941] -0.6071142279 -0.6071142279 -0.6071142279 -0.3915946797 -0.3915946797
#>  [946] -0.3915946797  1.2400644597  1.2400644597  0.6271811441 -0.6194157632
#>  [951] -0.7386208847 -0.7386208847 -0.7386208847 -0.4950948290  0.0644763431
#>  [956]  0.0644763431  0.0644763431 -0.4792750321 -0.2507182608 -0.2507182608
#>  [961] -0.2507182608 -0.2507182608  1.6806526306  1.0542607076  1.0542607076
#>  [966]  1.0542607076  1.0542607076  1.0542607076  1.0542607076  1.0542607076
#>  [971] -0.6316173945 -0.6316173945 -2.3027740009 -2.4962415630 -1.7896883449
#>  [976] -1.7896883449 -1.0590395339 -0.1397613880 -0.2960996850 -0.2812594096
#>  [981] -0.2812594096 -0.9264574803 -0.9264574803 -0.9264574803 -0.3341110874
#>  [986] -0.3341110874 -0.3341110874 -0.3341110874 -0.3341110874  0.6168453194
#>  [991] -0.6039565855  0.0007309168  0.0007309168  0.0007309168 -0.1143995312
#>  [996] -0.1143995312 -0.1143995312 -0.1143995312 -0.5879236283 -0.2805743264
#> 
#> $alpha1
#>    [1] 0.8144621 1.3377849 1.3377849 1.3377849 0.9314684 0.9314684 0.9314684
#>    [8] 0.9314684 0.9314684 0.9314684 0.9314684 1.9846798 1.9846798 1.0080286
#>   [15] 1.0080286 1.0080286 1.0080286 0.6266740 0.6266740 0.6266740 2.0560035
#>   [22] 0.7206150 1.3183081 1.3183081 3.4305749 2.8134307 1.6813914 1.4197098
#>   [29] 2.0522013 0.5602570 1.2311815 1.8535341 1.2528505 1.2528505 1.2528505
#>   [36] 1.2528505 2.3269501 1.7983157 1.7983157 2.2332834 0.7456363 0.7456363
#>   [43] 0.7456363 0.7456363 0.5886596 0.5886596 1.9018091 1.9018091 0.4143372
#>   [50] 0.6242132 0.6242132 0.6242132 0.6242132 0.6242132 1.1686317 1.0485792
#>   [57] 1.0485792 0.8051276 0.8051276 0.8051276 1.6885284 2.3413702 1.3946365
#>   [64] 1.3946365 1.5964859 1.5964859 1.1991294 2.0450819 2.0005243 2.0005243
#>   [71] 1.4621227 0.6606598 0.6606598 1.5486585 1.5486585 2.2443087 1.9171386
#>   [78] 1.9171386 1.9171386 1.9171386 1.9043484 0.6029029 0.9840967 0.9139667
#>   [85] 0.9139667 0.9139667 0.9139667 0.9139667 0.6945959 0.6945959 0.6945959
#>   [92] 0.9658800 0.9658800 0.9813336 0.6300787 0.6300787 0.7034341 0.9506931
#>   [99] 0.9506931 1.0455012 1.0455012 1.0094210 1.0094210 1.0094210 1.0094210
#>  [106] 1.0094210 1.0094210 1.0094210 1.0094210 1.0094210 1.5004743 1.2812381
#>  [113] 1.2194885 1.2194885 2.1177553 2.2674827 2.7609428 1.5285796 1.5285796
#>  [120] 1.5285796 1.5285796 1.8001514 1.8001514 1.8001514 0.9238139 1.0838169
#>  [127] 0.8534942 0.8534942 0.8534942 0.9460734 0.5793946 0.5793946 1.0295080
#>  [134] 1.0295080 1.2429749 1.2429749 1.2429749 1.2429749 1.2429749 1.2429749
#>  [141] 1.5668336 1.5668336 1.5668336 2.3794807 2.4347479 2.4347479 0.6449220
#>  [148] 0.5771330 1.0088617 0.5011499 1.5366156 2.4844176 1.1753583 1.9895367
#>  [155] 0.8670172 0.7836946 1.4183560 1.4183560 1.4183560 1.4183560 1.4183560
#>  [162] 1.4183560 1.4183560 1.4183560 1.4183560 1.4183560 1.4183560 1.7478141
#>  [169] 1.7975584 0.6581526 0.6581526 1.4977111 1.4977111 1.4977111 1.4977111
#>  [176] 1.4977111 1.4977111 1.4977111 1.4977111 1.3321877 0.8839094 0.8839094
#>  [183] 0.8839094 1.5432083 1.5432083 1.5432083 1.2336372 1.2336372 1.9882998
#>  [190] 1.9882998 0.4728873 0.8017914 0.7988707 0.7988707 2.9859345 2.9859345
#>  [197] 1.1096989 1.1096989 0.7751458 0.7751458 0.5644589 0.3835942 0.3835942
#>  [204] 0.3835942 1.1952444 0.8029857 0.6973182 0.6973182 0.6973182 0.6945659
#>  [211] 0.6090914 0.4828368 0.4828368 2.1259579 2.1259579 1.5992392 1.0874080
#>  [218] 1.0874080 1.0874080 1.0874080 1.0874080 1.0874080 1.0874080 1.0874080
#>  [225] 1.0874080 1.0874080 1.5959159 1.5959159 0.7415624 0.6150169 0.6150169
#>  [232] 0.6150169 0.6150169 0.6150169 1.0889431 0.5350322 0.7036095 1.5693027
#>  [239] 0.5300703 0.5300703 0.8772160 0.8772160 0.8772160 0.5194301 1.0958370
#>  [246] 1.3363826 1.3363826 0.9604901 0.9604901 0.9604901 0.9604901 1.1569655
#>  [253] 1.1569655 1.8031052 4.2891467 4.3391553 1.4862941 1.9530882 0.9112506
#>  [260] 0.4972699 0.8093557 0.8093557 0.9993406 0.9993406 1.1978640 1.1978640
#>  [267] 1.1978640 0.4420620 1.0839218 1.0839218 1.0839218 2.3733832 1.1810377
#>  [274] 0.5832134 0.5832134 1.0630064 1.0630064 1.0630064 0.7078607 1.8352050
#>  [281] 0.9842276 0.9460925 0.9632592 0.9632592 0.5919822 0.5919822 0.5919822
#>  [288] 0.5919822 0.8891687 0.8891687 0.8891687 0.8891687 1.4613928 1.4613667
#>  [295] 1.4613667 1.4613667 0.9600952 0.9600952 2.0927705 2.0927705 2.1161682
#>  [302] 1.2878479 1.2878479 1.2878479 1.2878479 1.2878479 1.2878479 1.6889080
#>  [309] 1.6695397 0.6014393 1.3718673 2.0366456 1.8918565 1.8918565 0.6319109
#>  [316] 0.6319109 0.6319109 0.6319109 1.7714402 0.5130479 0.4015952 0.4015952
#>  [323] 0.4015952 0.7872216 0.7872216 0.7872216 0.7872216 0.5721917 0.7557317
#>  [330] 0.7557317 0.7557317 0.9273108 1.5632885 1.5632885 1.5632885 1.2868395
#>  [337] 1.2868395 1.2868395 1.2868395 1.2868395 1.2868395 1.2868395 1.4550918
#>  [344] 1.4550918 1.4550918 0.4803129 0.9733112 0.9733112 0.9733112 0.9733112
#>  [351] 1.4587397 0.5742484 1.1929013 0.6494244 0.8619538 1.2107329 1.2107329
#>  [358] 1.2107329 1.2107329 1.2107329 1.7885868 1.7885868 0.3717417 0.3369885
#>  [365] 0.5551725 1.1450579 0.7077962 0.7077962 0.7077962 0.7077962 0.7077962
#>  [372] 0.7077962 0.7077962 0.7077962 0.7077962 0.7077962 1.9658346 1.5482748
#>  [379] 1.5482748 1.1280280 1.1280280 1.1280280 1.1568505 1.1568505 1.7767686
#>  [386] 1.7767686 1.7767686 1.1312791 2.3476188 1.6749121 1.6749121 1.6749121
#>  [393] 1.0382432 0.8073197 0.8073197 0.8073197 0.8073197 0.8073197 1.6477084
#>  [400] 1.7924681 1.7924681 1.7924681 1.2570802 1.2570802 2.0459250 2.1752270
#>  [407] 1.4973238 1.2590786 1.5935180 1.8335002 1.8335002 0.8359048 0.8359048
#>  [414] 1.0851010 1.0851010 0.8532877 0.8532877 0.8532877 1.5638638 1.5638638
#>  [421] 1.4330615 1.4330615 1.4330615 0.6803240 1.3443786 1.3443786 1.6228333
#>  [428] 1.6228333 1.6228333 1.6228333 1.3373276 0.5467095 0.3946948 0.5239193
#>  [435] 0.6110506 0.6110506 0.8247254 0.5665448 0.2936489 0.2936489 0.6038546
#>  [442] 1.3273051 0.2779669 1.4056128 1.4056128 1.4056128 1.4056128 1.4056128
#>  [449] 1.4056128 1.4056128 0.6987672 0.6987672 1.8024081 1.1570039 0.8848212
#>  [456] 0.8848212 0.7442628 0.7442628 1.3141370 0.8387645 0.8387645 0.8387645
#>  [463] 0.8387645 0.8387645 0.8387645 0.4263986 0.8770320 0.6072318 0.6072318
#>  [470] 0.7521969 0.7521969 0.7521969 0.8676799 0.9989036 0.9989036 0.9989036
#>  [477] 0.9989036 0.9989036 0.9989036 0.7236407 0.7236407 0.8551776 0.8551776
#>  [484] 0.8551776 1.4417818 0.9279882 0.9279882 0.9279882 1.2033488 1.2033488
#>  [491] 1.2466577 0.8748585 2.1452154 0.8235245 0.8235245 0.7928413 0.7928413
#>  [498] 0.7928413 0.7928413 0.7928413 0.7928413 0.7928413 1.0806567 0.3358828
#>  [505] 1.6019365 1.7772095 1.8274689 1.8274689 2.4158694 2.4158694 2.4158694
#>  [512] 1.5033811 0.3051115 2.9828223 0.7977764 0.7977764 0.7339905 0.7339905
#>  [519] 0.7339905 1.3728366 1.3728366 0.9600181 0.9600181 0.9600181 0.9600181
#>  [526] 0.9600181 0.9600181 0.9600181 1.0471534 1.0471534 1.0471534 1.3037281
#>  [533] 1.3037281 1.3037281 1.1861340 1.1861340 1.1861340 1.1861340 1.1861340
#>  [540] 0.7640692 0.3241339 2.2064729 2.1955547 2.1955547 1.8071160 1.8071160
#>  [547] 1.8071160 0.7412312 0.7412312 0.7412312 1.1952163 1.0140476 0.8010218
#>  [554] 1.7336183 1.7336183 1.1978753 1.1978753 1.1978753 1.1978753 1.1978753
#>  [561] 1.1978753 1.1978753 1.1978753 1.5528008 1.1026095 1.1026095 1.1026095
#>  [568] 1.1026095 1.1026095 1.1026095 1.8212008 1.8212008 1.1329491 0.6928295
#>  [575] 0.6928295 2.1899681 0.9551329 0.9551329 2.3436423 2.3436423 0.9125117
#>  [582] 0.9125117 0.9125117 0.7955829 0.7955829 0.7955829 1.5361844 1.5361844
#>  [589] 1.0053511 0.9455320 0.9455320 2.1476322 2.5460494 2.0901121 1.5471353
#>  [596] 1.2257319 1.9643527 0.4137299 0.4137299 0.4137299 0.4337757 1.8984990
#>  [603] 1.8984990 1.1531175 1.1531175 0.5335810 0.5335810 0.5232951 0.6867656
#>  [610] 0.6867656 0.6867656 0.6867656 0.6867656 0.7443925 0.3489600 1.2632620
#>  [617] 1.2632620 1.2632620 2.7891385 2.7891385 2.7891385 1.8027404 1.8027404
#>  [624] 1.7543052 1.7543052 1.7543052 3.4589724 3.4589724 3.4589724 1.9314919
#>  [631] 1.0177312 1.7231776 1.0652279 1.0652279 0.9455897 1.1769903 1.9628763
#>  [638] 1.3665294 0.4067149 1.4835204 0.9987895 0.9987895 0.9987895 0.9987895
#>  [645] 0.9987895 0.5684825 1.1649976 1.5554724 1.5554724 0.6226291 0.7368752
#>  [652] 0.7368752 0.7368752 0.7368752 1.3755716 0.4671107 0.4671107 1.4136836
#>  [659] 1.4136836 1.4145274 1.4145274 1.4145274 1.4145274 0.9337890 0.9337890
#>  [666] 0.7830747 0.7830747 1.2551847 1.2551847 1.2551847 0.7969641 1.2130124
#>  [673] 1.2130124 1.2130124 0.7641748 0.7641748 0.3378006 0.3378006 0.5064575
#>  [680] 0.5064575 1.8191589 1.8191589 1.8191589 1.8191589 2.5359621 0.3986362
#>  [687] 0.3986362 0.5745766 0.5745766 0.5745766 1.0900447 1.0900447 1.0900447
#>  [694] 0.8178947 1.2164199 1.2164199 0.5582516 0.5056389 1.4566380 1.4566380
#>  [701] 1.4566380 1.4566380 1.4566380 1.1895049 0.4575135 3.1026453 0.9593015
#>  [708] 0.6421899 0.6421899 0.6421899 0.3397058 0.3397058 0.9954453 0.9954453
#>  [715] 0.9954453 1.0328381 1.0328381 1.0328381 1.0328381 1.0328381 1.1792513
#>  [722] 1.1792513 1.1792513 1.1792513 0.6580606 0.8341006 0.8341006 0.6855975
#>  [729] 0.6042386 0.6042386 0.6042386 0.6042386 1.1716942 1.1716942 1.1716942
#>  [736] 1.1716942 1.1716942 1.1716942 1.1716942 1.1716942 1.1716942 0.7272368
#>  [743] 0.7272368 0.7272368 1.4248659 1.8945062 1.6200840 1.6200840 1.6200840
#>  [750] 1.6200840 1.9509399 1.9509399 1.9509399 0.7568942 0.7568942 0.7568942
#>  [757] 0.7568942 0.7568942 0.7568942 0.7568942 0.9863873 0.9863873 0.1850733
#>  [764] 0.1850733 3.5344503 3.0729422 3.0729422 0.4817389 0.4817389 1.1683931
#>  [771] 1.1683931 0.5133290 0.8519196 0.8519196 2.5476158 2.1116208 2.1116208
#>  [778] 1.3240620 1.1339717 0.8620257 0.8290049 0.8290049 0.7853776 0.5742098
#>  [785] 0.5742098 1.4015475 1.4015475 1.4015475 1.4112079 0.8210824 1.2529932
#>  [792] 1.1191785 1.1191785 1.2911766 1.2911766 1.2911766 1.6027913 0.6356912
#>  [799] 0.4203871 0.4203871 2.2983996 2.2983996 1.4484847 1.4484847 1.4484847
#>  [806] 1.1536577 0.6921990 1.5907969 1.5907969 1.5907969 1.5907969 0.6312771
#>  [813] 0.7075679 1.4149628 1.4149628 1.4149628 1.0985812 0.4166246 1.2687457
#>  [820] 1.2687457 1.2687457 1.5721734 1.5721734 1.5721734 1.5721734 1.5721734
#>  [827] 1.5721734 1.5721734 1.4405266 1.2015989 1.4054433 1.4054433 1.4054433
#>  [834] 1.1495438 0.9293492 0.9293492 0.9293492 2.0185260 1.4962975 2.1300143
#>  [841] 0.9159696 0.9159696 0.2692504 0.6933156 0.7077195 0.7759170 0.7759170
#>  [848] 0.7759170 0.7759170 0.9968726 0.9968726 0.9968726 0.9968726 0.9968726
#>  [855] 0.9968726 0.9968726 1.0109189 1.0109189 1.0109189 1.0109189 1.0381503
#>  [862] 1.4499668 1.5440270 3.2816141 3.2816141 2.2931094 0.5143730 1.4633473
#>  [869] 1.0418587 0.8918908 1.0180258 1.0180258 1.0180258 1.0180258 1.3296172
#>  [876] 0.8141899 1.1639021 1.1639021 1.1639021 1.1639021 1.1639021 1.1639021
#>  [883] 1.1639021 1.1639021 1.1639021 1.1639021 1.0104577 1.0104577 1.3718206
#>  [890] 1.3718206 0.4781654 0.4781654 1.7667923 1.7667923 1.7667923 1.7667923
#>  [897] 1.7667923 1.7667923 0.9259173 0.9259173 0.9259173 1.3244212 1.3244212
#>  [904] 2.4605834 1.9714773 0.4524093 0.4524093 0.4791513 0.4791513 0.8351482
#>  [911] 1.5163784 0.9283426 0.9283426 0.9283426 0.9283426 0.9283426 0.9283426
#>  [918] 0.9283426 0.9283426 0.9283426 0.9759194 0.9759194 0.9759194 2.8446955
#>  [925] 2.8446955 2.8446955 2.8446955 2.8446955 1.2281609 1.6832961 0.5177039
#>  [932] 0.5177039 0.5177039 0.7150998 1.3165085 1.3165085 0.4027451 1.2338467
#>  [939] 1.2338467 1.2338467 0.9930500 0.9930500 0.9930500 2.3512887 2.3512887
#>  [946] 2.3512887 1.2156299 1.2156299 1.4062594 1.6876439 2.0516381 2.0516381
#>  [953] 2.0516381 1.6334416 0.7516650 0.7516650 0.7516650 0.5598136 1.2402164
#>  [960] 1.2402164 1.2402164 1.2402164 0.7727921 1.4825662 1.4825662 1.4825662
#>  [967] 1.4825662 1.4825662 1.4825662 1.4825662 0.5155855 0.5155855 0.8892348
#>  [974] 1.2938957 1.5873327 1.5873327 0.6419105 1.8226990 1.4221157 2.5131799
#>  [981] 2.5131799 0.5130339 0.5130339 0.5130339 0.8200089 0.8200089 0.8200089
#>  [988] 0.8200089 0.8200089 1.1306994 0.7719126 0.5369596 0.5369596 0.5369596
#>  [995] 1.2789614 1.2789614 1.2789614 1.2789614 0.4102984 0.7427112
#> 
#> 
#> Slot "options":
#> An object of class "McmcOptions"
#> Slot "iterations":
#> [1] 2100
#> 
#> Slot "burnin":
#> [1] 100
#> 
#> Slot "step":
#> [1] 2
#> 
#> Slot "rng_kind":
#> [1] NA
#> 
#> Slot "rng_seed":
#> [1] NA
#> 
#> 
# Create some data from the class `DataDual`.
plcb <- 0.001
my_data <- DataDual(
  w = c(13, 77, 86, 26, 27, 36, 37, 97, 21, 49, 87, 48),
  x = c(plcb, 25, 25, 25, plcb, 50, 50, 50, plcb, 100, 100, 100),
  y = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L),
  doseGrid = c(plcb, seq(25, 300, 25)),
  placebo = TRUE,
  ID = 1:12,
  cohort = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L)
)

# Initialize the CRM model.
my_model <- DualEndpointRW(
  mean = c(0, 1),
  cov = matrix(c(1, 0, 0, 1), nrow = 2),
  sigma2W = c(a = 0.1, b = 0.1),
  rho = c(a = 1, b = 1),
  sigma2betaW = 0.01,
  rw1 = TRUE
)

# Sample from the posterior distribution.
my_options <- McmcOptions(
  burnin = 50,
  step = 2,
  samples = 4,
  rng_kind = "Mersenne-Twister",
  rng_seed = 1
)

samples <- mcmc(data = my_data, model = my_model, options = my_options)
samples
#> An object of class "Samples"
#> Slot "data":
#> $betaW
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]
#> [1,] 43.97979 44.41466 44.43972 44.11392 44.62213 45.16043 45.16812 45.21349
#> [2,] 43.15657 42.91989 43.51310 44.68803 44.56862 44.87953 44.94821 45.51928
#> [3,] 63.68104 63.29789 63.85898 64.05148 63.52357 64.10696 64.75609 65.32082
#> [4,] 50.45590 49.98192 49.94248 50.23495 50.54648 50.68016 51.02047 50.21193
#>          [,9]    [,10]    [,11]    [,12]    [,13]
#> [1,] 45.17819 44.50411 44.97736 44.98087 45.22721
#> [2,] 45.87216 45.26223 45.42696 45.75288 45.95267
#> [3,] 65.62907 65.52253 66.59065 66.42558 66.77227
#> [4,] 50.02701 49.17010 49.01135 49.45278 49.73688
#> 
#> $betaZ
#>           [,1]       [,2]
#> [1,] -2.507907 0.03496807
#> [2,] -2.507907 0.03496807
#> [3,] -2.507907 0.03496807
#> [4,] -2.507907 0.03496807
#> 
#> $delta
#>            [,1]        [,2]       [,3]       [,4]      [,5]        [,6]
#> [1,]  0.4348687  0.02505645 -0.3258029  0.5082169 0.5382963 0.007687938
#> [2,] -0.2366798  0.59321185  1.1749236 -0.1194105 0.3109172 0.068670722
#> [3,] -0.3831418  0.56109098  0.1924961 -0.5279107 0.5833939 0.649129673
#> [4,] -0.4739807 -0.03943816  0.2924624  0.3115307 0.1336790 0.340314130
#>             [,7]        [,8]       [,9]      [,10]        [,11]     [,12]
#> [1,]  0.04537578 -0.03529845 -0.6740836  0.4732525  0.003504127 0.2463430
#> [2,]  0.57107036  0.35288467 -0.6099253  0.1647277  0.325915901 0.1997869
#> [3,]  0.56472919  0.30824406 -0.1065357  1.0681196 -0.165072414 0.3466892
#> [4,] -0.80854374 -0.18491804 -0.8569132 -0.1587477  0.441429357 0.2841035
#> 
#> $precW
#> [1] 0.0007380298 0.0009402290 0.0006374998 0.0006963610
#> 
#> $rho
#> [1] 0.1193680 0.1129187 0.2440825 0.1499421
#> 
#> 
#> Slot "options":
#> An object of class "McmcOptions"
#> Slot "iterations":
#> [1] 58
#> 
#> Slot "burnin":
#> [1] 50
#> 
#> Slot "step":
#> [1] 2
#> 
#> Slot "rng_kind":
#> [1] "base::Mersenne-Twister"
#> 
#> Slot "rng_seed":
#> [1] 1
#> 
#> 
# Create some data from the class `DataDual`.
plcb <- 0.001
my_data <- DataDual(
  w = c(13, 77, 86, 26, 27, 36, 37, 97, 21, 49, 87, 48),
  x = c(plcb, 25, 25, 25, plcb, 50, 50, 50, plcb, 100, 100, 100),
  y = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L),
  doseGrid = c(plcb, seq(25, 300, 25)),
  placebo = TRUE,
  ID = 1:12,
  cohort = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L)
)

# Initialize the CRM model.
my_model <- DualEndpointBeta(
  mean = c(0, 1),
  cov = diag(2),
  ref_dose = 2,
  use_log_dose = FALSE,
  sigma2W = c(a = 1, b = 2),
  rho = c(a = 1.5, b = 2.5),
  E0 = 2,
  Emax = 50,
  delta1 = 6,
  mode = 9,
  ref_dose_beta = my_data@doseGrid[my_data@nGrid] + 10
)

# Sample from the posterior distribution.
my_options <- McmcOptions(
  burnin = 50,
  step = 2,
  samples = 4,
  rng_kind = "Mersenne-Twister",
  rng_seed = 1
)

samples <- mcmc(data = my_data, model = my_model, options = my_options)
samples
#> An object of class "Samples"
#> Slot "data":
#> $betaW
#>      [,1]     [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#> [1,]    2 2.383076    2    2    2    2    2    2    2     2     2     2     2
#> [2,]    2 2.383076    2    2    2    2    2    2    2     2     2     2     2
#> [3,]    2 2.383076    2    2    2    2    2    2    2     2     2     2     2
#> [4,]    2 2.383076    2    2    2    2    2    2    2     2     2     2     2
#> 
#> $betaZ
#>           [,1]       [,2]
#> [1,] -4.354759 0.09035452
#> [2,] -4.354759 0.09035452
#> [3,] -4.354759 0.09035452
#> [4,] -3.273111 0.08172139
#> 
#> $precW
#> [1] 0.0004229406 0.0004149886 0.0004264222 0.0003413195
#> 
#> $rho
#> [1] -0.5116824 -0.5902350 -0.5709147 -0.5230612
#> 
#> 
#> Slot "options":
#> An object of class "McmcOptions"
#> Slot "iterations":
#> [1] 58
#> 
#> Slot "burnin":
#> [1] 50
#> 
#> Slot "step":
#> [1] 2
#> 
#> Slot "rng_kind":
#> [1] "base::Mersenne-Twister"
#> 
#> Slot "rng_seed":
#> [1] 1
#> 
#> 
##obtain mcmc DLE samples given the data, LogisticIndepBeta (DLE model) and mcmc simulations options
## data must be of 'Data' class
data<-Data(x=c(25,50,50,75,100,100,225,300),y=c(0,0,0,0,1,1,1,1),
           doseGrid=seq(25,300,25))
#> Used default patient IDs!
#> Used best guess cohort indices!
## model must be of 'LogisticIndepBeta' class
model<-LogisticIndepBeta(binDLE=c(1.05,1.8),DLEweights=c(3,3),DLEdose=c(25,300),data=data)
## options must be ''McmcOptions' class
options<-McmcOptions(burnin=100,step=2,samples=200)
set.seed(94)
samples<-mcmc(data=data,model=model,options=options)
# nolint start
##obtain mcmc efficacy samples given the data, 'Effloglog' model (efficacy model) and
## mcmc simulations options data must be of 'DataDual' class
data<-DataDual(x=c(25,50,25,50,75,300,250,150),
              y=c(0,0,0,0,0,1,1,0),
              w=c(0.31,0.42,0.59,0.45,0.6,0.7,0.6,0.52),
              doseGrid=seq(25,300,25),placebo=FALSE)
#> Used default patient IDs!
#> Used best guess cohort indices!
## model must be of 'Effloglog' class
Effmodel<-Effloglog(eff=c(1.223,2.513),eff_dose=c(25,300),nu=c(a=1,b=0.025),data=data)

## options must be ''McmcOptions' class
options<-McmcOptions(burnin=100,step=2,samples=200)
set.seed(94)
samples<-mcmc(data=data,model=Effmodel,options=options)
# nolint end
## obtain mcmc efficacy samples given the data, 'EffFlexi' model (efficacy model) and
## mcmc simulations options
## data must be of 'DataDual' class
data <- DataDual(
  x = c(25, 50, 25, 50, 75, 300, 250, 150),
  y = c(0, 0, 0, 0, 0, 1, 1, 0),
  w = c(0.31, 0.42, 0.59, 0.45, 0.6, 0.7, 0.6, 0.52),
  doseGrid = seq(25, 300, 25)
)
#> Used default patient IDs!
#> Used best guess cohort indices!
## model must be of 'EffFlexi' class

effmodel <- EffFlexi(
  eff = c(1.223, 2.513), eff_dose = c(25, 300),
  sigma2W = c(a = 0.1, b = 0.1), sigma2betaW = c(a = 20, b = 50), rw1 = FALSE, data = data
)

## options must be ''McmcOptions' class
options <- McmcOptions(burnin = 100, step = 2, samples = 200)
set.seed(94)
samples <- mcmc(data = data, model = effmodel, options = options)
ordinal_data <- .DefaultDataOrdinal()
ordinal_model <- .DefaultLogisticLogNormalOrdinal()
mcmc_options <- .DefaultMcmcOptions()

samples <- mcmc(ordinal_data, ordinal_model, mcmc_options)
#> Warning: Unused variable "y" in data