Running examples in ‘bssm-Ex.R’ failed
The error most likely occurred in:

> ### Name: run_mcmc.nongaussian
> ### Title: Bayesian Inference of Non-Gaussian State Space Models
> ### Aliases: run_mcmc.nongaussian
> 
> ### ** Examples
> 
> set.seed(1)
> n <- 50 
> slope <- cumsum(c(0, rnorm(n - 1, sd = 0.001)))
> level <- cumsum(slope + c(0, rnorm(n - 1, sd = 0.2)))
> y <- rpois(n, exp(level))
> poisson_model <- bsm_ng(y, 
+   sd_level = halfnormal(0.01, 1), 
+   sd_slope = halfnormal(0.01, 0.1), 
+   P1 = diag(c(10, 0.1)), distribution = "poisson")
>   
> # Note small number of iterations for CRAN checks
> mcmc_out <- run_mcmc(poisson_model, iter = 1000, particles = 10, 
+   mcmc_type = "da")
> summary(mcmc_out, what = "theta", return_se = TRUE)
              Mean        SD         SE      ESS
sd_level 0.2144235 0.1053168 0.01699091 38.42046
sd_slope 0.0302117 0.0232767 0.00242895 91.83449
> 
> set.seed(123)
> n <- 50
> sd_level <- 0.1
> drift <- 0.01
> beta <- -0.9
> phi <- 5
> 
> level <- cumsum(c(5, drift + rnorm(n - 1, sd = sd_level)))
> x <- 3 + (1:n) * drift + sin(1:n + runif(n, -1, 1))
> y <- rnbinom(n, size = phi, mu = exp(beta * x + level))
> 
> model <- bsm_ng(y, xreg = x,
+   beta = normal(0, 0, 10),
+   phi = halfnormal(1, 10),
+   sd_level = halfnormal(0.1, 1), 
+   sd_slope = halfnormal(0.01, 0.1),
+   a1 = c(0, 0), P1 = diag(c(10, 0.1)^2), 
+   distribution = "negative binomial")
> 
> # run IS-MCMC
> # Note small number of iterations for CRAN checks
> # so no real use of parallelization
> fit <- run_mcmc(model, iter = 5000,
+   particles = 10, mcmc_type = "is2", seed = 1, threads = 2)
> 
> # extract states   
> d_states <- as.data.frame(fit, variable = "states", time = 1:n)
> 
> library("dplyr")

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> library("ggplot2")
> 
>  # compute summary statistics
> level_sumr <- d_states %>% 
+   filter(variable == "level") %>%
+   group_by(time) %>%
+   summarise(mean = Hmisc::wtd.mean(value, weight, normwt = TRUE), 
+     lwr = Hmisc::wtd.quantile(value, weight, 
+       0.025, normwt = TRUE), 
+     upr = Hmisc::wtd.quantile(value, weight, 
+       0.975, normwt = TRUE))
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Warning in regularize.values(x, y, ties, missing(ties), na.rm = na.rm) :
  collapsing to unique 'x' values
Error: Problem with `summarise()` input `lwr`.
✖ zero non-NA points
ℹ Input `lwr` is `Hmisc::wtd.quantile(value, weight, 0.025, normwt = TRUE)`.
ℹ The error occurred in group 38: time = 38.
Backtrace:
     █
  1. ├─`%>%`(...)
  2. ├─dplyr::summarise(...)
  3. ├─dplyr:::summarise.grouped_df(...)
  4. │ └─dplyr:::summarise_cols(.data, ...)
  5. │   ├─base::withCallingHandlers(...)
  6. │   └─mask$eval_all_summarise(quo)
  7. ├─Hmisc::wtd.quantile(value, weight, 0.025, normwt = TRUE)
  8. │ └─stats::approx(...)
  9. │   └─base::stop("zero non-NA points")
 10. └─base::.handleSimpleError(...)
 11.   └─dplyr:::h(simpleError(msg, call))
Execution halted