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

SIMrun will not create csv if all but one covariates are fixed #50

Open
mhovd opened this issue Dec 3, 2021 · 1 comment
Open

SIMrun will not create csv if all but one covariates are fixed #50

mhovd opened this issue Dec 3, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@mhovd
Copy link
Contributor

mhovd commented Dec 3, 2021

During some testing with SIMrun, I encountered an error.
When the number of non-fixed covariates to be simulated is one, SIMrun will fail to create a csv-file with the data.
This is the error: Error in (nfixed + 1):(nfixed + ncol(covDF)) : argument of length 0.

I believe this error is because ncol(covDF) evaluates to NULL.

Here is a minimal example reproducing the error:

library(Pmetrics)

PMwriteMatrix(data = mdata.1, filename = "template.csv")
writeLines(model, con = "model.txt")

SIMrun(makecsv = "simdata.csv", include = 1, model = "model.txt", 
       data = "template.csv", poppar = final.1, nsim = 10,
       covariate = list(cov = cov.1, fix = c("africa","age","gender","height")))

Setting obsNoise to model file assay error. When making a csv file, you cannot specify no obsNoise.

Model solver mode: Algebraic
Number of compartments: 2, including an absorptive compartment
Primary Variables: Ka, Ke, V, Tlag1, wt
Covariates in data file: africa, age, gender, height
Covariates used in model file: africa, age, gender, height
Secondary Variables: KCP, KPC
Model conditions: no bioavailability term defined, initial conditions are zero, lag term defined

The following subject(s) in the data will serve as the template(s) for simulation: 1

Simulating from subject 1 ...
Error in (nfixed + 1):(nfixed + ncol(covDF)) : argument of length 0

@mhovd
Copy link
Contributor Author

mhovd commented Feb 4, 2024

This issue still appears to be present in 2.0, with the following example

NPex$sim(
  nsim = 1,
  include = 1,
  covariate = list(
    cov = NPex$cov,
    fix = c("africa", "age", "gender", "height")
  ), makecsv = "out.csv"
)

Error in (nfixed + 1):(nfixed + ncol(covDF)) : argument of length 0
In addition: Warning message:
In cbind(covDF, temp[, nfixed + covNotSimPos]) :
  number of rows of result is not a multiple of vector length (arg 2)

@mhovd mhovd added the bug Something isn't working label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant