[R] order() on vector with Inf's
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Thu Jan 23 08:16:03 CET 2003
On Thu, 23 Jan 2003, Murray Jorgensen wrote:
> I have a parameter vector, ibeta, and a corresponding vector of
> loglikelihoods, llbet. If llbet contains no NAs or Inf's then I can
> extract the best parameter by
>
> index <- order(-llbet)[1]
sort.list(llbet, decreasing=TRUE)[1]
would be better.
> beta <- ibeta[index]
or just max(beta, na.rm=TRUE).
> or similar. The argument na.last of order() allows me to fix this up
> even if llbet contains some NAs which I wish to ignore.
>
> Unfortunately my llbet contains Inf's, which are not points of infinite
> likelihood, if anything they should be -Inf's. Anyway na.last does not
> seem to help me with these. What should I do?
llbet[llbet==Inf] <- -Inf
should correct the problem, but why not correct the calculation?
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list