Skip to content

Commit

Permalink
number of cores again for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
santikka committed Aug 23, 2023
1 parent b5c0c67 commit c0a0c4b
Show file tree
Hide file tree
Showing 72 changed files with 109 additions and 6 deletions.
11 changes: 6 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# dynamite 1.4.5
* `get_data` method for `dynamitefit` object now correctly uses the previously defined priors instead of the default ones.

* The `get_data()` method for `dynamitefit` objects now correctly uses the previously defined priors instead of the default ones.
* Fixed a bug in indexing of random effect terms.
* Limited the number of parallel threads used by the `data.table` package to 1 in examples, tests, and vignettes for CRAN.

# dynamite 1.4.4

* Example of the `lfo()` method now uses a single chain and core to avoid a compatibility issue with CRAN.
* Fixed `plot_nus` for categorical responses.
* Fixed an issue which caused an error in error message of `predict` and `fitted` methods when `newdata` contained duplicate time points within group.
* Fixed an issue (#72) which caused NA ELPD value in `lfo` in case of missing data.
* Fixed `plot_nus()` for categorical responses.
* Fixed an issue which caused an error in error message of `predict()` and `fitted()` methods when `newdata` contained duplicate time points within group.
* Fixed an issue (#72) which caused NA ELPD value in `lfo()` in case of missing data.

# dynamite 1.4.3

Expand Down
1 change: 1 addition & 0 deletions R/as_data_frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#' model parameters in a long format. For a wide format, see
#' [dynamite::as_draws()].
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' as.data.frame(
#' gaussian_example_fit,
#' responses = "y",
Expand Down
1 change: 1 addition & 0 deletions R/as_data_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @return A `data.table` containing either samples or summary statistics of
#' the model parameters.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' as.data.table(
#' gaussian_example_fit,
#' responses = "y",
Expand Down
1 change: 1 addition & 0 deletions R/as_draws.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#' @inheritParams as.data.frame.dynamitefit
#' @return A `draws_df` object.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' as_draws(gaussian_example_fit, types = c("sigma", "beta"))
#'
#' # Compute MCMC diagnostics using the posterior package
Expand Down
1 change: 1 addition & 0 deletions R/ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#' to `NA`.
#' @srrstats {RE4.3} Provides credible intervals.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' confint(gaussian_example_fit, level = 0.9)
#'
confint.dynamitefit <- function(object, parm, level = 0.95, ...) {
Expand Down
1 change: 1 addition & 0 deletions R/coef.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#' model parameters in a long format.
#' @srrstats {G2.3a, RE4.2} Provides model coefficients.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' betas <- coef(gaussian_example_fit, type = "beta")
#' deltas <- coef(gaussian_example_fit, type = "delta")
#'
Expand Down
2 changes: 2 additions & 0 deletions R/dynamite.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
#' from Panel Data with Dynamic Multivariate Panel Models. SocArxiv preprint,
#' <https://osf.io/preprints/socarxiv/mdwu5/>.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' \donttest{
#' # Please update your rstan and StanHeaders installation before running
#' # on Windows
Expand Down Expand Up @@ -624,6 +625,7 @@ remove_redundant_parameters <- function(stan_input, backend,
#' @family formulas
#' @export
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' formula(gaussian_example_fit)
#'
formula.dynamitefit <- function(x, ...) {
Expand Down
3 changes: 3 additions & 0 deletions R/dynamiteformula.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
#' @srrstats {G2.3b} Uses tolower.
#' @srrstats {RE1.0} Uses a formula interface.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' # A single gaussian response channel with a time-varying effect of 'x',
#' # and a time-varying effect of the lag of 'y' using B-splines with
#' # 20 degrees of freedom for the coefficients of the time-varying terms.
Expand Down Expand Up @@ -351,6 +352,7 @@ parse_name <- function(x) {
#' @param e2 \[`dynamiteformula`]\cr A model formula specification.
#' @export
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' obs(y ~ x, family = "gaussian") + obs(z ~ w, family = "exponential")
#'
`+.dynamiteformula` <- function(e1, e2) {
Expand All @@ -367,6 +369,7 @@ parse_name <- function(x) {
#' @param ... Ignored.
#' @export
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' x <- obs(y ~ x + random(~ 1 + lag(d)), family = "gaussian") +
#' obs(z ~ varying(~w), family = "exponential") +
#' aux(numeric(d) ~ log(y) | init(c(0, 1))) +
Expand Down
1 change: 1 addition & 0 deletions R/fitted.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @return A `data.frame` containing the fitted values.
#' @srrstats {RE4.9} Returns the fitted values.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' fitted(gaussian_example_fit, n_draws = 2L)
#' \donttest{
#' set.seed(1)
Expand Down
6 changes: 6 additions & 0 deletions R/getters.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#' @return A `data.frame` containing the prior definitions.
#' @srrstats {BS5.2} Provides access to the prior definitions of the model.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' d <- data.frame(y = rnorm(10), x = 1:10, time = 1:10, id = 1)
#' get_priors(obs(y ~ x, family = "gaussian"),
#' data = d, time = "time", group = "id"
Expand Down Expand Up @@ -60,6 +61,7 @@ get_priors.dynamitefit <- function(x, ...) {
#' extracts the full model code.
#' @return The Stan model blocks as a `character` string.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' d <- data.frame(y = rnorm(10), x = 1:10, time = 1:10, id = 1)
#' cat(get_code(obs(y ~ x, family = "gaussian"),
#' data = d, time = "time", group = "id"
Expand Down Expand Up @@ -164,6 +166,7 @@ get_code_ <- function(x, blocks = NULL) {
#' @inheritParams get_priors.dynamiteformula
#' @return A `list` containing the input data to Stan.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' d <- data.frame(y = rnorm(10), x = 1:10, time = 1:10, id = 1)
#' str(get_data(obs(y ~ x, family = "gaussian"),
#' data = d, time = "time", group = "id"
Expand Down Expand Up @@ -218,6 +221,7 @@ get_data.dynamitefit <- function(x, ...) {
#' @export
#' @family output
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' get_parameter_dims(multichannel_example_fit)
#'
get_parameter_dims <- function(x, ...) {
Expand Down Expand Up @@ -305,6 +309,7 @@ get_parameters <- function(x) {
#' @export
#' @family output
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' get_parameter_types(multichannel_example_fit)
#'
get_parameter_types <- function(x, ...) {
Expand Down Expand Up @@ -343,6 +348,7 @@ get_parameter_types.dynamitefit <- function(x, ...) {
#' @export
#' @family output
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' get_parameter_names(multichannel_example_fit)
#'
get_parameter_names <- function(x, types = NULL, ...) {
Expand Down
1 change: 1 addition & 0 deletions R/lags.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @return An object of class `lags`.
#' @srrstats {G2.3a} Uses match.arg
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' obs(y ~ -1 + varying(~x), family = "gaussian") +
#' lags(type = "varying") + splines(df = 20)
#'
Expand Down
1 change: 1 addition & 0 deletions R/latent_factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#' The number of knots is based `splines()` call.
#' @return An object of class `latent_factor`.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' # three channel model with common factor affecting for responses x and y
#' obs(y ~ 1, family = "gaussian") +
#' obs(x ~ 1, family = "poisson") +
Expand Down
3 changes: 3 additions & 0 deletions R/lfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#' Approximate leave-future-out cross-validation for Bayesian time series
#' models, Journal of Statistical Computation and Simulation, 90:14, 2499-2523.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' \donttest{
#' # Please update your rstan and StanHeaders installation before running
#' # on Windows
Expand Down Expand Up @@ -259,6 +260,7 @@ lfo <- function(x, L, verbose = TRUE, k_threshold = 0.7, ...) {
#' @return Returns `x` invisibly.
#' @export
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' \donttest{
#' # Please update your rstan and StanHeaders installation before running
#' # on Windows
Expand Down Expand Up @@ -291,6 +293,7 @@ print.lfo <- function(x, ...) {
#' @return A ggplot object.
#' @export
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' \donttest{
#' # Please update your rstan and StanHeaders installation before running
#' # on Windows
Expand Down
1 change: 1 addition & 0 deletions R/loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' Practical Bayesian model evaluation using leave-one-out cross-validation and
#' WAIC. Statistics and Computing. 27(5), 1413–1432.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' \donttest{
#' # Please update your rstan and StanHeaders installation before running
#' # on Windows
Expand Down
1 change: 1 addition & 0 deletions R/mcmc_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' positive (unrestricted) integer.
#' @return Returns `x` (invisibly).
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' mcmc_diagnostics(gaussian_example_fit)
#'
mcmc_diagnostics <- function(x, n) {
Expand Down
1 change: 1 addition & 0 deletions R/ndraws.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param x \[`dynamitefit`]\cr The model fit object.
#' @return Number of posterior draws as a single `integer` value.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' ndraws(gaussian_example_fit)
#'
ndraws.dynamitefit <- function(x) {
Expand Down
1 change: 1 addition & 0 deletions R/nobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @return Total number of non-missing observations as an `integer`.
#' @srrstats {RE4.5} Provides the number of observations.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' nobs(gaussian_example_fit)
#'
nobs.dynamitefit <- function(object, ...) {
Expand Down
4 changes: 4 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#' method. Further plots can be easily constructed with the help of `as_draws`
#' combined with `ggplot2`, for example.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' plot(gaussian_example_fit, type = "beta")
#'
plot.dynamitefit <- function(x, parameters = NULL, type = NULL,
Expand Down Expand Up @@ -97,6 +98,7 @@ plot.dynamitefit <- function(x, parameters = NULL, type = NULL,
#' @srrstats {G2.3a} Uses match.arg.
#' @srrstats {BS6.1, RE6.0, RE6.1, BS6.3} Implements the `plot` method.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' plot_deltas(gaussian_example_fit, level = 0.025, scales = "free") +
#' ggplot2::theme_minimal()
#'
Expand Down Expand Up @@ -210,6 +212,7 @@ plot_deltas <- function(x, parameters = NULL, responses = NULL, level = 0.05,
#' @return A `ggplot` object.
#' @srrstats {BS6.1, RE6.0, RE6.1, BS6.3} Implements the `plot` method.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' plot_betas(gaussian_example_fit, level = 0.1)
#'
plot_betas <- function(x, parameters = NULL, responses = NULL, level = 0.05,
Expand Down Expand Up @@ -301,6 +304,7 @@ plot_betas <- function(x, parameters = NULL, responses = NULL, level = 0.05,
#' @return A `ggplot` object.
#' @srrstats {BS6.1, RE6.0, RE6.1, BS6.3} Implements the `plot` method.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' plot_nus(gaussian_example_fit)
#'
plot_nus <- function(x, parameters = NULL, responses = NULL, level = 0.05,
Expand Down
1 change: 1 addition & 0 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#' @srrstats {RE4.16} New group levels are supported via
#' `new_levels` parameter.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' out <- predict(gaussian_example_fit, type = "response", n_draws = 2L)
#' head(out)
#'
Expand Down
1 change: 1 addition & 0 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @srrstats {BS6.0, RE4.17} Implements the `print` method for the model fit.
#' @srrstats {BS5.3, BS5.5} Contains convergence statistics in the output.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' print(gaussian_example_fit)
#'
print.dynamitefit <- function(x, ...) {
Expand Down
1 change: 1 addition & 0 deletions R/random.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' you encounter divergences or other problems in sampling.
#' @return An object of class `random_spec`.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' # two channel model with correlated random effects for responses x and y
#' obs(y ~ 1 + random(~1), family = "gaussian") +
#' obs(x ~ 1 + random(~1 + z), family = "poisson") +
Expand Down
1 change: 1 addition & 0 deletions R/splines.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#' `splines()`. If `TRUE`, any existing definitions will be replaced.
#' @return An object of class `splines`.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' # Two channel model with varying effects, with explicit lower bounds for the
#' # random walk prior standard deviations, with noncentered parameterization
#' # for the first channel and centered for the second channel.
Expand Down
1 change: 1 addition & 0 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @return `summary` returns a `data.frame`.
#' @srrstats {BS6.4, RE4.18} Implements `summary` method.
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' summary(gaussian_example_fit,
#' types = "beta",
#' probs = c(0.05, 0.1, 0.9, 0.95)
Expand Down
1 change: 1 addition & 0 deletions R/update.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#' @export
#' @family fitting
#' @examples
#' data.table::setDTthreads(1) # For CRAN
#' \dontrun{
#' # re-estimate the example fit without thinning:
#' # As the model is compiled on Windows, this will fail on other platforms
Expand Down
1 change: 1 addition & 0 deletions man/as.data.frame.dynamitefit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/as.data.table.dynamitefit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/as_draws-dynamitefit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/coef.dynamitefit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/confint.dynamitefit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/dynamite.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/dynamiteformula.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/fitted.dynamitefit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c0a0c4b

Please sign in to comment.