x1<-c(5.548,4.896,1.964,3.586,3.824,3.111,3.607,3.557,2.989,18.053,3.773,1.253,2.094,2.726,1.758,5.011,2.455,0.913,0.890,2.468,4.168,4.810,34.319,1.531,1.481,2.239,4.204,3.463,1.727)
y<-c(2.590,3.770,1.270,1.445,3.290,0.930,1.600,1.250,3.450,1.096,1.745,1.060,0.890,2.755,1.515,4.770,2.220,0.590,0.530,1.910,4.010,1.745,1.965,2.555,0.770,0.720,1.730,2.860,0.760)
x2<-c(0.137,2.499,0.419,1.699,0.605,0.677,0.159,1.699,0.340,2.899,0.082,0.425,0.444,0.225,0.241,0.099,0.644,0.266,0.351,0.027,0.030,3.400,1.499,0.351,0.082,0.518,0.471,0.036,0.721)
k<-rep(1,29)
x<-data.frame(k,x1,x2)

freg<-function(y,x1,x2){
  reg<- rlm(y ~ x1 + x2 , data=x)
  return(reg)
}


 func <- function(x1,x2,b){
      fit<-freg(y,x1,x2)
        b<-c(coef(fit))
      dv<-1+ b[2]*x2^b[3]
        dv1<-b[2]*x2^b[3]*log(x2)
      out <- ( x1/(1+ b[2]*x2^b[3]))
      out1<-  c(-x1*x2^b[3]/dv^2,-x1* dv1/dv^2)
        return(list( out,out1))
       }>
optim(par=c(b[2],b[3]), fn=out, gr =out1,
        method = c("BFGS"),
        lower = -Inf, upper = Inf,
        control = list(), hessian = T)
can someone help me try running this code because i try many occasion but prove  abortive. the aim is
to optimize the parameter of the model that is parameter estimates using optimization 

	[[alternative HTML version deleted]]

