bdw.multicore: Producing several chains from a MCMC object of class 'bdw'

Description Usage Arguments Value Author(s) See Also Examples

Description

This function is equipped with multicore options to produce several chains from a MCMC of class 'bdw'

Usage

1
bdw.mc(dw.object, n.repeat = 10, cores = 0)

Arguments

dw.object

Object of class 'bdw'.

n.repeat

The number of chains to be generated.

cores

The number of processors. If set to zero then the procedure uses all cores.

Value

An object of class 'bdw'. All chains are combined into a list that is stored in an object named 'all'. The output of this function can be passed to plot() and summary().

Author(s)

Hamed Haselimashhadi <[email protected]>

See Also

bdw, plot.bdw, summary.bdw

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
39
40
## Not run: 
  #==== multicore example - estimating logit-DW(regQ,B) parameters using RJ and 5 chains ======
  #==== Two variables and four coefficients, including intercepts, are simulated and analysed
  set.seed(1234)
  n = 500
  x1 = runif(n = n, min = 0, max = 1.5)
  x2 = runif(n = n, min = 0, max = 1.5)

  theta0 = .6   #<<< true parameter
  theta1 =  0   #<<< true parameter
  theta2 = .34  #<<< true parameter

  lq = theta0 +  x1*theta1 + x2*theta2

  q = exp(lq - log(1+exp(lq)) )
  beta = 1.5

  y = c()
  for(i in 1:n){
    y[i] = BDWreg:::rdw(1,q = q[i],beta = beta)
  }

  data = data.frame(x1,x2,y) # <<<- data
  result = bdw(data = data              ,
               formula = y~.             ,
               RJ = TRUE                 ,
               initial = rep(.5,4)       ,
               iteration = 25000         ,
               reg.b = FALSE,reg.q = TRUE,
               v.scale = .1              ,
               q.par = c(0,1)            ,
               b.par = c(0,1)            ,
               dist.q = dnorm            ,
               dist.b = dnorm
  )
  result2 = bdw.mc(result,5) # <<<- multicore
  plot(result2)
  summary(result2)

## End(Not run)

BDWreg documentation built on May 30, 2017, 12:31 a.m.