isdiag: Diagnostics for importance sampling from stanoptim

Description Usage Arguments Value Examples

View source: R/isdiag.R

Description

Diagnostics for importance sampling from stanoptim

Usage

1
isdiag(fit, wait = TRUE)

Arguments

fit

Output from stanoptimis when isloops > 0

Value

Nothing. Plots convergence of parameter mean estimates from initial Hessian based distribution to final sampling distribution.

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
## Not run: 
library(rstan)
scode <- "
parameters {
  real y[2];
}
model {
  y[1] ~ normal(0, 1);
  y[2] ~ double_exponential(0, 2);
}
"

sm <- stan_model(model_code=scode)

fit1 <- sampling(object = sm, iter = 10, verbose = FALSE)
print(fit1)
fit2 <- stan(fit = fit1, iter = 10000, verbose = FALSE)

## extract samples as a list of arrays
e2 <- extract(fit2, permuted = TRUE)

## using as.array on the stanfit object to get samples
a2 <- as.array(fit2)


optimfit <- optimstan(standata = list(),sm = sm,isloops=10,finishsamples = 1000,cores=3)

apply(optimfit$posterior,2,mean)
apply(optimfit$posterior,2,sd)
isdiag(optimfit)

plot(density(optimfit$posterior))
points(density(e2$y))

## End(Not run)

cdriveraus/stanoptimis documentation built on July 26, 2019, 3:18 p.m.