Dear R users,

I am new to R. I would like to find *maximum likelihood estimators for psi
and alpha* based on the following *log likelihood function*, c is
consumption data comprising 148 entries:

fn<-function(c,psi,alpha)

{

s1<-sum(for(i in 1:n){(c[i]-(psi^(-1/alpha)*(lag(c[i],-1))))^2*

(lag(c[i],-1)^((-2)*(alpha+1))

)});

s2<- sum(for(m in 1:n){log(lag(c[m],-1)^(((2)*alpha)+2))});

constant-(74*s1)-(1/2)*s2}



In particular I want to use the BHHH and the BFGS algorithms. I have found
the following packages that can be used for the task:  *mle{stats4},
optim{stats}, maxBHHH{micEcon}, maxBFGS{micEcon}*. I have documented some of
my attempts below ((a) package name (b) usage (c) my attempt and
corresponding error). In all humility I apologise for any bad coding, and
ask if anyone can *direct me in finding these estimators*.



Yours sincerely.





*(1a)  mle{stats4}

(b)  Usage:

     mle(minuslogl, start = formals(minuslogl), method = "BFGS",

     fixed = list(), ...)

(For this I use the negative of the log-likelihood function,bn)*

*(c)  >mle(start=list(psi=1,alpha=0),fn, method="BFGS",fixed=list(c=c))*

Error in optim(start, f, method = method, hessian = TRUE, ...) :

        non-finite finite-difference value [1]



*(2a)  optim{stats}



(b)  optim(par, fn, gr = NULL,

      method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"),*

*

      lower = -Inf, upper = Inf,

      control = list(), hessian = FALSE, ...)



(c)  > optim(c(c,1,0),fn, method="BFGS", control=list(c=c))*

Error: argument "psi" is missing, with no default



*(3a)     maxBHHH{micEcon}

(b)     Usage: maxBHHH(fn, grad = NULL, hess=NULL, theta, print.level
= 0, iterlim = 100,   ...)*

* *

*(c) > maxBHHH(fn(c,psi,alpha),theta=list(psi=1,alpha=0))*

 Error in psi^(-1/alpha) * (lag(c[i], -1)) :

        time-series/vector length mismatch



(4a)  maxBFGS{micEcon}



(b)  Usage: maxBFGS(fn, grad = NULL, theta, print.level = 0, iterlim = 200,

     tol = 1e-06, ... )

*(ci) >  maxBFGS(fn(c,psi,alpha),theta=list(psi=1,alpha=0))*

Error in psi^(-1/alpha) * (lag(c[i], -1)) :

        time-series/vector length mismatch



*(cii)> maxBFGS(fn,theta=list(psi=1,alpha=0))*

Error: argument "psi" is missing, with no default

	[[alternative HTML version deleted]]

