
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-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.

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.

> library(mcmc)
> 
> .morph.unmorph <- mcmc:::.morph.unmorph
> 
> ###########################################################################
> # basic functionality check, can morph.metro run?  Can we change the
> # transformation?
> set.seed(42)
> obj <- morph.metrop(function(x) dt(x, df=3, log=TRUE),
+                     100, 100, morph=morph(b=3))
> obj <- morph.metrop(obj, morph=morph(b=1))
> 
> obj <- morph.metrop(function(x) prod(dt(x, df=3, log=TRUE)),
+                     rep(100, 3), 100, morph=morph(p=3, b=1))
> obj <- morph.metrop(obj, morph=morph(r=1, p=3, b=1))
> 
> all.equal(class(obj), c("mcmc", "morph.metropolis"))
[1] TRUE
> 
> ###########################################################################
> # check .morph.unmorph
> obj <- list(final=10)
> outfun <- function(x) x
> m <- morph(p=3)
> obj <- .morph.unmorph(obj, m, outfun)
> all.equal(class(obj), c("mcmc", "morph.metropolis"))
[1] TRUE
> all.equal(sort(names(obj)),
+           sort(c("final", "morph", "morph.final", "outfun")))
[1] TRUE
> all.equal(c(obj$final, obj$morph.final), c(m$inverse(10), 10))
[1] TRUE
> all.equal(obj$outfun, outfun)
[1] TRUE
> all.equal(obj$morph, m)
[1] TRUE
> 
> proc.time()
   user  system elapsed 
  0.384   0.024   0.401 
