Closed friendly closed 2 weeks ago
Hi,
On 2024-08-09 2:54 p.m., Michael Friendly wrote:
Caution: External email.
Before the flurry of generalizing w/ Eqn() et al, there was an arg | start = c(row=1, col=1) that could be be used to start the indexing of rows/cols at 0 in |symbolicMatrix()`. Just found myself in need of this, and realized it disappeared in the dust. How much work would it take to put it back?
I don't recall this. Can you find it in the GitHub history?
John
— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/53>, or unsubscribe <https://github.com/ notifications/unsubscribe-auth/ ADLSAQRC3C5TPVU3GBCZ2GLZQUF7BAVCNFSM6AAAAABMI7COK6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TQNBZGQ3TENQ>. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Ugh! I tried git blame R/symbolicMatrix.R
and the blame button on GitHub, but can't find this. The history goes back to Aug 2.
I had an older copy in dev/
, but deleted it when I cleaned up.
Hi,
Unless I'm completely losing it, I never explicitly enabled 0-based indexing in symbolicMatrix(). Maybe it worked anyway, but I don't see how.
OTOH, I don't think that it would be hard to implement in the latest approach I'm taking to the function. Would you like me to try? If so, I think that I'd prefer to have a logical argument, say zero.based, which defaults to FALSE and applies to both rows and columns. Any reason not to use that rather than a 2-element numeric start argument?
Also, I can't say that I've ever enjoyed working with programming languages that use 0-based indexing and wonder why it would be useful for something like symbolicMatrix().
Best, John
On 2024-08-09 3:41 p.m., Michael Friendly wrote:
Caution: External email.
Ugh! I tried |git blame R/symbolicMatrix.R| and the blame button on GitHub, but can't find this. The history goes back to Aug 2. I had an older copy in |dev/|, but deleted it when I cleaned up.
— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/53#issuecomment-2278627614>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQSCJTMCDBQOKRZPEYTZQULQBAVCNFSM6AAAAABMI7COK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYGYZDONRRGQ>. You are receiving this because you commented.Message ID: <friendly/ @.***>
Hi again,
Since you didn't object, I added a zero.based arg to symbolicMatrix() in dev/symbolicMatrix.R. It seems to work fine; for example,
symbolicMatrix(zero.based=TRUE) symbolicMatrix(nrow=3, ncol=4, zero.based=TRUE) symbolicMatrix(ncol=4, zero.based=TRUE) symbolicMatrix(nrow=3, zero.based=TRUE) symbolicMatrix(nrow="n", ncol="n", diag=TRUE, zero.based=TRUE) symbolicMatrix(nrow=3, ncol=3, diag=TRUE, zero.based=TRUE)
Everything else should work as before but of course more checking is eventually in order.
Best, John
On 2024-08-09 3:41 p.m., Michael Friendly wrote:
Caution: External email.
Ugh! I tried |git blame R/symbolicMatrix.R| and the blame button on GitHub, but can't find this. The history goes back to Aug 2. I had an older copy in |dev/|, but deleted it when I cleaned up.
— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/53#issuecomment-2278627614>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQSCJTMCDBQOKRZPEYTZQULQBAVCNFSM6AAAAABMI7COK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYGYZDONRRGQ>. You are receiving this because you commented.Message ID: <friendly/ @.***>
sorry for not responding earlier... I'm entering packing mode for our holiday, starting Monday.
It must have been @philchalmers who implemented the possibility of zero-based indexing, The use case for separate row/col bases is the $\mathbf{B}_{(q+1) \times p}$ matrix in a multivariate regression problem, where the first row $\mathbf{b}_0^\top$ is for the intercept but the columns for the responses are numbered 1, ... ,p.
$$ \sizedmat{B}{(q+1) \times p} = \begin{pmatrix} b{0}^\top \ b{1}^\top \ \vdots \ b{i}^\top \ \vdots \ b{q}^\top \ \end{pmatrix} $$
Not I, but the commit to add start
was here: https://github.com/friendly/matlib/commit/8c19247da3d5e496895f2232952f525201136f68
If you need access to this file create a branch at this exact commit and copy the file out:
git checkout 8c19247da3d5e496895f2232952f525201136f68
cp R/symb-matrix.R some/u/want/symb-matrix.R
git checkout master
Hi,
OK, it wasn't hard to make zero.based a two-element logical vector for rows and columns, so now
symbolicMatrix(zero.based=c(TRUE, TRUE)) symbolicMatrix(nrow=3, ncol=4, zero.based=c(TRUE, TRUE)) symbolicMatrix(ncol=4, zero.based=c(TRUE, TRUE)) symbolicMatrix(nrow=3, zero.based=c(TRUE, TRUE)) symbolicMatrix(nrow="n", ncol="n", diag=TRUE, zero.based=c(TRUE, TRUE)) symbolicMatrix(nrow=3, ncol=3, diag=TRUE, zero.based=c(TRUE, TRUE))
symbolicMatrix(zero.based=c(TRUE, FALSE)) symbolicMatrix(zero.based=c(FALSE, TRUE))
symbolicMatrix("\mathbf{B}", nrow="q", ncol="p",
- zero.based=c(TRUE, FALSE)) \begin{pmatrix} \mathbf{B}{0,1} & \mathbf{B}{0,2} & \cdots & \mathbf{B}{0,p} \ \mathbf{B}{1,1} & \mathbf{B}{1,2} & \cdots & \mathbf{B}{1,p} \ \vdots & \vdots & & \vdots \ \mathbf{B}{q - 1,1} & \mathbf{B}{q - 1,2} & \cdots & \mathbf{B}_{q
- 1,p} \ \end{pmatrix}
You'll notice that the last doesn't really produce what you want. Expecting to get 0, 1, ..., q if nrow="q" isn't really 0-based indexing in my understanding of the term, because there would then be q + 1 rows.
The following also isn't satisfactory, because the function doesn't do arithmetic if nrow is character:
symbolicMatrix("\mathbf{B}", nrow="q + 1", ncol="p",
- zero.based=c(TRUE, FALSE)) \begin{pmatrix} \mathbf{B}{0,1} & \mathbf{B}{0,2} & \cdots & \mathbf{B}{0,p} \ \mathbf{B}{1,1} & \mathbf{B}{1,2} & \cdots & \mathbf{B}{1,p} \ \vdots & \vdots & & \vdots \ \mathbf{B}{q + 1 - 1,1} & \mathbf{B}{q + 1 - 1,2} & \cdots & \mathbf{B}_{q + 1 - 1,p} \ \end{pmatrix}
Best, John
On 2024-08-09 5:20 p.m., Michael Friendly wrote:
Caution: External email.
sorry for not responding earlier... I'm entering packing mode for our holiday, starting Monday.
It must have been @philchalmers https://github.com/philchalmers who implemented the possibility of zero-based indexing, The use case for separate row/col bases is the $\mathbf{B}_{(q+1) \times p}$ matrix in a multivariate regression problem, where the first row $\mathbf{b}_0^\top$ is for the intercept but the columns for the responses are numbered 1, ... ,p.
$$ \sizedmat{B}{(q+1) \times p} = \begin{pmatrix} b{0}^\top \ b{1} ^\top \ \vdots \ b{i}^\top \ \vdots \ b{q}^\top \ \end{pmatrix} $$
— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/53#issuecomment-2278770762>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQX5MOQ2A77H7PCZXULZQUXABAVCNFSM6AAAAABMI7COK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYG43TANZWGI>. You are receiving this because you commented.Message ID: <friendly/ @.***>
Hi,
This looks like a completely different function, which Michael wrote.
Best, John
On 2024-08-09 5:49 p.m., Phil Chalmers wrote:
Caution: External email.
Not I, but the commit to add |start| was here: 8c19247 <https:// github.com/friendly/matlib/commit/8c19247da3d5e496895f2232952f525201136f68>
If you need access to this file create a branch at this exact commit and copy the file out:
|git checkout 8c19247da3d5e496895f2232952f525201136f68 cp R/symb- matrix.R some/u/want/symb-matrix.R git checkout master |
— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/53#issuecomment-2278797288>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQTOWD6Q6BJ6P5KT4YTZQU2O5AVCNFSM6AAAAABMI7COK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYG44TOMRYHA>. You are receiving this because you commented.Message ID: <friendly/ @.***>
Indeed, it was before the port to the new symbolicMatrix occurred. That's why there was no history of it via git blame.
Hi Michael,
After some messing around, and at the expense of proliferating arguments, I think that I have a solution that can produce what you want:
symbolicMatrix("\mathbf{B}", nrow="q", ncol="p",
- zero.based=c(TRUE, FALSE),
- end.at.n.minus.1=c(FALSE, TRUE)) \begin{pmatrix} \mathbf{B}{0,1} & \mathbf{B}{0,2} & \cdots & \mathbf{B}{0,p} \ \mathbf{B}{1,1} & \mathbf{B}{1,2} & \cdots & \mathbf{B}{1,p} \ \vdots & \vdots & & \vdots \ \mathbf{B}{q,1} & \mathbf{B}{q,2} & \cdots & \mathbf{B}_{q,p} \ \end{pmatrix}
The argument zero.based has entries for rows and columns, and whether 0-based indices run to nrow/ncol or nrow-1/ncol-1 is controlled by the argument end.at.n.minus.1.
Let me know what you think, John
On 2024-08-09 5:20 p.m., Michael Friendly wrote:
Caution: External email.
sorry for not responding earlier... I'm entering packing mode for our holiday, starting Monday.
It must have been @philchalmers https://github.com/philchalmers who implemented the possibility of zero-based indexing, The use case for separate row/col bases is the $\mathbf{B}_{(q+1) \times p}$ matrix in a multivariate regression problem, where the first row $\mathbf{b}_0^\top$ is for the intercept but the columns for the responses are numbered 1, ... ,p.
$$ \sizedmat{B}{(q+1) \times p} = \begin{pmatrix} b{0}^\top \ b{1} ^\top \ \vdots \ b{i}^\top \ \vdots \ b{q}^\top \ \end{pmatrix} $$
— Reply to this email directly, view it on GitHub <https://github.com/ friendly/matlib/issues/53#issuecomment-2278770762>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ ADLSAQX5MOQ2A77H7PCZXULZQUXABAVCNFSM6AAAAABMI7COK6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZYG43TANZWGI>. You are receiving this because you commented.Message ID: <friendly/ @.***>
@friendly has this been resolved?
Yes, we now have zero.based
and end.at
args. I'll close this now,
Before the flurry of generalizing w/ Eqn() et al, there was an arg
start = c(row=1, col=1) that could be be used to start the indexing of rows/cols at 0 in
symbolicMatrix()`. Just found myself in need of this, and realized it disappeared in the dust. How much work would it take to put it back?