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

covarsearchauto not working with categorical variables #71

Open
danieleboaretti opened this issue Oct 18, 2024 · 1 comment
Open

covarsearchauto not working with categorical variables #71

danieleboaretti opened this issue Oct 18, 2024 · 1 comment

Comments

@danieleboaretti
Copy link

Hello,

I am reporting a possible issue with covarsearch auto.
I tested the code in the documentation:

one.cmt <- function() {
  ini({
    ## You may label each parameter with a comment
    tka <- 0.45 # Log Ka
    tcl <- log(c(0, 2.7, 100)) # Log Cl
    ## This works with interactive models
    ## You may also label the preceding line with label("label text")
    tv <- 3.45; label("log V")
    ## the label("Label name") works with all models
    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)
  })
}

d <- theo_sd
d$SEX <-0
d$SEX[d$ID<=6] <-1



fit <- nlmixr2(one.cmt, d, "focei")

fitcovarWT <- covarSearchAuto(fit, varsVec = c("ka", "cl"),
    covarsVec = c("WT"))
covarSearchAuto(fit, varsVec = c("ka", "cl"),
    covarsVec = c("SEX"), catvarsVec = c("SEX"))

The code runs fine when using WT as covariate, while for SEX it gives me an error.

The covarsearchauto gives me this error:

── starting forward search... ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Error in .foceiPreProcessData(.data, .ret, .ui, .control$rxControl) :
  Assertion on 'names(data)' failed: Names must include the elements {'ID','DV','TIME','SEX'}, but is missing elements {'SEX'}.

I don't understand why, in d there is the SEX column:

head(d)
  ID TIME    DV     AMT EVID CMT   WT SEX
1  1 0.00  0.00 319.992  101   1 79.6   1
2  1 0.00  0.74   0.000    0   2 79.6   1
3  1 0.25  2.84   0.000    0   2 79.6   1
4  1 0.57  6.57   0.000    0   2 79.6   1
5  1 1.12 10.50   0.000    0   2 79.6   1
6  1 2.02  9.66   0.000    0   2 79.6   1

I wonder if the categorical variable might cause the problem here.

Thank you for your support.

Daniele

@danieleboaretti danieleboaretti changed the title covarsearchauto not working covarsearchauto not working with categorical variables Oct 18, 2024
@mattfidler
Copy link
Member

Hi @danieleboaretti

This is currently broken.

I guess the best thing to do is turn it off for now (no longer export it).

@mattfidler mattfidler transferred this issue from nlmixr2/nlmixr2 Oct 18, 2024
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