Closed barrettk closed 9 months ago
As an aside: In the end we need to be able to put the matrices back together. I had messed around with this pattern:
# Get full matrix
omega_full <- bbr::get_initial_est(.mod)$omegas
# Separate the full matrix. Hard code example:
omega_1 <- omega_full[1:2, 1:2]
omega_2 <- omega_full[3:5, 3:5]
# Checks that the individual matrices are positive-definite, and corrects them if need be
omega_1 <- bbr::check_and_modify_pd(omega_1)
omega_2 <- bbr::check_and_modify_pd(omega_2)
# combine matrices back into full matrix
omega_full_pd <- as.matrix(Matrix::bdiag(list(omega_1, omega_2)))
However, I really like the handling of nmrec:::vector_to_matrix_ltri
. I know it doesnt make sense to export that function, so just wondering if you have any suggestions here, or think something on the nmrec
side (exported) might make sense for doing this (assuming not).
@barrettk Thanks for posting this issue.
The simplest method I can think of from an nmrec perspective, would be to have a helper to pull out the size attribute, and then I can determine the indices on the bbr front [...]
I agree that that's the simplest given the current implementation. In hopes that this doesn't block you, I've pushed a scratch implementation to scratch/extra-param-sizes.
I'm undecided on where we should end up eventually, but it probably makes sense to wait until we have a better idea of how metrumresearchgroup/bbr#640 settles.
Awesome thanks! Will give it a shot and let you know how it goes
Hey @kyleam While the original intention for this feature was for matrix handling (see linked issue above), I also made use of it for tabulating the record number in the new initial_estimates()
function.
The matrix handling, along with tweaking initial omegas and sigmas altogether, will be handled in a separate PR.
However, after discussing with @seth127, we agreed it would be nice to include this metadata (record_number
column) in this PR (Note that it wont be that exact PR, as Im going to start with a clean branch). This new column is potentially helpful for distinguishing non-informative priors, which is in line with some of the other adjustments we've made.
Using this method, we can access the
size
of each record:In helping to address https://github.com/metrumresearchgroup/bbr/issues/640, we need a method for separating the full omega matrix into individual matrices (see this comment). The full procedure for addressing the issue is outlined in this comment. As you can see in the setup section however, I hard coded the individual matrices; shown again below:
There are a number of ways I could get those dimensions.
nmrec
perspective, would be to have a helper to pull out thesize
attribute, and then I can determine the indices on thebbr
front. I know we dont want to exportcreate_param_index
for good reason, so a helper that extracts some of these attributes could be more ideal.nmrec
, but just putting it out there.extract_omega
/extract_sigma
.In terms of how and what information we would return from the
nmrec
side, I would 100% leave that up to you, based on what you thinknmrec
should be responsible for. In the end, I just need a method for separating the matrices using exportednmrec
functions, and the minimum information I need to do that, is how many rows/columns each record spans, along with the order they show up in in the control stream file (i.e. to determine the indices the record spans within the full compiled matrix).