[R] question about formulating a nls optimization
Adi Humbert
adrian_humbert at yahoo.com
Fri Jul 18 20:45:01 CEST 2003
Dear list,
I'm migrating a project from Matlab to R, and I'm
facing a relatively complicated problem for nls. My
objective function is below:
>> objFun <- function(yEx,xEx,tEx,gamma,theta,kappa){
yTh <- pdfDY(xEx,tEx,gamma,theta,kappa)
sum(log(yEx/yTh)^2)
}
The equation is yTh=P(xEx,tEx) + noise.
I collect my data in:
>> data <- data.frame(xEx,tEx,yEx)
And I do the nls:
aux <- nls( ~ objFun(yEx,xEx,tEx,gamma,theta,kappa),
data=data,
start=list(gamma=0.085, theta=8.62*10^(-5),
kappa=4.45*10^(-3)), trace=TRUE)
I get the following error:
179.8911 : 8.50e-02 8.62e-05 4.45e-03
Error in sum(rr[-(1:npar)]^2) : subscript out of
bounds
One problem that I identified is that the algorithm
does not change the values of the parameters at all.
It calculates the objective function OK, but the
parameters are not updated.
The function pdfDY is a Fourier integral with
parameters xEx, tEx, gamma, theta, kappa, that I
calculate with a Filon algorithm. The calculation of
pdfDY is correct.
Can anybody help me with this? Thank you very much,
Adrian
More information about the R-help
mailing list