MarcLavielle / mlxR

mlxR
Other
19 stars 5 forks source link

Bug when regressor has missing values #32

Open jamesdwade opened 3 years ago

jamesdwade commented 3 years ago

https://github.com/MarcLavielle/mlxR/blob/3b2609375ef9f32841e9ec49ac4a49e79869ced3/R/readdatamlx.R#L484-L490

Hi Marc,

I seem to have found a bug in monolix2simulx when it comes to 1) having multiple columns in the data set defined as regressors AND 2) one or more of those columns containing missing values "." - if those regressor columns with missing values do not come before the regressor columns without missing values.

Specific case:

My data set in Monolix includes 3 regressors:

When I run monolix2simulx, I get the following error:

[.data.frame`(Sx, , ix.num[k]) : undefined columns selected 

The error appears to occur in readDatamlx specifically from for (k in (ix.num)) on line 489 and Sx[,ix.num[k]] on line 490.

It is possible to work-around this error by reordering the regressors in the original dataset to {X2,X1,X3}, such that the regressor, X2, with missing values (or all such regressors) come first - I have confirmed this as a work-around.

It would, however, be great to get a bug fix.

Thanks,

James