plot_multivariate {aphylo}R Documentation

Multiavariate plot (surface)

Description

Multiavariate plot (surface)

Usage

plot_multivariate(
  fun,
  params,
  domain,
  sets,
  nlevels = 20,
  args = list(),
  plotfun = graphics::image,
  plot = TRUE,
  postplot = function(params, res) {
     points(params, cex = 2, pch = 3, col = "red")

    },
  mfrow = NULL,
  ...
)

Arguments

fun

A function that receives 2 or more parameters and returns a single number.

params

Numeric vector with the default parameters.

domain

(optional) Named list with as many elements as parameters. Specifies the domain of the function.

sets

(optional) Character matrix of size ⁠2 x # of combinations⁠. contains the names of the pairs to plot. If nothing passed, the function will generate all possible combinations as combn(names(params), 2).

nlevels

Integer. Number of levels.

args

List of named arguments to be passed to fun.

plotfun

Function that will be used to plot ⁠x,y,z⁠.

plot

Logical. When FALSE skips plotting.

postplot

Function to be called after plotfun. Should recieve a vector with the current parameters.

mfrow

Passed to graphics::par.

...

Further arguments passed to plotfun.

Value

A list of length length(sets), each with the following:

Examples

# Example: A model with less parameters
set.seed(1231)
x <- raphylo(20)
ans <- aphylo_mcmc(
  x ~ psi + mu_d + mu_s,
  control = list(nsteps = 1e3, burnin = 0)
  )

# Creating the multivariate plot (using by default image)
plot_multivariate(
  function(...) {
    ans$fun(unlist(list(...)), priors = ans$priors, dat = ans$dat, verb_ans = FALSE)
  },
  sets = matrix(c("mu_d0", "mu_d1", "psi0", "psi1"), ncol=2),
  params = ans$par
)

[Package aphylo version 0.3-3 Index]