[R] help using optim function
tmuman
mumantariq at gmail.com
Tue Oct 23 23:42:52 CEST 2012
Hi, am very new to R and I've written an optim function, but can't get it to
work
least.squares.fitter<-function(start.params,gr,low.constraints,high.constraints,model.one.stepper,data,scale,ploton=F)
{
result<-optim(par=start.params,method=c('Nelder-Mead'),fn=least.squares.fit,lower=low.constraints,upper=high.constraints,data=data,scale=scale,ploton=ploton)
return(result)
}
least.squares.fitter(c(2,2),c(0,0),c(Inf,Inf),ricker.one.step,dat,'linear')
where least.squares.fit is the function returning the difference between
model data points and predicted points (residuals, residuals^2 and SSR),
which i am trying to minimise
and ricker.one.step is the function that generated the predictions
I've been trying to figure out whats wrong for hours but can't.
Many thanks,
Tariq
--
View this message in context: http://r.789695.n4.nabble.com/help-using-optim-function-tp4647231.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list