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

string assign is too strict for use in nlmixr2est #779

Merged
merged 4 commits into from
Aug 31, 2024
Merged

Conversation

mattfidler
Copy link
Member

By parsing a simple if/else and pruning it we get:

library(rxode2)
#> rxode2 3.0.0 using 8 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
f <- rxode2({
  levels(a) <- c("good", "bad")
  E0 <- THETA[1]
  Em <- THETA[2]
  E50 <- THETA[3]
  g <- 2
  v <- E0 + Em * time^g / (E50^g + time^g) + wt
  p <- expit(v)
  a <- (p < 0.5) * (1)
  a <- (1 - (p < 0.5)) * (2) + (1 - ((1 - (p < 0.5)))) * (a)
  rx_yj_ ~ 152
  rx_lambda_ ~ 1
  rx_low_ ~ 0
  rx_hi_ ~ 1
  rx_r_ ~ 0
  rx_pred_ ~ DV * v - log(1 + exp(v))
  rx_pred_ <- -rx_pred_
})
#> rxode2 model syntax error:
#> ================================================================================
#> :001:     levels(a) <- c("good", "bad")
#> :002:     E0 <- THETA[1]
#> :003:     Em <- THETA[2]
#> :004:     E50 <- THETA[3]
#> :005:     g <- 2
#> :006:     v <- E0 + Em * time^g/(E50^g + time^g) + wt
#> :007:     p <- expit(v)
#> :008: the string variable 'a' can only be 1 to 2, or 'good', 'bad':
#>           a <- (p < 0.5) * (1)
#>                ^~~~~~~~~~~~~~~~~~~~
#> :008:     a <- (p < 0.5) * (1)
#> :009: the string variable 'a' can only be 1 to 2, or 'good', 'bad':
#>           a <- (1 - (p < 0.5)) * (2) + (1 - ((1 - (p < 0.5)))) * (a)
#>                ^
#> :009:     rx_yj_ ~ 152
#> :010:     rx_lambda_ ~ 1
#> :011:     rx_low_ ~ 0
#> :012:     rx_hi_ ~ 1
#> :013:     rx_r_ ~ 0
#> :014:     rx_pred_ ~ DV * v - log(1 + exp(v))
#> :015:     rx_pred_ <- -rx_pred_
#> ================================================================================
#> Error: syntax errors (see above)

Created on 2024-08-31 with reprex v2.1.1

@mattfidler
Copy link
Member Author

While it works out to 1 or 2 the parser doesn't do algebra.

@mattfidler mattfidler merged commit 771b204 into main Aug 31, 2024
5 of 7 checks passed
@mattfidler mattfidler deleted the 779-less-strict branch August 31, 2024 16:48
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

Successfully merging this pull request may close these issues.

1 participant