R function to search for a function
Asked Answered
C

1

3

Update: The original question is: Is there an R function using the same algorithm implemented in the "lsqnonlin" function in matlab? However, the answer is more related to searching a function in R. I think the answer is in general very helpful for R users. So I edited the title but asked the original question again here: In R, how to do nonlinear least square optimization which involves solving differential equations?

I am doing nonlinear least-square optimizations and found that the matlab function lsqnonlin performs better than all the optimization algorithms I tried in R (including the algorithms in function optimx, nlm, nlminb, solnp, etc.) in the sense that it is faster and found the "more correct" solution.

However, I did not find an implementation of the 'trust-region-reflective' algorithm in R that is used in Matlab. Does someone know if there is already an implementation? Also, is it always true that the 'trust-region-reflective' algorithm is a better algorithm for this kind of optimization?

Chiefly answered 4/12, 2012 at 12:50 Comment(2)
It is better to ask this question here :stats.stackexchange.comIson
thanks, @agstudy. I was actually not sure where to post. But I think I Matthew Plourde has answered my question.Chiefly
A
5

It sounds like lsqnonlin in the pracma package is what you're looking for.

I recommend installing the sos package for R. Its purpose is to help you answer questions like 'Is there a function out there that does this?'. findFn in this package will search what's on CRAN for the term you supply.

library(sos)
findFn('lsqnonlin')
Abduct answered 4/12, 2012 at 14:4 Comment(2)
Thank you very much for the help. I knew neither sos nor lsqnonlin in pracma, I will try them out.Chiefly
I started working on this problem again and found that the lsqnonlin in the pracma package only implemented the levenberg-Marquardt algorithm. Here is the description of the function "lsqnonlin solves nonlinear least-squares problems, including nonlinear data-fitting problems, through the Levenberg-Marquardt approach. lsqnonneg solve nonnegative least-squares constraints problem."Chiefly

© 2022 - 2024 — McMap. All rights reserved.