# c95: Compute 95% Credible Interval and Mean In bamlss: Bayesian Additive Models for Location, Scale, and Shape (and Beyond)

## Description

Small helper function that computes the 2.5% and 97.5% quantiles and the mean of a vector. Useful for example when using function `predict.bamlss`.

## Usage

 `1` ```c95(x) ```

## Arguments

 `x` A numeric vector.

`predict.bamlss`, `coef.bamlss`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```x <- rnorm(100) c95(x) ## Not run: ## Example computing predictions. set.seed(123) d <- data.frame("x" = seq(-3, 3, length = 30)) d\$y <- sin(d\$x) + rnorm(30, sd = 0.3) ## Estimate model and compute predictions. ## with c95(). b <- bamlss(y ~ s(x), data = d) p <- predict(b, model = "mu", FUN = c95) plot(d) matplot(d\$x, p, type = "l", lty = c(2, 1, 2), col = "black", add = TRUE) ## Example extracting coefficients. coef(b, FUN = c95) ## End(Not run) ```

### Example output

```Loading required package: coda
This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.

Attaching package: ‘bamlss’

The following object is masked from ‘package:mgcv’:

smooth.construct

2.5%       Mean      97.5%
-1.7693532  0.1394206  1.9100474
AICc  32.7828 logPost -45.1629 logLik  -9.3672 edf 5.5018 eps 0.5485 iteration   1
AICc  24.2758 logPost -37.5892 logLik  -5.2357 edf 5.4242 eps 0.1452 iteration   2
AICc  21.5877 logPost -35.8920 logLik  -3.2511 edf 5.8264 eps 0.0983 iteration   3
AICc  21.2665 logPost -35.5925 logLik  -2.7038 edf 6.0627 eps 0.0344 iteration   4
AICc  21.2497 logPost -35.5556 logLik  -2.5698 edf 6.1384 eps 0.0070 iteration   5
AICc  21.2495 logPost -35.5520 logLik  -2.5516 edf 6.1493 eps 0.0008 iteration   6
AICc  21.2494 logPost -35.5517 logLik  -2.5499 edf 6.1502 eps 0.0000 iteration   7
AICc  21.2494 logPost -35.5517 logLik  -2.5499 edf 6.1502 eps 0.0000 iteration   7
elapsed time:  0.14sec
Starting the sampler...

|                    |   0%  3.09sec
|*                   |   5%  3.04sec  0.16sec
|**                  |  10%  2.94sec  0.33sec
|***                 |  15%  2.82sec  0.50sec
|****                |  20%  2.71sec  0.68sec
|*****               |  25%  2.64sec  0.88sec
|******              |  30%  2.45sec  1.05sec
|*******             |  35%  2.28sec  1.23sec
|********            |  40%  2.09sec  1.40sec
|*********           |  45%  1.93sec  1.58sec
|**********          |  50%  1.77sec  1.77sec
|***********         |  55%  1.60sec  1.96sec
|************        |  60%  1.44sec  2.16sec
|*************       |  65%  1.27sec  2.35sec
|**************      |  70%  1.09sec  2.55sec
|***************     |  75%  0.92sec  2.75sec
|****************    |  80%  0.75sec  3.00sec
|*****************   |  85%  0.56sec  3.18sec
|******************  |  90%  0.37sec  3.37sec
|******************* |  95%  0.19sec  3.59sec
|********************| 100%  0.00sec  3.79sec
2.5%        Mean       97.5%
mu.s.s(x).b1        -2.2228698 -1.52753307 -0.79930659
mu.s.s(x).b2        -1.8736102 -0.15771182  1.83257361
mu.s.s(x).b3        -0.5471637  0.04696152  0.59977765
mu.s.s(x).b4        -1.6725921 -0.24849646  0.97530007
mu.s.s(x).b5        -0.5943349 -0.08611467  0.39970457
mu.s.s(x).b6        -0.9399148  0.11546354  1.41680931
mu.s.s(x).b7        -0.4025812  0.02100879  0.51990939
mu.s.s(x).b8        -2.5278422  0.01623375  2.95938761
mu.s.s(x).b9        -1.9046007 -0.73646681  0.43017304
mu.s.s(x).tau21      1.8018670 10.12671211 39.49809611
mu.s.s(x).alpha      1.0000000  1.00000000  1.00000000
mu.p.(Intercept)    -0.1252683 -0.01533819  0.09304321
mu.p.alpha           1.0000000  1.00000000  1.00000000
sigma.p.(Intercept) -1.4898936 -1.23677270 -0.96268921
sigma.p.alpha        0.5493008  0.93476188  1.00000000
```

bamlss documentation built on May 15, 2021, 9:06 a.m.