Converts a stanfit object into a mcmc object for easier analysis.

stan2mcmc(stanFit)

Arguments

stanFit

a stanfit object from the output of either fecr_stan() or fec_stan()

Value

A MCMC object with a list of relevant parameters.

Details

The output can be analyzed as a mcmc object with the functions from the coda package. NOTE: The resulting MCMC object does not contain warm-up samples and is already thinned.

Examples

data(epgs) ## apply zero-infation model for the paired design model <- fecr_stan(epgs$before, epgs$after, rawCounts = FALSE, indEfficacy = FALSE, preCF = 10, paired = TRUE, zeroInflation = TRUE)
#> #> SAMPLING FOR MODEL 'zipaired' NOW (CHAIN 1). #> Chain 1: Gradient evaluation took 5.6e-05 seconds #> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.56 seconds. #> Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup) #> Chain 1: Iteration: 500 / 2000 [ 25%] (Warmup) #> Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup) #> Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling) #> Chain 1: Iteration: 1500 / 2000 [ 75%] (Sampling) #> Chain 1: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 1: Elapsed Time: 1.10743 seconds (Warm-up) #> Chain 1: 0.685517 seconds (Sampling) #> Chain 1: 1.79294 seconds (Total) #> #> SAMPLING FOR MODEL 'zipaired' NOW (CHAIN 2). #> Chain 2: Gradient evaluation took 2.5e-05 seconds #> Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.25 seconds. #> Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup) #> Chain 2: Iteration: 500 / 2000 [ 25%] (Warmup) #> Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup) #> Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling) #> Chain 2: Iteration: 1500 / 2000 [ 75%] (Sampling) #> Chain 2: Iteration: 2000 / 2000 [100%] (Sampling) #> Chain 2: Elapsed Time: 1.04059 seconds (Warm-up) #> Chain 2: 0.817354 seconds (Sampling) #> Chain 2: 1.85795 seconds (Total) #> Model: Zero-inflated Bayesian model for paired design #> Number of Samples: 2000 #> Warm-up samples: 1000 #> Thinning: 1 #> Number of Chains 2 #> mean sd 2.5% 50% 97.5% HPDLow95 #> FECR 0.9270 0.0069 0.9129 0.9272 0.9398 0.9138 #> meanEPG.untreated 1122.4649 460.9544 452.6852 1043.8116 2252.4964 354.4322 #> meanEPG.treated 81.8469 34.8374 33.1745 75.8447 168.7987 23.3838 #> mode HPDHigh95 #> FECR 0.9274 0.9406 #> meanEPG.untreated 892.3415 2023.0249 #> meanEPG.treated 62.9578 147.5620 #> #> NOTE: there is no evidence of non-convergence since all parameters have potential scale reduction factors (Brooks and Gelman, 1998) less than 1.1.
samples <- stan2mcmc(model$stan.samples) summary(samples)
#> #> Iterations = 1:2000 #> Thinning interval = 1 #> Number of chains = 1 #> Sample size per chain = 2000 #> #> 1. Empirical mean and standard deviation for each variable, #> plus standard error of the mean: #> #> Mean SD Naive SE Time-series SE #> FECR 9.270e-01 6.903e-03 1.544e-04 1.544e-04 #> meanEPG.untreated 1.122e+03 4.610e+02 1.031e+01 1.031e+01 #> meanEPG.treated 8.185e+01 3.484e+01 7.790e-01 7.790e-01 #> kappa 5.220e-01 2.933e-01 6.557e-03 5.917e-03 #> phi 4.426e-01 1.210e-01 2.706e-03 2.706e-03 #> delta 7.297e-02 6.903e-03 1.544e-04 1.544e-04 #> #> 2. Quantiles for each variable: #> #> 2.5% 25% 50% 75% 97.5% #> FECR 0.91294 0.92253 9.272e-01 9.317e-01 9.398e-01 #> meanEPG.untreated 452.68521 803.92664 1.044e+03 1.338e+03 2.252e+03 #> meanEPG.treated 33.17448 58.09237 7.584e+01 9.700e+01 1.688e+02 #> kappa 0.14572 0.30283 4.483e-01 6.765e-01 1.244e+00 #> phi 0.19292 0.36378 4.498e-01 5.269e-01 6.653e-01 #> delta 0.06017 0.06831 7.279e-02 7.747e-02 8.706e-02 #>
plot(samples)