[R] ms?

Douglas Bates bates at stat.wisc.edu
Mon Feb 28 17:39:04 CET 2000


Douglas Bates <bates at stat.wisc.edu> writes:

> Assuming that the quadratic form evaluates to a scalar, try
> 
> opt.func <- function(alf, beta) 
>   t(Y-(X[,1] * alf + X[,2] * bet)^delta) %*% covariance.matrix.inverse %*%
>             (Y-(X[,1] * alf + X[,2] * bet)^delta)
> 
> nlm(opt.func, c(alf = 5, bet = 0.5))
> 
> or
> 
> optim(c(alf = 5, bet = 0.5), opt.func)

Those are wrong.  The function being optimized has to be a function of
a single argument.  If alf and bet are both scalars you can combine
them into a vector and use

opt.func <- function(arg) 
  t(Y-(X[,1] * arg[1] + X[,2] * arg[2])^delta) %*% covariance.matrix.inverse %*%
            (Y-(X[,1] * arg[1] + X[,2] * arg[2])^delta)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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