1

I am carrying out posterior simulation with GAMs/SCAMs and was wondering if/how the rmvn() function differs in any way from the mvrnorm() function in mgcv.

I ask because if there is already a function to perform MVN simulation in the MASS package, then why was rmvn() created for mgcv? This leads me to believe either:

(1) there is a fundamental difference between these two functions; or,

(2) there is no difference, and rmvn() was created simply for convenience (i.e., not having to install/load another package).

I ask this because replacing mvrnorm() used here:

Can I use bootstrapping to estimate the uncertainty in a maximum value of a GAM?

with rmvn() results in an error that "mu dimensions are wrong" when applied to SCAM objects:

see: Posterior Simulation of a shape constrained additive model (SCAM).

This behaviour leads me to believe that there is a difference between mvrnorm() and rmvn(). Or, there may be a critical bug that Simon Wood (the creator and maintainer of mgcv) should be informed on.

Is there really a difference that should lead me to using one function over the other? My intuition says no, but I would like to be certain.

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
compbiostats
  • 1,017
  • 9
  • 18

1 Answers1

1

MASS::mvrnorm and mgcv::rmvn do the same thing, simulates from a multivariate normal distribution. So why did the mgcv author replicate functionality already in MASS? We don't know, you should rather ask @Simon Wood!

But, the two functions use different methods: MASS::mvrnorm uses the eigendecomposition of the covariance matrix, while mgcv::rmvn calls mgcv::mroot, a function which by default uses the Choleski decomposition. That might be faster, but potentially less accurate (according to the authors of MASS).

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467