[R] stupid q re: gradient to nlm

Maneesh maneesh at www.chip.org
Sun Aug 12 23:49:09 CEST 2001


Hi all,
I can't figure out why the following function when supplied to nlm, isn't
using the gradient function that I am providing, everything I read says to
attach "gradient" attribute to the return value...no?

atanE <- function(a) {

  gr <- function(a){
  g<-numeric()
  print("adsad")   #I never get this
  g[4]<-sum(2*(a[1]*atan((a[2]*x)-a[3])+a[4]-y))
  g[3]<-sum(g[4]*(-(a[1]/(1+((a[2]*x)-a[3])^2))))
  g[2]<-sum(g[3]*x)
  g[1]<-sum(g[4]*atan((a[2]*x)-a[3]))
  g
 }

 value<-sum( ((a[1]*atan((a[2]*x)-a[3])+a[4]) - y)^2 )
 attr(value, "gradient")<-gr
 value
}

Sorry for the bother,
Maneesh


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list