nlmixr2 / nlmixr2extra

Extra utilities for nlmixr objects
https://nlmixr2.github.io/nlmixr2extra/
GNU General Public License v3.0
3 stars 1 forks source link

SCM filter result problem #64

Open junmoxiao66 opened 10 months ago

junmoxiao66 commented 10 months ago

How can I solve this problem?I use the saem algorithm, Error in covSearchRes[[which.min(resTable$pchisqr)]][[1]] : wrong arguments for subsetting an environment

屏幕截图 2023-12-27 212749
vsarsani commented 10 months ago

@junmoxiao66 Can you Post the command you used?

junmoxiao66 commented 10 months ago

The following two pictures are, thank you

屏幕截图 2024-01-02 095504 屏幕截图 2024-01-02 095705
junmoxiao66 commented 6 months ago

@vsarsani How to solve the above problem?

vsarsani commented 6 months ago

@junmoxiao66 Sorry for the delay. Let me look into this week.

junmoxiao66 commented 6 months ago

@vsarsani Thank you very much.

vsarsani commented 6 months ago

@junmoxiao66 Can you output following for your data

is.numeric(AIC(fit) fit$objf

junmoxiao66 commented 6 months ago

@vsarsani I ran the new code again,This is found in all code, as long as the covariates are filtered out, this error will occur. 1715003395150(1) 1715003452794(1) 1715003519072 Finally, I have one more question: Why is the estimated value of tcl negative

mattfidler commented 6 months ago

The value of tcl is negative since it is on a log scale. You take the exponential to get the back transformed value

On Mon, May 6, 2024, 8:56 AM junmoxiao66 @.***> wrote:

@vsarsani https://github.com/vsarsani I ran the new code again,This is found in all code, as long as the covariates are filtered out, this error will occur. 1715003395150.1.jpg (view on web) https://github.com/nlmixr2/nlmixr2extra/assets/140042718/bac40147-c14c-4a07-89a7-9597433ee3f0 1715003452794.1.jpg (view on web) https://github.com/nlmixr2/nlmixr2extra/assets/140042718/91d5144e-55d8-4780-bb9d-8aecf73d2f69 1715003519072.jpg (view on web) https://github.com/nlmixr2/nlmixr2extra/assets/140042718/078ffa36-d984-4058-96da-3d0fec642e45 Finally, I have one more question: Why is the estimated value of tcl negative

— Reply to this email directly, view it on GitHub https://github.com/nlmixr2/nlmixr2extra/issues/64#issuecomment-2096079576, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5VWUNX5LZRPXGIDRLT5DZA6DZVAVCNFSM6AAAAABBEL2OOKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWGA3TSNJXGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

junmoxiao66 commented 6 months ago

@mattfidler Suddenly, thank you very much for your reply

pippalf commented 6 months ago

Hi all,

I am having the same issue. Here is some reproducible code with the warfarin dataset:

### From https://nlmixr2.org/articles/running_nlmixr.html

library(nlmixr2)

one.cmt <- function() {
  ini({
    tka <- 0.45 # Ka
    tcl <- log(c(0, 2.7, 100)) # Log Cl
    tv <- 3.45; label("log V")
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    add.sd <- 0.7
  })
  model({
    ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    linCmt() ~ add(add.sd)
  })
}

f <- nlmixr(one.cmt)

### Updated with warfarin dataset.

fit <- nlmixr(one.cmt, warfarin, est="focei", control=list(print=0))

print(fit)

### Error starts here:
# "Error in covSearchRes[[which.min(resTable$pchisqr)]][[1]] :
#   wrong arguments for subsetting an environment"

Fit.scm =
  covarSearchAuto(
    fit=fit,
    varsVec=c("ka","cl", "v"),
    covarsVec=c("wt", "age", "sex"),
    pVal=list(fwd=0.5, bck=0.1),
    searchType="scm" 
  )

rxode2::.rxWithWd(tempdir(), {
  Fit.scm =
    covarSearchAuto(
      fit=fit,
      varsVec=c("ka","cl", "v"),
      covarsVec=c("wt", "age", "sex"),
      pVal=list(fwd=0.5, bck=0.1),
      searchType="scm" 
    )
})

Any ideas on how to solve this or what it means?

the-magister commented 6 months ago

I can partially fix forwardSearch. The issue seems to be that the code assumes covSearchRes[[]] contains fitted objects, but it does not. It's a list of "prediction only" models. So, the next loop through pulls that object and it lacks and objective function (and many other things). The hack I came up with was to select the best model, then (RE)fit it. Very inefficient, but it does work:

mod <- covSearchRes[[which.min(resTable$pchisqr)]] fit <- suppressWarnings(nlmixr2(mod,data,est=fit$est))

junmoxiao66 commented 5 months ago

@the-magister awesome

junmoxiao66 commented 5 months ago

@vsarsani Hello, can you fix this BUG? I am very eager to use all the functions of your package to build PPK models (including the function of covariate screening), and then to publish the article, I think your open source R package is too good, but everyone seems to be concerned about this package is not particularly high, but also want to publicize the nlmixr2 package through the article

junmoxiao66 commented 5 months ago

@vsarsani Hello, professor, I'm sorry to bother you again, and I want to ask if you have time to fix the BUG. I'm waiting to use your package to screen covariates. Thank you again, and I hope you can make a breakthrough!

vsarsani commented 5 months ago

@junmoxiao66 Sorry, did not get a chance to look into this. Let me try to see if I can do it this weekend. Have you tried bayesian covariate selection in nlmixr2

junmoxiao66 commented 5 months ago

@vsarsani I haven't used Bayesian covariate selection, can you tell me specifically how to call this function?Which function is it? 1717089411716

vsarsani commented 5 months ago

https://cran.r-project.org/web/packages/nlmixr2extra/nlmixr2extra.pdf

Try horseshoedf , covarSearchAuto and also lassoSummardf

Use library(nlmixr2extra)