
R Under development (unstable) (2017-02-13 r72168) -- "Unsuffered Consequences"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> ## from Eric Weese
> library(bbmle)
Loading required package: stats4
> f <- function(x=2,a=1) x^2 - a
> f.g <- function(x,a) 2*x
> f.g2 <- function(x,a) c(2*x,0)
> options(digits=3)
> m1 <- mle2(f,fixed=list(a=1))
> m2 <- mle2(f,gr=f.g,fixed=list(a=1))
> m3 <- mle2(f,gr=f.g2,fixed=list(a=1))
> stopifnot(all.equal(coef(m1),coef(m2)))
> stopifnot(all.equal(coef(m1),coef(m3)))
> tt <- function(x) x@details$hessian
> stopifnot(all.equal(tt(m1),tt(m2),tolerance=1e-6))
> stopifnot(all.equal(tt(m1),tt(m3),tolerance=1e-6))
> 
> proc.time()
   user  system elapsed 
  1.992   0.128   2.122 
