[R] Issues when trying to fit a nonlinear regression model

Paul Bernal p@u|bern@|07 @end|ng |rom gm@||@com
Sun Aug 20 19:15:08 CEST 2023


Dear friends,

This is the dataset I am currently working with:
>dput(mod14data2_random)
structure(list(index = c(14L, 27L, 37L, 33L, 34L, 16L, 7L, 1L,
39L, 36L, 40L, 19L, 28L, 38L, 32L), y = c(0.44, 0.4, 0.4, 0.4,
0.4, 0.43, 0.46, 0.49, 0.41, 0.41, 0.38, 0.42, 0.41, 0.4, 0.4
), x = c(16, 24, 32, 30, 30, 16, 12, 8, 36, 32, 36, 20, 26, 34,
28)), row.names = c(NA, -15L), class = "data.frame")

I did the following to try to fit a nonlinear regression model:

#First, Procedure to Find Starting (initial) Values For Theta1, Theta2, and
Theta3

mymod2 <- y ~ theta1 - theta2*exp(-theta3*x)

strt2 <- c(theta1 = 1, theta2 = 2, theta3 = 3)

trysol2<-nlxb(formula=mymod2, data=mod14data2_random, start=strt2,
trace=TRUE)
trysol2
trysol2$coefficients[[3]]

#Fitting nonlinear Regression Model Using Starting Values From Previous Part
nonlinearmod2 <- nls(mymod2, start = list(theta1 =
trysol2$coefficients[[1]],
                     theta2 = trysol2$coefficients[[2]],
                     theta3 = trysol2$coefficients[[3]]), data =
mod14data2_random)

And I got this error:
Error in nlsModel(formula, mf, start, wts, scaleOffset = scOff, nDcentral =
nDcntr) :
  singular gradient matrix at initial parameter estimates

Any idea on how to proceed in this situation? What could I do?

Kind regards,
Paul

	[[alternative HTML version deleted]]



More information about the R-help mailing list