[R] nonlinear regression problem
Sungsu
skim033 at ucr.edu
Thu Apr 10 23:31:27 CEST 2008
Dear R users.
I would like to ask you a nonlinear regression
problem that I have. Thr model is
y=integrate(1/[(a+b*cos(x))*sqrt{(a+b*cos(x))^2-h^2}],from 0
to x)
I tried the following code in writing the function and the
minimization:
y=c( 3.2, 3.4, 3.2, 3, 3.4, 3.1, 3.2, 3.3, 3.5, 3.4, 3.2,
3.4, 3.1, 3.2, 3.3 )
x=c( 0.2, 0.3, 0.8, 1.2, 1.4, 1.4, 1.5, 2, 1.7, 1.7, 1.8,
1.8, 1.9, 1.9, 1.9 )
l=length(x)
fun2<-function(u)
{
h<-u[1]
a<-u[2]
b<-x[3]
f=vector(length=l)
for(i in 1:l)
{
f[i]=h*integrate(function(t)((a+b*cos(t))*sqrt((a+b*cos(t))^2-
h^2))^(-1),lower=0,upper=y[i])$value
}
ff=sum(1-cos(x-f))
ff
}
nlminb(c(1.9999,1,1),fun2,lower =c(0.0001,0,0), upper =c
(1.9999,2*pi,2*pi))
This code runs ok, however the estimates of h, a and b are
just the boundary values, which I think they are wrong.
Please advise.
I would appreciate your help.
Sungsu
UCR
More information about the R-help
mailing list