Skip to content

Commit

Permalink
Merge pull request #166 from lindeloev/v0.3.4
Browse files Browse the repository at this point in the history
mcp 0.3.4 (make CRAN happy)
  • Loading branch information
lindeloev authored Mar 20, 2024
2 parents 55ef000 + 98363aa commit 9a1d4bc
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 84 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:

name: R-CMD-check

Expand Down
2 changes: 0 additions & 2 deletions CRAN-RELEASE

This file was deleted.

8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mcp
Title: Regression with Multiple Change Points
Version: 0.3.3
Date: 2023-03-19
Version: 0.3.4
Date: 2024-03-14
URL: https://lindeloev.github.io/mcp/
BugReports: https://github.com/lindeloev/mcp/issues
Authors@R:
Expand All @@ -15,7 +15,7 @@ License: GPL-2
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Depends: R (>= 3.5.0)
Imports:
Expand All @@ -27,7 +27,7 @@ Imports:
loo (>= 2.1.0),
bayesplot (>= 1.7.0),
tidybayes (>= 3.0.0),
dplyr (>= 1.0.0),
dplyr (>= 1.1.1),
magrittr (>= 1.5),
tidyr (>= 1.0.0),
tidyselect (>= 0.2.5),
Expand Down
13 changes: 12 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# mcp 0.3.4

This is a bug fix release.

## Bug fixes

* Now respects the `cores` argument to `mcp()`.
* Document all function arguments and remove documentation for removed arguments.



# mcp 0.3.3

This is a bug fix release
This is a bug fix release.

## Bug fixes

Expand Down
5 changes: 1 addition & 4 deletions R/get_formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ get_formula_str = function(ST, par_x, ytype = "ct", init = FALSE) {
#' @keywords internal
#' @inheritParams mcp
#' @param formula_str string. Returned by `get_formula`.
#' @param par_trials String. For binomial models: name of trials column.
#' @param pars_pop List of population parameters which the user must provide.
#' @param pars_varying List varying parameters. They will default to zero
#' (optional for the user).
#' @param pars List of user-provided parameters, in the format of fit$pars.
#' @param nsegments Positive integer. Number of segments, typically `nrow(ST)`.
#' @return A string with R code for the fit$simulate() function corresponding to the model.
#' @encoding UTF-8
Expand Down
28 changes: 2 additions & 26 deletions R/mcp-package.R
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@
#' Regression with Multiple Change Points
#'
#' @docType package
#' @name mcp-package
#' @aliases mcp-package
#'
#' @description
#' The \pkg{mcp} package provides an interface to fit regression models with
#' multiple change points between generalized linear segments, optionally with
#' per-segment variance and autocorrelation structures.
#'
#' The main function of \pkg{mcp} is the `mcp()` function, which uses a formula
#' syntax to specify a wide range of change point models. Based on the supplied
#' data, formulas, and additional information, it writes JAGS code on the fly
#' and use \pkg{rstan} to fit the model, optionally in parallel to speed up
#' sampling. You will need to install JAGS for `mcp()` to work.
#'
#' A large number of post-processing methods can be applied. These include
#'
#' * Summarise fits using `summary()`, `fixef()`, and `ranef()`.
#' * Visualize fits using `plot()` and individual parameters using `plot_pars()`.
#' * Test hypotheses using `hypothesis()` and `loo()`.
#'
#' Extensive documentation with worked examples is available at the
#' [mcp website](https://lindeloev.github.io/mcp/).
NULL
#' @keywords internal
"_PACKAGE"
13 changes: 7 additions & 6 deletions R/mcpfit_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ get_summary = function(fit, width, varying = FALSE, prior = FALSE) {

# Add simulation to the beginning of the list
estimates = estimates %>%
dplyr::left_join(simulated, by = "name", multiple = "all") %>%
dplyr::left_join(simulated, by = "name", relationship = "one-to-one") %>%
dplyr::mutate(match = ifelse(.data$sim > .data$lower & .data$sim < .data$upper, yes = "OK", no = "")) %>%
dplyr::select("name", "match", "sim", "mean", "lower", "upper")
}
Expand Down Expand Up @@ -536,7 +536,7 @@ tidy_samples = function(
#' @param scale One of
#' * "response": return on the observed scale, i.e., after applying the inverse link function.
#' * "linear": return on the parameter scale (where the linear trends are modelled).
#' @param ... Currently ignored.
#' @param ... Currently unused
#' @return
#' * If `summary = TRUE`: A `tibble` with the posterior mean for each row in `newdata`,
#' If `newdata` is `NULL`, the data in `fit$data` is used.
Expand Down Expand Up @@ -574,7 +574,8 @@ pp_eval = function(
arma = TRUE,
nsamples = NULL,
samples_format = "tidy",
scale = 'response'
scale = 'response',
...
) {
# Recodings
fit = object
Expand Down Expand Up @@ -660,7 +661,7 @@ pp_eval = function(
newdata,
tidy_samples(fit, population = TRUE, varying = varying, prior = prior, nsamples = nsamples),
by = unique(varying_info$cols),
multiple = "all"
relationship = "many-to-many"
) %>%
dplyr::mutate(!!returnvar := rlang::exec(fit$simulate, !!!., type = type_for_simulate, rate = rate, which_y = which_y, arma = arma, add_attr = FALSE, scale = scale))
} else {
Expand All @@ -686,7 +687,7 @@ pp_eval = function(

# Apply original order and put newdata as the first columns
dplyr::arrange(.data$data_row) %>%
dplyr::left_join(newdata, by = "data_row") %>%
dplyr::left_join(newdata, by = "data_row", relationship = "one-to-one") %>%
dplyr::select(dplyr::one_of(colnames(newdata)), !!returnvar, "error", -"data_row")


Expand All @@ -697,7 +698,7 @@ pp_eval = function(
dplyr::mutate(quantile = 100 * .data$quantile) %>%
tidyr::pivot_wider(names_from = "quantile", names_prefix = "Q", values_from = "y")

df_return = dplyr::left_join(df_return, quantiles_fit, by = as.character(xvar))
df_return = dplyr::left_join(df_return, quantiles_fit, by = as.character(xvar), relationship = "many-to-one")
}
return(data.frame(df_return))
} else if (samples_format == "tidy") {
Expand Down
13 changes: 8 additions & 5 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ get_arma_order = function(pars_arma) {
# Ask reminder questions for CRAN export
release_questions = function() {
c(
"Have you run the test of fits? options(test_mcp_fits = TRUE)",
"Have you built the README plots and checked them? source('vignettes/figures/make_README_plots.R')",
"Have you re-built the site using pkgdown::build_site() AFTER deleting caches of articles?",
"Have you checked all articles and plots after re-building the site?",
"Have you run the script to insert the correct logo.png in the HTML meta?"
"TEST: Have you run the extensive tests? options(test_mcp_allmodels = TRUE)",
"TEST: Have you run the test of fits? options(test_mcp_fits = TRUE)",
"TEST: Have you run `revdepcheck::revdep_check()`?",

"DOC: Have you built the README plots and checked them? source('vignettes/figures/make_README_plots.R')",
"DOC: Have you re-built the site using pkgdown::build_site() AFTER deleting caches of articles in 'vignettes/*_cache/'?",
"DOC: Have you checked all articles and plots after re-building the site?",
"DOC: Have you run the script to insert the correct logo.png in the HTML meta?"
)
}

Expand Down
3 changes: 0 additions & 3 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ plot.mcpfit = function(x,
#' @keywords internal
#' @param fit An `mcpfit` object
#' @param facet_by `NULL` or a a string, like `plot.mcpfit(..., facet_by = "id").`
#' @param include Boolean. If `TRUE` and `!is.null(facet_by)`, only return
#' densities for the change points "affected" by `facet_by`. If `FALSE` and `!is.null(facet_by)`,
#' return all densities except those "affected" by `facet_by`. Has no effect if `is.null(facet_by)`
#' @return A `ggplot2::stat_density` geom representing the change point densities.
geom_cp_density = function(fit, facet_by, limits_y) {
dens_scale = 0.2 # Proportion of plot height
Expand Down
2 changes: 1 addition & 1 deletion R/run_jags.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ run_jags = function(data,
} else if (cores == "all" || cores > 1) {
# PARALLEL using the future package and one chain per worker
message("Parallel sampling in progress...")
future::plan(future::multisession, .skip = TRUE)
future::plan(future::multisession, workers = cores, .skip = TRUE)
samples = future.apply::future_lapply(
sample(1:1000, n.chains), # Random seed to JAGS
n.chains = 1,
Expand Down
23 changes: 23 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# mcp 0.3.4

## Notes for the reviewer

* This fixes NOTES about arguments with missing documentation.

## R CMD check results
There were no ERRORs or WARNINGs except the usual artificial ones (see "Expected
NOTEs and ERRORs" in the bottom of this file).

## Test environments
Github Actions: oldrel, release, and devel on Ubuntu.
Github Actions: release on MacOS and Windows.

## Downstream dependencies
We checked 1 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages




# mcp 0.3.3

## Notes for the reviewer
Expand Down
2 changes: 1 addition & 1 deletion man/fitted.mcpfit.Rd

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

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

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

9 changes: 2 additions & 7 deletions man/get_simulate.Rd

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

29 changes: 13 additions & 16 deletions man/mcp-package.Rd

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

5 changes: 3 additions & 2 deletions man/pp_eval.Rd

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

2 changes: 1 addition & 1 deletion man/predict.mcpfit.Rd

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

2 changes: 1 addition & 1 deletion man/residuals.mcpfit.Rd

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

0 comments on commit 9a1d4bc

Please sign in to comment.