Hello,

I posted this question last week and have not heard anything, I am wondering if anyone had ideas for testing a model relationship?

I am working with a real-time hydrologic modeling system, and I am using R (R batch script on Linux) to create a non-linear relationship (exponential) between observed data. I want to extract the non-linear coefficients (“b” and “m”) if the relationship can be created, if the relationship cannot be created I will use default “b” and “m” coefficients. In the R script I some times get an error of singular gradient matrix (see below). I want to test whether I can create the relationship (singular gradient causes the script crash) and use the model extracted coefficients or use default coefficients.

Model in R batch script:
fit.nls <- nls(P~(b*exp(m*Z)), start=list(m=0.015,b=0.017),
control=list(maxiter=200))
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates

** the initial parameter values are also the default

Specific Questions:
1) Is there a way to test fit.nls (or the data) prior to see if this error occurs.
2) Would this test be set up as an if statement?
if (fit is good) {proceed model coefficients} else {use default coefficients}?

Thanks for all your help,
Doug

--
---------------------------------
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice: 970.686.1253
email: dmhul...@metstat.com
web: http://www.metstat.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to