Skip to content

Commit

Permalink
Merge pull request #72 from nicholasjclark/re_export_brms
Browse files Browse the repository at this point in the history
Re export brms
  • Loading branch information
nicholasjclark authored Sep 3, 2024
2 parents 98f9654 + d11a03f commit f6e879c
Show file tree
Hide file tree
Showing 33 changed files with 800 additions and 155 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Package: mvgam
Title: Multivariate (Dynamic) Generalized Additive Models
Version: 1.1.3
Date: 2024-07-02
Date: 2024-09-03
Authors@R: person("Nicholas J", "Clark", , "nicholas.j.clark1214@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7131-3301"))
Description: Fit Bayesian Dynamic Generalized Additive Models to sets of time series. Users can build dynamic nonlinear State-Space models that can incorporate semiparametric effects in observation and process components, using a wide range of observation families. Estimation is performed using Markov Chain Monte Carlo with Hamiltonian Monte Carlo in the software 'Stan'. References: Clark & Wells (2022) <doi:10.1111/2041-210X.13974>.
URL: https://github.com/nicholasjclark/mvgam, https://nicholasjclark.github.io/mvgam/
BugReports: https://github.com/nicholasjclark/mvgam/issues
License: MIT + file LICENSE
Depends:
R (>= 3.6.0),
brms (>= 2.21.0)
R (>= 3.6.0)
Imports:
brms (>= 2.21.0),
methods,
mgcv (>= 1.8-13),
insight (>= 0.19.1),
Expand Down
48 changes: 48 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ S3method(get_data,mvgam_prefit)
S3method(get_predict,mvgam)
S3method(get_vcov,mvgam)
S3method(hindcast,mvgam)
S3method(irf,mvgam)
S3method(lfo_cv,mvgam)
S3method(logLik,mvgam)
S3method(log_posterior,mvgam)
Expand All @@ -41,6 +42,7 @@ S3method(pairs,mvgam)
S3method(plot,mvgam)
S3method(plot,mvgam_conditional_effects)
S3method(plot,mvgam_forecast)
S3method(plot,mvgam_irf)
S3method(plot,mvgam_lfo)
S3method(posterior_epred,mvgam)
S3method(posterior_linpred,mvgam)
Expand Down Expand Up @@ -73,9 +75,14 @@ export(PW)
export(RW)
export(VAR)
export(add_residuals)
export(bernoulli)
export(beta_binomial)
export(betar)
export(code)
export(compare_mvgams)
export(comparisons)
export(conditional_effects)
export(datagrid)
export(drawDotmvgam)
export(dynamic)
export(ensemble)
Expand All @@ -85,14 +92,22 @@ export(eval_smoothDotmodDotsmooth)
export(eval_smoothDotmoiDotsmooth)
export(forecast)
export(get_mvgam_priors)
export(gp)
export(hindcast)
export(hypotheses)
export(irf)
export(lfo_cv)
export(lognormal)
export(loo)
export(loo_compare)
export(lv_correlations)
export(mcmc_plot)
export(mvgam)
export(nb)
export(neff_ratio)
export(nmix)
export(nuts_params)
export(plot_comparisons)
export(plot_mvgam_factors)
export(plot_mvgam_fc)
export(plot_mvgam_pterms)
Expand All @@ -102,13 +117,30 @@ export(plot_mvgam_series)
export(plot_mvgam_smooth)
export(plot_mvgam_trend)
export(plot_mvgam_uncertainty)
export(plot_predictions)
export(plot_slopes)
export(posterior_epred)
export(posterior_linpred)
export(posterior_predict)
export(pp_check)
export(ppc)
export(predictions)
export(prior)
export(prior_)
export(prior_string)
export(rhat)
export(roll_eval_mvgam)
export(s)
export(score)
export(series_to_mvgam)
export(set_prior)
export(sim_mvgam)
export(slopes)
export(stancode)
export(standata)
export(student)
export(student_t)
export(t2)
export(te)
export(ti)
export(tweedie)
Expand All @@ -122,22 +154,27 @@ importFrom(bayesplot,neff_ratio)
importFrom(bayesplot,nuts_params)
importFrom(bayesplot,pp_check)
importFrom(brms,bernoulli)
importFrom(brms,beta_binomial)
importFrom(brms,conditional_effects)
importFrom(brms,dbeta_binomial)
importFrom(brms,do_call)
importFrom(brms,dstudent_t)
importFrom(brms,get_prior)
importFrom(brms,gp)
importFrom(brms,logm1)
importFrom(brms,lognormal)
importFrom(brms,mcmc_plot)
importFrom(brms,ndraws)
importFrom(brms,pbeta_binomial)
importFrom(brms,prior)
importFrom(brms,prior_)
importFrom(brms,prior_string)
importFrom(brms,pstudent_t)
importFrom(brms,qstudent_t)
importFrom(brms,rbeta_binomial)
importFrom(brms,read_csv_as_stanfit)
importFrom(brms,rstudent_t)
importFrom(brms,set_prior)
importFrom(brms,stancode)
importFrom(brms,standata)
importFrom(brms,student)
Expand Down Expand Up @@ -171,11 +208,18 @@ importFrom(loo,is.loo)
importFrom(loo,loo)
importFrom(loo,loo_compare)
importFrom(magrittr,"%>%")
importFrom(marginaleffects,comparisons)
importFrom(marginaleffects,datagrid)
importFrom(marginaleffects,get_coef)
importFrom(marginaleffects,get_predict)
importFrom(marginaleffects,get_vcov)
importFrom(marginaleffects,hypotheses)
importFrom(marginaleffects,plot_comparisons)
importFrom(marginaleffects,plot_predictions)
importFrom(marginaleffects,plot_slopes)
importFrom(marginaleffects,predictions)
importFrom(marginaleffects,set_coef)
importFrom(marginaleffects,slopes)
importFrom(methods,cbind2)
importFrom(mgcv,Predict.matrix)
importFrom(mgcv,Rrank)
Expand All @@ -186,8 +230,12 @@ importFrom(mgcv,get.var)
importFrom(mgcv,initial.sp)
importFrom(mgcv,interpret.gam)
importFrom(mgcv,nb)
importFrom(mgcv,s)
importFrom(mgcv,smooth.construct)
importFrom(mgcv,smoothCon)
importFrom(mgcv,t2)
importFrom(mgcv,te)
importFrom(mgcv,ti)
importFrom(parallel,clusterEvalQ)
importFrom(parallel,clusterExport)
importFrom(parallel,setDefaultCluster)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Added `standata.mvgam_prefit`, `stancode.mvgam` and `stancode.mvgam_prefit` methods for better alignment with 'brms' workflows
* Added 'gratia' to *Enhancements* to allow popular methods such as `draw()` to be used for 'mvgam' models if 'gratia' is already installed
* Added an `ensemble.mvgam_forecast` method to generate evenly weighted combinations of probabilistic forecast distributions
* Added an `irf.mvgam` method to compute Generalized and Orthogonalized Impulse Response Functions (IRFs) from models fit with Vector Autoregressive dynamics

## Deprecations
* The `drift` argument has been deprecated. It is now recommended for users to include parametric fixed effects of "time" in their respective GAM formulae to capture any expected drift effects
Expand Down
3 changes: 2 additions & 1 deletion R/backends.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@
'sigma_obs_vec',
'shape_vec',
'phi_inv',
'lv_coefs_raw'),
'lv_coefs_raw',
'L_Sigma'),
algorithm = algorithm)
}

Expand Down
6 changes: 4 additions & 2 deletions R/conditional_effects.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#'
#' Display conditional effects of one or more numeric and/or categorical
#' predictors in `mvgam` models, including two-way interaction effects.
#' @importFrom brms conditional_effects
#' @importFrom ggplot2 scale_colour_discrete scale_fill_discrete theme_classic
#' @importFrom marginaleffects plot_predictions
#' @importFrom graphics plot
#' @importFrom grDevices devAskNewPage
#' @inheritParams brms::conditional_effects.brmsfit
Expand Down Expand Up @@ -219,6 +217,10 @@ conditional_effects.mvgam = function(x,
return(out)
}

#' @export
#' @importFrom brms conditional_effects
brms::conditional_effects

#' @rdname conditional_effects.mvgam
#' @export
plot.mvgam_conditional_effects = function(x,
Expand Down
26 changes: 25 additions & 1 deletion R/families.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @importFrom stats make.link dgamma pgamma rgamma qnorm plnorm runif pbeta dlnorm dpois
#' @importFrom stats pnorm ppois plogis gaussian poisson Gamma dnbinom rnbinom dnorm dbeta
#' @importFrom stats binomial rbinom pbinom dbinom qbinom qlogis
#' @importFrom brms lognormal student bernoulli rstudent_t qstudent_t dstudent_t pstudent_t dbeta_binomial rbeta_binomial pbeta_binomial
#' @importFrom brms lognormal student beta_binomial bernoulli rstudent_t qstudent_t dstudent_t pstudent_t dbeta_binomial rbeta_binomial pbeta_binomial
#' @importFrom mgcv betar nb
#' @param link a specification for the family link function. At present these cannot
#' be changed
Expand Down Expand Up @@ -80,6 +80,30 @@ nb = function(...){
mgcv::nb(...)
}

#' @rdname mvgam_families
#' @export
lognormal = function(...){
brms::lognormal(...)
}

#' @rdname mvgam_families
#' @export
student = function(...){
brms::student(...)
}

#' @rdname mvgam_families
#' @export
bernoulli = function(...){
brms::bernoulli(...)
}

#' @rdname mvgam_families
#' @export
beta_binomial = function(...){
brms::beta_binomial(...)
}

#' @rdname mvgam_families
#' @examples
#' \donttest{
Expand Down
16 changes: 16 additions & 0 deletions R/get_mvgam_priors.R
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,22 @@ get_mvgam_priors = function(formula,
return(out)
}

#' @export
#' @importFrom brms prior
brms::prior

#' @export
#' @importFrom brms prior_
brms::prior_

#' @export
#' @importFrom brms set_prior
brms::set_prior

#' @export
#' @importFrom brms prior_string
brms::prior_string

#' Use informative scale and intercept priors following brms example
#' @importFrom stats mad qcauchy setNames
#' @importFrom brms logm1 prior_string get_prior
Expand Down
Loading

0 comments on commit f6e879c

Please sign in to comment.