-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
U and V #1
Comments
I am glad that you find the package useful in your work. Yours is an example of the reason why I started the package. If you haven't already, the README file I think describes what you are trying to do: https://cran.r-project.org/web/packages/matrixNormal/vignettes/introduction-to-matrixnormal-package.html Thank you for letting me know about the possible issue and for your investigation. I apologize for the delay, but I had a lot going on. Certainly,
So, in rmatrixnormal, the row covariance matrix V is m x m and column covariance matrix U is p x p, so M is a m x p matrix. They define the Kronecker as column, row. However, I can't seem to find a citation on their definitions for their U and V. In matrixNormal, the row covariance matrix U is n x n and column covariance matrix V is p x p, so M is a n x p matrix. I double-checked the reference listed on the help file, and indeed,
|
Upon investigating, the matrixsampling package uses an "eigen" decomposition. So for a fair comparison to matixsampling, you need to change the method to
Created on 2021-11-03 by the reprex package (v2.0.1) |
BTW, thanks to your comments @prockenschaub , the help file for the argument methods in
As you can see in the function, "eigen" is not the default method and needs to be changed to "chol". |
Thank you for taking the time to look into this! It's been a little since I worked with this, so hopefully I won't misremember :) Having read through your explanations, I understand that Before writing my earlier comment in August, I read your reference of Iranmanesh et al. (2010) and I agree with your conclusion that their definition suggests However, Wikipedia — citing work by Gupta and Nagar (1999) — suggest the opposite In light of the simulation results in my earlier post and the rather obscure journal in which Iranmanesh et al. (2010) was published, I tend to assume that the definiton in Iranmanesh et al. is incorrect and think instead This also makes sense when thinking about the resulting covariance matrix. Using |
Thank you, @prockenschaub. Your recent note clarifies many items for me. Thank you for bring the literature to my attention; I was unaware of Pocuca et al. (2019). Using an example from @stla, I think I see what you mean.
Created on 2021-11-03 by the reprex package (v2.0.1) The first makes no sense, while the second makes sense....especially since |
# matrixNormal 0.1.0 2021-Dec-29 - `pmatnorm`: Included argument `keepAttr` to pass to `mvtnorm::pmvtnorm()` v.1.1-2: logical allowing users to attach error and message to the return value. See . - `rmatnorm`: - Added argument `checkSymmetry = FALSE` to `mvtnorm::rmvnorm()` as the matrices are already checked for symmetry. See . - U and V are incorrectly switched, (thanks, @prockenschaub, <#1>) - Added warning to earlier versions of R - Changed reference cited. - Made argument method clearer - Documentation clarification, thanks \#1 # matrixNormal 0.0.5 2021-Apr-1 ## Bug Fixes - Minor Change: Changed lazy data to FALSE in description file to remove notes on CRAN check in R 4.0.5. # matrixNormal 0.0.4 2020-08-26 - New `vech()` function: performs half-vectorization on a symmetric matrix. This is the vector-form of the lower triangular matrix only. Unlike other functions on CRAN, vech() inherits any names from the matrix. ## Bug Fixes - `dmatrixnorm`: Clarified by replacing the name of argument `use.log` with `log` for consistency in argument name with mvtnorm and stats package. - `is.symmetric()`, `is.positive.definite()`, `is.positive.semi.definite()`: - if A is not symmetric, these functions NOW return FALSE instead of stopping the function. Restructured helper `find.eval()`. - if A contains a missing value (`NA`), these functions NOW return NA. - `rmatrixnorm`: Added the first argument `s` to draw many random samples. Only 1 sample is still drawn; the argument currently has no effect but acts as a placeholder in future releases. - Clarified documentation. - Added session information and version details to the vignette. The updated versions of the packages listed do not affect the results of matrixNormal functions.
Updated in version 0.1.0 (#1) |
First off, thank you very much for your package and the accompanying vignette. It helped me a lot in geting to grips with the matrix normal distribution!
I have been using your package to draw samples from the posterior of a multivariate linear regression, which follows an inverse-Wishart times a Matrix normal distribution (see for example wikipedia). While doing so, I stumbled across an inconsistency in the variance of those draws, and I think it is because
U
andV
in the below code should be switched.matrixNormal/R/matrixNormal_Distribution.R
Line 168 in 64132e0
Example
Sorry for the slightly verbose example, but here is some code that implements what I meant to do. It compares the results obtained via
matrixNormal
(that differ from I expected) to those that I get using thematrixsampling
package (which are in line with expectations).Created on 2021-08-24 by the reprex package (v2.0.0)
Edit: Updated example to include a random seed.
The text was updated successfully, but these errors were encountered: