Skip to content
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

"subscript out of bounds" during SAEM model setup #561

Open
billdenney opened this issue Sep 28, 2021 · 3 comments
Open

"subscript out of bounds" during SAEM model setup #561

billdenney opened this issue Sep 28, 2021 · 3 comments

Comments

@billdenney
Copy link
Contributor

I'm working to generate a reprex for this, but as usual the data and model are proprietary

I have a moderate-complexity model that gets a "subscript out of bounds" error in nlmixrUI.saem.model.omega() due to the fact that etd goes up to 18 but dm is only 17. So, the matrix dimension is not big enough for the etas (if I'm reading the code correctly).

nlmixr/R/ui.R

Lines 3153 to 3162 in 9fc906a

nlmixrUI.saem.model.omega <- function(obj) {
dm <- sum(!is.na(.saemThetaTrans(obj)))
et <- obj$saem.eta.trans
mat <- matrix(rep(0, dm * dm), dm)
etd <- which(!is.na(obj$neta1))
for (i in etd) {
mat[et[obj$neta1[i]], et[obj$neta2[i]]] <- mat[et[obj$neta2[i]], et[obj$neta1[i]]] <- 1
}
return(mat)
}

One challenge with making a reprex is that when I use the same model but much simpler data, obj$env$.bpars in nlmixrUI.saem.model.omega() is NULL instead of having a function body.

This is with nlmixr 2.0.5, RxODE 1.1.1, lotri 0.3.1, and R 4.1.0.

@billdenney
Copy link
Contributor Author

Continuing to try to make a reprex; there is an unusual feature to me that obj$saem.eta.trans within nlmixrUI.saem.model.omega() is c(9, 11, 27) in the model with the issue (and the full, real data) and it is c(7, 9, 14) in the attempted reprex (and much simpler data). Without yet really knowing what saem.eta.trans is, I would have expected it only to be based on the model and not the data, but I apparently need to dig deeper...

@mattfidler
Copy link
Contributor

Hi Bill,

The saem low level functions are a bit tricky. If the model contains time-varying covariates some of the saem functions behave differently. Currently saem treats mu-referenced covariates as single values unless they are time-varying. Therefore the model may be different if the data contain time varying covariate.

I always struggle remembering the use of saem.eta.trans. My guess is that this shows the translation between the population parameters and the the mu-referenced ETAs. The time varying covariates are treated as a single mu referenced expression, so with a simple model with non time-varying expressions the "theta" numbers change. Without looking at your data and model, this is my impression of the situation.

Would that reflect your data?

@billdenney
Copy link
Contributor Author

Hmm... I just checked, and the only covariates in the model are non-time-varying. (The only covariates is baseline body weight, and I confirmed that every ID has a single baseline body weight value). And, in my test data, the way I was setting baseline body weight was the same (non-time-varying). I'll keep looking or trying to make a share-able reprex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants