Hello.
As part of a Monte Carlo simulation, I'm programming some model comparisons on generated data. The underlying relationship in the data is a two-parameter exponential curve (y=a*e^(bx)), and among the models being compared are hyperbolic (y=a/(1+bx)), and quadratic (y=b*(x-a)^2) relationships. The generated datasets follow a within-subjects design, and each subject may have unique values for the two parameters. As such, the models are being fit using nlme().
The problem I'm having is that the hyperbolic and quadratic models fail to converge a majority of the time. The error I usually get for the hyperbolic model is:
The quadratic model also produces the same type of error, but it will sometimes produce this one instead:
Choosing better starting parameter values helps a little, but the problem is still prevalent. I've tried raising the nlmeControl parameters "tol," "pnlsTol," and "minScale," to no avail, and my google-fu hasn't uncovered any other possible solutions.
Here is my code for the model fits:
(ahyp, bhyp, aquad, and bquad are products of separate estimation functions, similar to a SelfStart approach)
I've attached three example datasets (comma-separated .txt, since I can't do .csv), if that helps. I can't seem to get one that produces the Na/NaN/Inf error for the quadratic model right now, since that one is less common.
Some other info that might be useful: The simulation tests several different ways of sampling the independent variable in the generated datasets. The quadratic model fails more often when a small number (2-4) of discrete IV values are sampled. The hyperbolic model fails more often when there are fewer observations per subject and/or when there is greater between-subject variance in the b parameter in the underlying exponential relationship. Unfortunately, these are all aspects of the simulation that need to remain in place.
I'm pretty desperate at this point. I would be grateful for any help you can offer. Thank you.
As part of a Monte Carlo simulation, I'm programming some model comparisons on generated data. The underlying relationship in the data is a two-parameter exponential curve (y=a*e^(bx)), and among the models being compared are hyperbolic (y=a/(1+bx)), and quadratic (y=b*(x-a)^2) relationships. The generated datasets follow a within-subjects design, and each subject may have unique values for the two parameters. As such, the models are being fit using nlme().
The problem I'm having is that the hyperbolic and quadratic models fail to converge a majority of the time. The error I usually get for the hyperbolic model is:
Code:
Error in nlme.formula(y ~ a/(1 + b * x), data = theData, fixed = a + b ~ :
Step halving factor reduced below minimum in PNLS step
Code:
Error in FUN(newX[, i], ...) :
NA/NaN/Inf in foreign function call (arg 1)
Here is my code for the model fits:
Code:
hypMod1<-try(nlme(y~a/(1+b*x), data=theData, fixed=a+b~1, random=a+b~1|subj, groups=~subj, start=list(fixed=c(a=ahyp,b=bhyp)), correlation=NULL, control=nlmeControl(maxIter=100, tol=1, pnlsTol=.1, minScale=.1), weights=varPower(), method="REML"))
quadMod1<-try(nlme(y~b*(x-a)^2, data=theData, fixed=a+b~1, random=a+b~1|subj, groups=~subj, start=list(fixed=c(a=aquad,b=bquad)), correlation=NULL, control=nlmeControl(maxIter=100, tol=1, pnlsTol=.1, minScale=.1), weights=varPower(), method="REML"))
I've attached three example datasets (comma-separated .txt, since I can't do .csv), if that helps. I can't seem to get one that produces the Na/NaN/Inf error for the quadratic model right now, since that one is less common.
Some other info that might be useful: The simulation tests several different ways of sampling the independent variable in the generated datasets. The quadratic model fails more often when a small number (2-4) of discrete IV values are sampled. The hyperbolic model fails more often when there are fewer observations per subject and/or when there is greater between-subject variance in the b parameter in the underlying exponential relationship. Unfortunately, these are all aspects of the simulation that need to remain in place.
I'm pretty desperate at this point. I would be grateful for any help you can offer. Thank you.
Last edited: