[R] nls() singular graident matrix error

Yang, Richard dyang at nrcan.gc.ca
Thu Jul 11 21:19:35 CEST 2002


R-helpers;

	I used Proc Model in SAS to fit the following model to data:

		proc model data = dbsmv;
                        a = a1*F**2;
                        b = b1*F + b2*T + b3*F*T;
                        tph2 = tph1 *((1 - exp(-a*age2)) / (1 -
exp(-a*age)))**-b;
		fit  tph2;

	and yielded the following estimated parameters after iterations:

	a1 = -0.15943, a2 = -1.8177, b1 = -0.01911, b2 = - 0.01494, b3 =
0.036427 with SEE = 4.7492 and MSE = 0.0111 (427 d.f). The model fits well
to the data.
	

	Trying to duplicate the model in R using nls(), I took the following
steps:

	Foo <- deriv( ~ tph1 * ((1 - exp(-(a1*N^a2)*age2))/ (1 -
exp(-(a1*N^a2)*age)))^(-(b1*N + b2*T +
            b3*F*T)), c("a1","a2","b1","b2","b3"), function(tph1, age2, age,
T, N, a1, a2, b1, b2, b3) {})

	Foo.nls <- nls(tph2 ~ Foo(tph1,N, T, a1, a2, b1, b2, b3), data =
dbsmv,
    start = c(a1 = -0.15943, a2 = -1.8177, b1 = -0.01911, b2 = - 0.01494, b3
= 0.036427))	

	The nls() failed due to 
	"Error in nlsModel(formula, mf, start) : singular gradient matrix at
initial parameter estimates".

	Any workaround for the singularity problem? 

	Thanks in advance,

Richard


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list