sample_pois_reg()
in some circumstances.Removed times_flat_ar1()
, which wasn’t well-documented and no longer all that useful to me.
Added bss()
and friends.
conj_gamma_b()
.b=
to dmvnorm_diff()
for the canonical representation.Enforce spam >= 2.9-2
because of a critical bug fix related to the element-wise multiplication of a full spam
object. This led to incorrect densities. Note: if you can’t find a compatible version on CRAN, try the source GitLab, which has tarballs of the packages.
Added the diag=
argument to conj_matnorm_mu()
and conj_matlm_beta()
output when params.only=TRUE
.
diag=TRUE
now works for gs_matlm_beta()
. It’s slightly slower when the dimensions are small, but MUCH faster when the dimensions get large.
conj_matlm_beta()
and conj_matnorm_mu()
when diag=TRUE
and a dimension is 1.base::diag()
to spam::diag()
(I missed these last time).Changed a few more base::diag()
to spam::diag()
in the case diag=TRUE
and Q0
or precision
is a spam
object.
Changed some internals for sample_multinom_reg()
when diag=TRUE
. In particular, precision
can now be a spam
matrix.
base::diag()
to spam::diag()
in conj_matlm_mu()
and conj_matlm_beta()
, in the case diag=TRUE
and Q0
is a spam
object.conj_gamma_b()
.Fixed a misspecified glue
.
Changed all the relevant C++ code to include a const
declaration, so I don’t regret it later.
Removed MASS
as a dependency.
Added the special case mu=NULL
to dmatnorm()
, dmvnorm()
, and dmvlnorm()
.
Fixed an issue in the multinomial approximations when the number of rows is 1.
Removed some spurious code.
Added rtruncexp()
, qtruncexp()
, ptruncexp()
, and dtruncexp()
for truncated exponential distributions.
Added “mv truncated exponential” to sample_pois_reg()
, sample_binom_reg()
, and sample_multinom_reg()
, to approximate the log-density with a first-order Taylor approximation (which is an exponential distribution).
Fixed a bug in the “mv beta” method of sample_binom_reg()
, where a +
sign was accidentally present in place of a -
.
Fixed the pkgdown changelog by adding “gibbs.utils” to all the headers so it parses correctly.
Added method to sample_multinom_reg()
for “mv ind quadratic taylor”.
The width=
argument is now squared when applied to the variance for various methods, so that it is consistency on the sd scale.
Sped up sample_pois_reg()
and sample_binom_reg()
by something like half, and sample_multinom_reg()
by maybe 1 percent by improving matrix subscripting in the C++ code.
Improved the numeric stability of the gamma approximations in sample_pois_reg()
and the beta approximations in sample_binom_reg()
.
Fixed a bug in the (still experimental) “mv beta” method of sample_binom_reg()
.
Added methods to sample_multinom_reg()
for “normal”, “uniform”, and “quadratic taylor”.
sample_multinom_reg()
by 7x by reworking some C++ internals.rdirich()
to generate random Dirichlet vectors.Added the times_flat_ar1()
function, whose details will undoubtedly come in another release.
Documented the diag=
argument from v4.3.0.
diag=
argument to sample_multinom_reg()
, for when the precision matrix is diagonal, yielding a speedup (because it can skip calculating the conditional mean).conj_matlm_beta()
(by about 4x) and conj_matnorm_mu()
(very slightly) by only matrix multiplying once when diag=TRUE
.mu=NULL
in conj_matnorm_V()
and conj_mvnorm_Q()
.zmax=
argument to sample_multinom_reg()
, for advanced usage.sample_multinom_reg()
. Where possible, backwards compatibility was maintained, but results will differ because of random seeds and whatnot.truncate=
argument to sample_pois_reg()
, to truncate the Poisson likelihood.Added dmvlnorm()
, dmvlnorm_diff()
, dnorm_diff()
, dlnorm_diff()
.
Added an argument byrow=
to dmvnorm_diff()
.
Critical bug fix for “[mv ]gamma” in sample_pois_reg()
and “mv beta” in sample_binom_reg()
.
Added “mv beta” to sample_binom_reg()
.
Added “mv ind quadratic taylor” to sample_binom_reg()
and sample_pois_reg()
.
Changed the accept_regardless=
argument to acceptance=
, where one option (“LL only”) is to accept ignoring the proposal density.
Fixed a bug where “gamma” didn’t actually run the gamma proposal.
Fixed the “gamma” metropolis step in cases when mult != 1
.
Added a “mv gamma” option.
Added accept_regardless=
argument to sample_pois_reg()
and sample_binom_reg()
Saved some time by using C++ pass-by-reference.
Added “gamma” proposal to sample_pois_reg()
.
ss_pois_reg()
and mh_pois_reg()
now have a unified interface: sample_pois_reg()
, with slightly different naming conventions for extra arguments.
ss_binom_reg()
and mh_binom_reg()
now have a unified interface: sample_binom_reg()
, with slightly different naming conventions for extra arguments.
ss_multinom_reg()
was renamed to sample_multinom_reg()
for consistency, with slightly different naming conventions for extra arguments, and the additional argument method=
for future development.
ss_multinom_reg()
now allows a 3-dimensional z=
argument, for a small speed penalty.dmatnorm_diff()
, akin to dmvnorm_diff()
.dmvnorm_diff()
for taking the difference of two (log-) densities, useful in, e.g. Metropolis-Hastings sampling, but faster than taking individual densities twice.Removed conj_matlm_V()
, which is nearly an exact duplicate of conj_matnorm_V()
.
Added some shortcut arguments for t(X) %*% U
, t(X) %*% U %*% X
, and t(ymu) %*% U %*% ymu
to conj_matlm_beta()
and conj_matnorm_V()
.
as.numeric()
with as.vector()
, for compatibility with spam
.gs_diagmatlm_beta()
with gs_matlm_beta()
, which now passes arguments to conj_matlm_beta()
through the dots. This includes the new zero=
argument, which can be used to recover the performance of gs_diagmatlm_beta()
.Added the zero=
argument to conj_matnorm_mu()
and conj_matlm_beta()
to indicate structural zeros. As such, we removed conj_diagmatlm_beta()
, which was slightly faster with small inputs, and about the same speed with larger ones. (Author’s note: implementing a special condition for when zero
is a diagonal matrix does remedy the small inputs speed difference, but I decided it wasn’t worth maintaining more code for something that’s already very fast).
Added the derivation of the above conjugate case to the vignette.
conj_diagmatlm_beta()
(and hence gs_diagmatlm_beta()
) by taking the linear algebra a few steps further.Added is.gu_chol()
, and now allow for passing of newQ.chol=
to be taken into account when sampling with spam::rmvnorm.canonical()
(by appending the gu_chol
class, which doesn’t take the Cholesky another time). Notably, this doesn’t work for spam
objects, because they are S4.
chol.gu_chol()
gained a verbose=
argument (mostly for debugging).
gu_chol()
gained a take.chol=
argument, to mark existing Cholesky matrices as such without taking chol()
again.
Fixed a bug when params.only=TRUE
and the input newQ.chol=
is just a regular matrix.
Overhauled the conjugate normal functions, to use spam::rmvnorm.canonical()
instead of taking two inverses. This method is slower than what we had before when inputs are really small (when the conjugacy is super fast anyway, so I wasn’t worried) but almost 2x faster when inputs are big. Furthermore, we can get more performance when inputs are spam
objects already.
spam
was added as a dependency.
Replaced crossprod(x, y)
with t(x) %*% y
in almost all instances, to be compatible with, e.g., the spam
package for sparse matrices.
Fixed a typo in the vignette
dmvnorm()
and dmatnorm()
.dmatnorm()
, for speed gains of over 1000x for large inputs. The default for U=
is also now NULL
, indicating the identity matrix.use_trace=
argument introduced in v0.9.3. When x
was short, the trace was faster. When x=
was long, the non-trace method was faster. Now, using a vectorization trick with the trace, dmvnorm()
is always at least as fast (and usually faster) than either of the previous methods.Also return V.inv
for conjugate Wishart parameters, tau
for conjugate normal, and Q
for some other normal conjugate cases where newQ.inv=
has not already been supplied.
Changed the defaults (but not the default behavior) for some normal conjugates.
use_trace=
argument introduced in v0.9.3, because in my experience it’s faster not to use the matrix trace.mu0 = NULL
to indicate zero. This also allows you to give infinite precisions when mu0 = NULL = 0
(which would otherwise give Inf * 0 = NaN
).mvqt_binom_approx()
and mvqt_pois_approx()
.Added mh_pois_reg()
.
Added proposal="mv quadratic taylor"
to mh_binom_reg()
to do multivariate Taylor’s approximations and MH steps.
dmvnorm()
to opt out of the matrix trace.dmvnorm()
by using the matrix trace instead of a for-loop.Changed the n == k == 0
sampling to C++ for ss_binom_reg()
and mh_binom_reg()
ss_pois_reg()
now accepts NA
in k=
, to indicate that no Poisson draw was observed.
conj_matlm_sigma()
to conj_matlm_V()
. It, along with conj_matnorm_V()
, now both use conj_mvnorm_Q()
in the case that U = NULL
(independence among rows).Added truncnorm
as a package dependency.
Added gs_diagmatlm_beta()
to Gibbs-sample truncated normal diagonal matrix-normal regression means.
cond_mvnorm()
gained optional truncation parameters
Updated the vignettes to improve the custom LaTeX code that wasn’t previously handled by HTML output.
Improved printing of "gibbs_utils_params"
objects.
conj_matnorm_mu()
and conj_matlm_beta()
gained the diag=
argument, for 100x speed boost when both V=
and Q0=
are diagonal.
When params.only=TRUE
, the mu
vector returned now drops any dimensions in conj_matnorm_mu()
, conj_matlm_beta()
, conj_mvnorm_mu()
, conj_diagmatlm_beta()
, and conj_lm_beta()
When n==1
, chol_mvrnorm()
now drops dimensions, to match what MASS::mvrnorm()
does.
Improved printing of "gibbs_utils_params"
objects.
ss_multinom_reg()
now also uses normal draws in the case where z == 0
or n == 0
. This is not done multivariately, but rather univariately.
ss_multinom_reg()
now accepts numeric values for the ref=
argument, to allow inner “columns” to be the reference.
Sped up the multivariate binomial, multinomial, and Poisson likelihood evaluations (only completing the square once instead of each time), so that
ss_pois_reg()
is as much as 6.5x faster
ss_multinom_reg()
is as much as 1.6x faster
ss_binom_reg()
is as much as 4.5x faster
mh_binom_reg()
is as much as 2x faster.
As such, there are no longer C++ functions to evaluate the multivariate log-likelihoods (nor the slice sample functions to do the same); instead, the conditional means are computed within cond_mv_mean()
, and the results passed to the univariate likelihoods.
Overhauled mh_binom_reg()
. It now takes a proposal=
argument, to determine how proposals are made. The “normal” method is the default for backwards-compatibility, but the “quadratic taylor” gives better results and is about the same speed. The C++ internals have also been almost completely rewritten.
Updated mh_binom_reg()
and ss_binom_reg()
to take normal draws in the multivariate case when only one n=
is zero instead of only doing it when all the n=
’s are zero.
mh_binom_reg()
now enforces k <= n
Fixed one critical bug in mh_binom_reg()
in which the log-likelihood evaluations were using k=
instead of n=
.
ss_binom_reg()
now performs conjugate normal updates when n == 0
(or rowSums(n) == 0
in the multivariate case).
ss_binom_reg()
now enforces k <= n
Fixed a bug in chol_mvrnorm()
.
Added conj_binom_p()
for the beta conjugacy for a binomial probability.
Fixed a bug in ss_multinom_reg()
when dimensions were length 1.
params.only = TRUE
.Sped up multinomial log-likelihood by avoiding exponentiation altogether for structural zeros.
Changed the acceptable dimensions of mean=
and precision=
in ss_multinom_reg()
Sped up sampling (by maybe 15%?) by avoiding repeated subsetting of k and n.
Added ss_multinom_reg()
.
Added a pkgdown site (and README.md).
Added the params.only=
argument to conjugacy functions.
Added impute_conj_mvnorm()
.
chol_mvrnorm()
to draw multivariate normal samples instead of MASS::mvrnorm()
(which uses eigen decomposition instead of Cholesky).Defer to stats::rWishart()
instead of rwish()
, since the former is faster.
Added mh_binom_reg()
(and proceeded to fix one critical bug in 61de4f70).
Sped up multivariate log-likelihood.
Fixed one test.
Updated ss_pois_reg()
and ss_binom_reg()
to allow for matrix (multivariate) inputs.
Added tests.
Fixed a bug in defaults for conj_mvnorm_mu()
, where the length was accidentally the number of observations instead of variables.
Improved documentation.
Improved checking for matrix arguments.
Rename my_inv()
to chol_inv()
.