Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

name: R-CMD-check

jobs:
Expand All @@ -27,19 +31,24 @@ jobs:
TESTTHAT_CPUS: 4

steps:
- uses: n1hility/cancel-previous-runs@master
- uses: actions/checkout@v7

- uses: r-lib/actions/setup-r@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
r-version: ${{ matrix.r }}

- uses: actions/checkout@main
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2.11.4

- name: Install R Package Build Dependencies on MacOS
if: ${{ runner.os == 'macOS' }}
uses: r-hub/actions/setup-r-sysreqs@v1
with:
r-version: ${{ matrix.r }}
type: 'minimal'

- uses: r-lib/actions/setup-pandoc@v2.11.4
- uses: r-lib/actions/setup-r-dependencies@v2.11.4
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck any::betareg any::HSAUR3 any::biglm any::gamm4 any::V8
- uses: r-lib/actions/check-r-package@v2.11.4
dependencies: "TRUE"
extra-packages: any::rcmdcheck, rstan?source

- uses: r-lib/actions/check-r-package@v2
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Encoding: UTF-8
Authors@R: c(person("Jonah", "Gabry", email = "jgabry@gmail.com", role = "aut"),
person("Imad", "Ali", role = "ctb"),
person("Sam", "Brilleman", role = "ctb"),
person("Andrew", "Johnson", role = "ctb"),
person(given = "Jacqueline Buros", family = "Novik",
role = "ctb", comment = "R/stan_jm.R"),
person("AstraZeneca", role = "ctb", comment = "R/stan_jm.R"),
Expand Down Expand Up @@ -63,7 +64,7 @@ Suggests:
rmarkdown,
roxygen2,
StanHeaders (>= 2.21.0),
testthat (>= 1.0.2),
testthat (>= 3.0.0),
gamm4,
shiny,
V8
Expand All @@ -76,4 +77,6 @@ UseLTO: true
NeedsCompilation: yes
URL: https://mc-stan.org/rstanarm/, https://discourse.mc-stan.org
BugReports: https://github.com/stan-dev/rstanarm/issues
RoxygenNote: 7.3.3
Config/roxygen2/version: 8.1.0
Config/testthat/edition: 3
Config/testthat/parallel: true
177 changes: 98 additions & 79 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -197,88 +197,107 @@ import(methods)
import(rstantools)
import(shinystan)
import(stats)
importFrom(Matrix,Matrix)
importFrom(Matrix,t)
importFrom(Matrix,
Matrix,
t
)
importFrom(RcppParallel,RcppParallelLibs)
importFrom(bayesplot,pairs_condition)
importFrom(bayesplot,pairs_style_np)
importFrom(ggplot2,"%+replace%")
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,coord_cartesian)
importFrom(ggplot2,element_line)
importFrom(ggplot2,element_text)
importFrom(ggplot2,expand_limits)
importFrom(ggplot2,facet_wrap)
importFrom(ggplot2,geom_contour)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_pointrange)
importFrom(ggplot2,geom_ribbon)
importFrom(ggplot2,geom_segment)
importFrom(ggplot2,geom_smooth)
importFrom(ggplot2,geom_step)
importFrom(ggplot2,geom_vline)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggplot_build)
importFrom(ggplot2,labs)
importFrom(ggplot2,rel)
importFrom(ggplot2,scale_color_gradient2)
importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,scale_x_discrete)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(ggplot2,xlab)
importFrom(lme4,fixef)
importFrom(lme4,glFormula)
importFrom(lme4,glmer)
importFrom(lme4,glmerControl)
importFrom(lme4,lmer)
importFrom(lme4,lmerControl)
importFrom(lme4,mkVarCorr)
importFrom(lme4,ngrps)
importFrom(lme4,nlformula)
importFrom(lme4,nlmer)
importFrom(lme4,nlmerControl)
importFrom(lme4,ranef)
importFrom(loo,is.kfold)
importFrom(loo,is.loo)
importFrom(loo,is.waic)
importFrom(loo,kfold)
importFrom(loo,loo)
importFrom(loo,loo.function)
importFrom(loo,loo.matrix)
importFrom(loo,loo_compare)
importFrom(loo,loo_model_weights)
importFrom(loo,psis)
importFrom(loo,waic)
importFrom(loo,waic.function)
importFrom(loo,waic.matrix)
importFrom(bayesplot,
pairs_condition,
pairs_style_np
)
importFrom(ggplot2,
"%+replace%",
aes,
aes_string,
coord_cartesian,
element_line,
element_text,
expand_limits,
facet_wrap,
geom_contour,
geom_line,
geom_point,
geom_pointrange,
geom_ribbon,
geom_segment,
geom_smooth,
geom_step,
geom_vline,
ggplot,
ggplot_build,
labs,
rel,
scale_color_gradient2,
scale_x_continuous,
scale_x_discrete,
theme,
theme_bw,
xlab
)
importFrom(lme4,
fixef,
glFormula,
glmer,
glmerControl,
lmer,
lmerControl,
mkVarCorr,
ngrps,
nlformula,
nlmer,
nlmerControl,
ranef
)
importFrom(loo,
is.kfold,
is.loo,
is.waic,
kfold,
loo,
loo.function,
loo.matrix,
loo_compare,
loo_model_weights,
psis,
waic,
waic.function,
waic.matrix
)
importFrom(nlme,VarCorr)
importFrom(posterior,as_draws)
importFrom(posterior,as_draws_array)
importFrom(posterior,as_draws_df)
importFrom(posterior,as_draws_list)
importFrom(posterior,as_draws_matrix)
importFrom(posterior,as_draws_rvars)
importFrom(posterior,
as_draws,
as_draws_array,
as_draws_df,
as_draws_list,
as_draws_matrix,
as_draws_rvars
)
importFrom(reformulas,findbars)
importFrom(rstan,constrain_pars)
importFrom(rstan,extract)
importFrom(rstan,extract_sparse_parts)
importFrom(rstan,get_posterior_mean)
importFrom(rstan,optimizing)
importFrom(rstan,sampling)
importFrom(rstan,stanc)
importFrom(rstan,vb)
importFrom(rstantools,loo_R2)
importFrom(rstantools,nsamples)
importFrom(stats,cov2cor)
importFrom(stats,getInitial)
importFrom(rstan,
constrain_pars,
extract,
extract_sparse_parts,
get_posterior_mean,
optimizing,
sampling,
stanc,
vb
)
importFrom(rstantools,
loo_R2,
nsamples
)
importFrom(stats,
cov2cor,
getInitial
)
importFrom(survival,Surv)
importFrom(utils,capture.output)
importFrom(utils,head)
importFrom(utils,packageVersion)
importFrom(utils,tail)
importFrom(utils,
capture.output,
head,
packageVersion,
tail
)
importMethodsFrom(rstan,summary)
useDynLib(rstanarm, .registration = TRUE)
3 changes: 1 addition & 2 deletions R/jm_data_block.R
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ get_common_cnms <- function(x, stub = "Long") {
if (nm %in% nms[[m]]) paste0(stub, m, "|", x[[m]][[nm]])))
})
names(cnms) <- unique_nms
cnms
cnms[order(names(cnms))]
}

# Function to return a single list with the factor levels for each
Expand Down Expand Up @@ -2097,4 +2097,3 @@ handle_weights <- function(mod_stuff, weights, id_var) {

wts
}

2 changes: 1 addition & 1 deletion R/pp_check.R
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ is_binomial_ppc <- function(object, ...) {
if (!is.null(xvar)) {
dots[["x"]] <- .ppc_xvar(object, xvar, m = m)
} else {
if (funname %in% c("ppc_intervals", "ppc_ribbon", "ppc_error_binned")) {
if (funname %in% c("ppc_intervals", "ppc_ribbon", "ppc_error_binned", "ppc_error_scatter_avg")) {
message("'x' not specified in '...'. Using x=1:length(y).")
dots[["x"]] <- seq_along(y)
} else {
Expand Down
15 changes: 8 additions & 7 deletions R/stan_gamm4.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ stan_gamm4 <-
#'
#' @return \code{plot_nonlinear} returns a ggplot object.
#'
#' @importFrom ggplot2 aes_ aes_string facet_wrap ggplot geom_contour geom_line geom_ribbon labs scale_color_gradient2
#' @importFrom ggplot2 aes aes_string facet_wrap ggplot geom_contour geom_line geom_ribbon labs scale_color_gradient2
#'
plot_nonlinear <- function(x, smooths, ...,
prob = 0.9, facet_args = list(),
Expand All @@ -301,6 +301,7 @@ plot_nonlinear <- function(x, smooths, ...,
stop("Plot only available for models fit using the stan_gamm4 function.")
on.exit(message("try plot(x$jam) instead"))
scheme <- bayesplot::color_scheme_get()
predictor <- lower <- upper <- middle <- y <- z <- NULL

XZ <- x$x
XZ <- XZ[,!grepl("_NEW_", colnames(XZ), fixed = TRUE)]
Expand Down Expand Up @@ -354,7 +355,7 @@ plot_nonlinear <- function(x, smooths, ...,
xz <- XZ[, grepl(labels, colnames(XZ), fixed = TRUE), drop = FALSE]
plot_data$z <- apply(linear_predictor.matrix(b, xz), 2, FUN = median)
return(
ggplot(plot_data, aes_(x = ~x, y = ~y, z = ~z)) +
ggplot(plot_data, aes(x = x, y = y, z = z)) +
geom_contour(aes_string(color = "..level.."), size = size/2) +
labs(x = xnames[1], y = xnames[2]) +
scale_color_gradient2(low = scheme[[1]],
Expand Down Expand Up @@ -416,12 +417,12 @@ plot_nonlinear <- function(x, smooths, ...,
facet_args[["strip.position"]] <- "left"

on.exit(NULL)
ggplot(plot_data, aes_(x = ~ predictor)) +
geom_ribbon(aes_(ymin = ~ lower, ymax = ~ upper),
ggplot(plot_data, aes(x = predictor)) +
geom_ribbon(aes(ymin = lower, ymax = upper),
fill = scheme[[1]], color = scheme[[2]],
alpha = alpha, size = size) +
geom_line(aes_(y = ~ middle), color = scheme[[5]],
size = 0.75 * size, lineend = "round") +
alpha = alpha, linewidth = size) +
geom_line(aes(y = middle), color = scheme[[5]],
linewidth = 0.75 * size, lineend = "round") +
labs(y = NULL) +
do.call(facet_wrap, facet_args) +
bayesplot::theme_default()
Expand Down
6 changes: 4 additions & 2 deletions R/stanreg-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ VarCorr.stanreg <- function(x, sigma = 1, ...) {
rownames(Sigma) <- colnames(Sigma) <- cnms[[i]]
stddev <- sqrt(diag(Sigma))
corr <- cov2cor(Sigma)
structure(Sigma, stddev = stddev, correlation = corr)
structure(Sigma, stddev = stddev, correlation = corr,
class = c("vcmat_us", "matrix", "array"))
})
} else { # stanfit contains lower tri Sigma entries
spt <- split(Sigma, rep.int(ncseq, (nc * (nc + 1)) / 2))
Expand All @@ -375,7 +376,8 @@ VarCorr.stanreg <- function(x, sigma = 1, ...) {
rownames(Sigma) <- colnames(Sigma) <- cnms[[i]]
stddev <- sqrt(diag(Sigma))
corr <- cov2cor(Sigma)
structure(Sigma, stddev = stddev, correlation = corr)
structure(Sigma, stddev = stddev, correlation = corr,
class = c("vcmat_us", "matrix", "array"))
})
}
names(ans) <- nms
Expand Down
2 changes: 1 addition & 1 deletion man/reexports.Rd

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

3 changes: 2 additions & 1 deletion man/rstanarm-package.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/stan_betareg.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/stan_biglm.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/stan_clogit.Rd

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

Loading
Loading