Hi
I am trying to fit a sinusoidal model (y = *a* + *b*x + *c**sin( *d* * x *
pi - *e ** pi)) to time series data. I can successfully fit an
unconstrained model with the curve_fit function using the LsqFit package.
My problem is that the frequency parameter (*d* above) needs to be in the
range [0.75; 1.5].
I tried to use the Optim package and then optimise the squared error
function using fminbox, but I got the following error:* 'fminbox' has no
method matching fminbox(::Functiom, ::Array{Float64,1}, ::Array{Float64,1},
::Array{Float64,1},)*
My code is below:
*function sqerror(betas)*
* err = 0.0*
* for i in 1:length(x_data)*
* pred_i = betas[1] + betas[2] * x_data[i] +
betas[3]*sin(betas[4]*2pi*x_data[i]-betas[5]*2pi)*
* err += (y_real[i] - pred_i)^2*
* end*
* return err*
*end*
*l = [-Inf, -Inf, 0, 0.75, -2.0]*
*u = [Inf, Inf, Inf, 1.5, 2.0]*
*p0 = [y_real[1], (y_real[256]-y_real[1]) / 255,
0.5*(y_real[256]-y_real[1]), 1.25, 0]*
*results = fminbox(sqerror, p0, l, u)*
Is there another package / function that would work better in this
situation?