[R] ms?

Douglas Bates bates at stat.wisc.edu
Mon Feb 28 17:26:05 CET 2000


gb at stat.umu.se writes:

> On 28 Feb 2000, Douglas Bates wrote:
> 
> > gb at stat.umu.se writes:
> > 
> > > Is the Splus (4.0) function  ms  (or something equivalent)
> > > available in some  R  package? I am trying to get an Splus
> > > program to work with R. The piece of  Splus  code is
> > > 
> > > ms.fit<-ms(~t(Y-(X[,1] * alf + X[,2] * bet)^delta)%*%
> > >            covariance.matrix.inverse%*%
> > >            (Y-(X[,1] * alf + X[,2] * bet)^delta),
> > >            sys.parent(0) , list(alf=5,bet=0.5), trace = F)
> > 
> > There are several different optimizers available in R now but none of
> > them are exactly the same as the ms optimizer in S.  The nlm
> > optimizer has been available for a long time.  Recently Brian Ripley
> > added a variety of optimizers in the optim function.  Try
> >  ?optim
> > and
> >  ?nlm
> > 
> 
> Thanks for the answer; I just hoped for the _very_ simple 
> solution. Guess I have to write a function to minimize.

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)

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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