[R] Odp: [nls] singular gradient
petr.pikal at precheza.cz
Mon Oct 1 10:33:20 CEST 2007
Althoug I am not an expert in nonlinear regression, it seems to me that
your data are quite noisy. I presume you have got your model from
elsewhere and now you try to use it for your data. Looking at it and using
nlme I suppose you will not get such definite model based on your data.
> data1$ev <- ordered(data1$ev)
> data1.gr <- groupedData(N~CSR|ev, data1)
> out <- nlsList(N~CSR/(A+B*CSR), data1.gr, start= c(A=1, B=1))
> out1<- nlme(out)
0.2 8.667265e-05 -6.267700e-04
0.3 -3.139092e-04 2.206547e-03
0.4 4.044455e-06 -2.349364e-05
3.6 -7.402470e-08 -5.312590e-06
5 -3.844779e-06 2.942158e-05
> plot(as.numeric(row.names(ranef(out1))), ranef(out1)[,1])
> plot(as.numeric(row.names(ranef(out1))), ranef(out1)[,2])
You can clearly see that A and B random efect values are oscilating around
0 with increasing "ev" which seems to me that A and B are independent on
petr.pikal at precheza.cz
r-help-bounces at r-project.org napsal dne 01.10.2007 02:37:52:
> Hi, I am new to R. I don't have strong background of statistics. I am
> a student of Geotechnical Engineering. I tried to run a nonlinear
> regression for a three-variable function, that is
> N = f(CSR, ev) # N is a function of CSR and ev, and N = CSR/(A
> +B*CSR), wherer (A,B) are function of ev.
> N, CSR and ev are observed in the experiments.
> Following is my R script.
> # assign data
> N <- c
> CSR <- c
> ev <- c
> # set the data frame
> data1<- data.frame(cbind(N,CSR,ev))
> # the initial values of parameters
> para1.st <- c(a=75.4,b=165.9,c=-22.4,d=0,e=0.8,f=-0.28,g=0)
> para2.st <- c(a=31.3,b=-176.9,c=53.41,d=0,e=75.2,f=-0.18,g=0)
> # call nls funciton
> try.control <- c(maxiter=100, minFactor=1/4096)
> out <- nls(N~CSR/(1/(a+b*ev+c*(ev^2))+CSR/(d+e*exp(f*ev)))-g, data1,
> start=para1.st, control=try.control, trace=T)
> The data is from experiments and the pattern of data is scatter quite
> a bit. I want to find the best fit coefficients (a,b,c,d,e,f,g) for
> the data.
> I have two different sets of initial values for try. But in both
> cases I got error message of
> "singular gradint"
> What can I do for this error? Is there any other nonlinear regression
> model I can try? This problem is kind of emergency. I really hope
> someone can help me out. Any comment is appreciated. Thanks a lot.
> Yi-Min Huang
> Civil & Environmental Engineering
> U. of Washington
> Niner, Seattle
> ninerdummy at gmail.com
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help