chain: Return the MCMC chain in a 'data.frame'

Description Usage Arguments Value Author(s) See Also Examples

View source: R/functions.R

Description

chain is a function that returns a data.frame of calibration run without the burn-in

Usage

1
chain(modelfit, coda = TRUE)

Arguments

modelfit

a calibrate.class object

coda

if TRUE returns a coda object (if Nchains in opt.estim is higher than 1 a coda object is automatically returned see codamenu)

Value

return a data.frame or a coda object of the MCMC chain(s) generated.

Author(s)

M. Carmassi

See Also

model, prior, calibrate, sequentialDesign

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
###################### The code to calibrate
X <- cbind(seq(0,1,length.out=10),seq(0,1,length.out=10))
code <- function(X,theta)
{
  return((6*X[,1]*theta[2]-2)^2*theta[1]*sin(theta[3]*X[,2]-4))
}
Yexp <- code(X,c(1,1,11))+rnorm(10,0,0.1)

############### For the first model
###### Definition of the model
md <- model(code,X,Yexp,"model1")
###### Definition of the prior densities
pr <- prior(type.prior=c("gaussian","gaussian","gaussian","gamma"),opt.prior=
list(c(1,0.01),c(1,0.01),c(11,3),c(2,0.1)))
###### Definition of the calibration options
opt.estim=list(Ngibbs=200,Nmh=600,thetaInit=c(1,1,11,0.1),r=c(0.3,0.3),
sig=diag(4),Nchains=1,burnIn=100)
###### Run the calibration
mdfit <- calibrate(md,pr,opt.estim)

mcmc <- chain(mdfit)
### Check coda object
is.mcmc(mcmc)
### get all the chain
mcmc <- chain(mdfit,coda=FALSE)
head(mcmc)

### Multi chains
opt.estim=list(Ngibbs=200,Nmh=600,thetaInit=c(1,1,11,0.1),r=c(0.3,0.3),
sig=diag(4),Nchains=2,burnIn=100)
###### Run the calibration
mdfit2 <- calibrate(md,pr,opt.estim)

mcmc <- chain(mdfit2)
is.mcmc.list(mcmc)

## End(Not run)

mathieucarmassi/calibrationcode documentation built on Aug. 14, 2019, 12:35 a.m.