-
-
Notifications
You must be signed in to change notification settings - Fork 126
Sum to zero matrix #879
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
Sum to zero matrix #879
Conversation
|
@WardBrian you need anything else from me here? I'll have a bit of time tomorrow if so. |
|
It looks pretty good to me overall, I'll see if @bob-carpenter can do a read since he tends to be a stricter editor |
bob-carpenter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can only say that @WardBrian warned you.
This is a lot of very detailed comments on grammar, typography and layout. Hope it all makes sense---if not, I'm happy to elaborate on particular requests. Don't feel you need to answer all these and make them "resolved" in the UI---I'm happy to review again.
src/bibtex/all.bib
Outdated
| number = {1}, | ||
| pages = {4--12}, | ||
| publisher = {Mathematical Association of America}, | ||
| title = {The Helmert Matrices}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be {The {H}elmert Matrices} in order to keep the H capitalized through BibTeX.
| {{< since 2.37 >}} | ||
|
|
||
| ### Zero-sum matrices | ||
| These functions perform the transform and inverse transform described in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd try to make it clear that this is a separate doc, not a separate section of the same doc. And we want to say what things do, not just point to another document.
So how about:
The zero-sum matrix transforms map between unconstrained values and matrices whose rows and columns sum to zero; full definitions of the function and Jacobian can be found in the sum-to-zero matrix section of the Reference Manual.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git blame @WardBrian for this! Haha, I originally had it as a separate section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait this is in the functions reference, my bad Brian
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I moved it so that it was sorted with the other matrices, rather than in the middle of vectors, but I didn’t audit the text while doing so
| \index{{\tt \bfseries sum\_to\_zero\_constrain }!{\tt (matrices y): matrices}|hyperpage} | ||
|
|
||
| `matrices` **`sum_to_zero_constrain`**`(matrices y)`<br>\newline | ||
| Takes a free matrix `y` and returns a matrix such that the rows and columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a complete sentence---it's missing a subject as is. It can also be reduced to a single line.
The constraining function maps an unconstrained
N x Mmatrix to an(N + 1) x (M + 1)matrix for which the rows and columns all sum to zero.
| free matrix of size $N \times M$. | ||
| {{< since 2.37 >}} | ||
|
|
||
| ### Zero-sum matrices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to say "Sum-to-zero matrices". I got confused when writing programs as to whether to use sum_to_zero_matrix or zero_sum_matrix because we'd wavered on what to call it during design.
| {{< since 2.37 >}} | ||
|
|
||
| ### Zero-sum matrices | ||
| These functions perform the transform and inverse transform described in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference manual chapter should be renamed to also say "Sum-to-zero", though I have a feeling that will be a huge pain given how we link.
src/reference-manual/types.qmd
Outdated
|
|
||
| ### Matrices that sum to zero {-} | ||
|
|
||
| A zero-sum matrix is constrained such that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the lines 80 characters or thereabouts and equal length. Otherwise, it's a huge pain to either read or see diffs.
src/reference-manual/types.qmd
Outdated
| A zero-sum matrix is constrained such that the | ||
| sum of rows and the sum of the columns is always $0$. These are sometimes useful | ||
| for resolving identifiability issues in regression models. | ||
| While the underlying vector has only $N - 1 \times M - 1$ degrees of freedom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(N - 1) \times (M - 1)$ because
src/reference-manual/types.qmd
Outdated
| for resolving identifiability issues in regression models. | ||
| While the underlying vector has only $N - 1 \times M - 1$ degrees of freedom, | ||
| zero sum matrices are declared with their full dimensionality. | ||
| For instance, `beta` is declared to be a zero-sum $5 \times 4$-matrix (20 DoF) by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"sum-to-zero"
If it's 5 \times 4, isn't that 12 dof? Also, "dof" is usually written all lowercase like "pdf", but I'd just expand to "degrees of freedom" (no hyphens)
src/reference-manual/types.qmd
Outdated
| sum_to_zero_matrix[5, 4] beta; | ||
| ``` | ||
|
|
||
| Zero sum matrices are implemented as matrices and may be assigned to other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sum-to-zero" with hyphens
src/reference-manual/types.qmd
Outdated
| Zero sum matrices are implemented as matrices and may be assigned to other | ||
| matrices and vice-versa. Zero sum matrix variables, like other constrained | ||
| variables, are validated to ensure that they are indeed zero sum; for | ||
| zero sum matrices, this is only done up to a statically specified accuracy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say "internally" rather than "statically" to indicate it's not under user control. I don't think most of our users will even understand the static/dynamic distinction in C++.
Bonus points if you can say what this threshold is.
|
Also, this may not look so bad, but be sure to click the "hidden conversations" box to unfold the rest of my comments---there are 30+. If you don't have time or would prefer, I'm happy to make all these changes myself and let @WardBrian do the final review. |
|
No worries, I want this to be understood by the reader and having consistency and this type of review is good for that. I'll make a stab at the edits. On the 80 line length I configured vscode to automatically have 80 line length. Or I thought I did as it was 80 on my screen but maybe it was only in my console and didn't transfer over to the file itself? |
|
You can see the long lines in the file in the branch. |
|
I believe vscode only "soft" wraps lines when requested, not actually inserting newlines into the file on disc. There are extensions that provide hard wrapping, the most popular seems to be Rewrap |
|
@bob-carpenter this is ready for you to review again |
bob-carpenter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Thanks so much for updating.
src/reference-manual/types.qmd
Outdated
| matrices (lower triangular, positive diagonal, unit-length rows). The type | ||
| `sum_to_zero_matrix` is for matrices that sum to zero across rows and columns. | ||
|
|
||
| Constraints provide error checking for variables defined in the `data`, `transformed data`, `transformed parameters`, and `generated quantities` blocks. Constraints are critical for variables declared in the `parameters` block, where they determine the transformation from constrained variables (those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line length is still a problem but I don't want to hold something up for this.
| vectors and vice-versa. Zero sum vector variables, like other constrained | ||
| variables, are validated to ensure that they are indeed unit length; for | ||
| zero sum vectors, this is only done up to a statically specified accuracy | ||
| variables, are validated to ensure that they are indeed sum to zero; for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
|
@WardBrian mind taking one last look before we merge? I updated the function name by removing |
|
Thanks @spinkney ! |
When I built it I didn't see any of the changes so not sure what's going on there. I didn't add the versions either. @WardBrian I can work with you on Tuesday to get this fixed.
Submission Checklist
<<{ since VERSION }>>Summary
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
Sean Pinkney
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: