nlmixrdevelopment / nlmixr

nlmixr: an R package for population PKPD modeling
https://nlmixrdevelopment.github.io/nlmixr/
GNU General Public License v2.0
114 stars 45 forks source link

Initial ETAs were nudged; #579

Closed hrishikesh1985 closed 2 years ago

hrishikesh1985 commented 2 years ago

Hi,

While using following, i got warning. data attached here.

myEmaxsaem <- function() { ini({ temax <- 20 ted50 <- 20 eta.emax ~ 1 add.err <- 1 }) model({ emax <- (temax + eta.emax) ed50 <- ted50
eff = (((emax)* time)/((ed50)+time)) eff ~ add(add.err) }) } myEmaxsaemfit <- nlmixr(myEmaxsaem, d_sim,est = "nlme", nlmeControl(gradHess=FALSE, opt = "nlm" ) )

Warning message: In (function (uif, data, est = NULL, control = list(), ..., sum.prod = FALSE, : initial condition for additive error ignored with nlme

how to resolve this?>

043_R.csv

mattfidler commented 2 years ago

Hi @hrishikesh1985

The warning condition says that the additive condition is ignored with nlme.

I would suggest a different algorithm, ie est="focei" or est="saem"

hrishikesh1985 commented 2 years ago

Ok thanks...

While running different dataset for same code, i got below error, step halving factor reduced below minimum in PNLS step

I tried to control it using pnlstol but different values are obtained with different pnlstol value. what value should be used in to have best fit...

hrishikesh1985 commented 2 years ago

with foce, it shows

In (function (uif, data, est = NULL, control = list(), ..., sum.prod = FALSE, : initial ETAs were nudged; (can control by foceiControl(etaNudge=., etaNudge2=)) 2: In (function (uif, data, est = NULL, control = list(), ..., sum.prod = FALSE, : ETAs were reset to zero during optimization; (Can control by foceiControl(resetEtaP=.)) gradient problems with initial estimate and covariance; see $scaleInfo

but it is not resolved by controlling etanudge

mattfidler commented 2 years ago

etaNudge only affects focei. The etaNuge is simply telling that the system could not solve at the initial estimates, and the etas were adjusted to be non-zero solve the initial problem.

The bigger problem is likely here:

gradient problems with initial estimate and covariance;

You could try

nlmixr(...., foceiControl(outerOpt="bobyqa") which is a gradient free optimization.

As far as pnlsTol, it should increase slightly to get a final solution. In my experience the more you increase it the more likely the ETAs will be zero for individuals, though.

mattfidler commented 2 years ago

This zero gradient is often caused by poor data, a bad model description of the data, or very flat likelihood surface for certain parameters (ie overparameterization)

hrishikesh1985 commented 2 years ago

OK. I am getting the warning of gradient problems every time.

i am trying to calculate the Emax and ED50 value which is calculated using below nlme model of winnonlin

E = Emax * C / (EC50 + C) error(EEps = 1) observe(EObs(C) = E + EEps) stparm(EC50 = tvEC50) stparm(Emax = tvEmax + nEmax) fixef(tvEC50 = 1, fixef(tvEmax = ranef(diag(nEmax) = c(1)) } The model is almost similar as defined above except C part.

However, there is slight difference in the result of both.

mattfidler commented 2 years ago

The slight difference should be expected, they are different software platforms and small differences are not problematic.

hrishikesh1985 commented 2 years ago

hmn... also, i am trying to optimize the model by using the obtained/resulted estimates as initial values for temax, ted50, eta.emax and add.err value.

Controlling the sigdig to different values shows significant change in the final estimates. Because obtained values are so near by and final fitted model shows values in 1 decimal only. so, it is dificult to identified what was the exact eta. emax for the same.

mattfidler commented 2 years ago

The sigdig arguments controls many different tolerances by one figure. As the sigdig increases the accuracy of the estimate increases. As described in the foceiCotnrol() documentation, it sets

In truth the optimization solvers can all be overwritten by what you specify, but the sigdig will affect the final solution.

With more significant digits, more accuracy is requested from the ODE solvers and the final estimate in the optimization routines.

These values are not exact but rather an estimate for all scenarios, so you will not be able to identify the "exact" eta for any problem.

hrishikesh1985 commented 2 years ago

thanks for all the support.. This has been figured out now.