LaplaceApproximation: A simple class the maximum likelihood optimizes each...

Description Usage Arguments Details Value See Also Examples

Description

This is a simple slice sampler that uses stepping out for interval estimation.

Usage

1
 sampler = new("LaplaceApproximation",model)

Arguments

model

Constructor takes the model object create by the lexer

Details

This sampler inherits from MCMCsampler, so that it can benefit from the there implement functionality. It overwrites the sample function that gets called with the likelihood and prior. It used the R optim function to optimize the posterior and sets this value

Value

Returns a valid sampler object.

See Also

Package Overview: Slice-Package

Base sampler class: Sampler

Slice sampler class: MCMCsampler

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
41
42
43
44
45
46
47
48
49
50
51
require(Slice)


set.seed(1234)
n <- 100
lambda = 1.125
beta   <- c(1.4,-0.5)
sigma2 <- 0.1
n_time = 10

beta_new = beta[1]
beta_new = cbind(beta_new, beta[2])

X<-cbind(matrix(rnorm(n*n_time,2,1) ,ncol = n_time) ,1)

val = X
y<- matrix( val + rnorm(n, 0,sigma2) ,ncol = 1)

colnames(y) = 'y'
x<- matrix(X[,1:(ncol(X)-1) ],ncol = n_time)
colnames(x)= paste('x_',1:n_time,sep = '')

model_str= "
model regModel{

  y ~ dnorm( mu , sigma) 
  sequ =  lambda * seq(0,weights-1) 
  mu = x 

  lambda~dgamma(0.001,0.001)
  sigma~dgamma(0.001,0.001)
  beta0 ~ dnorm(0,s)
  beta1 ~ dnorm(0,s)
  s~dgamma(0.001,0.001)
}
"

data_list = list( 'y'=y , 'x'=x ,'weights'=n_time)

lex = new('Lexer')
lex$setModelString(model_str)
lex$setModelData(data_list)

lex$lexModel()

root_plate = lex$parseModel()

laplace = new('LaplaceApproximation',root_plate)
laplaceApprox = laplace$takeSample(50)

plot(laplaceApprox[,1])

dennisthemenace2/Slice documentation built on Nov. 4, 2019, 10:26 a.m.