Learn R Programming

secr (version 4.6.10)

LLsurface: Plot Likelihood Surface

Description

LLsurface is a generic function to calculate log likelihood over a grid of values of two coefficients (beta parameters) from a fitted model and optionally make an approximate contour plot of the log likelihood surface.

A method is provided for secr objects.

Usage

LLsurface(object, ...)

# S3 method for secr LLsurface(object, betapar = c("g0", "sigma"), xval = NULL, yval = NULL, centre = NULL, realscale = TRUE, plot = TRUE, plotfitted = TRUE, ncores = NULL, ...)

Value

A matrix of the log likelihood evaluated at each grid point (rows x, columns y), invisibly if plot = TRUE. Failed evaluations return NA.

Arguments

object

fitted model, secr object output from secr.fit

betapar

character vector giving the names of two beta parameters

xval

vector of numeric values for x-dimension of grid

yval

vector of numeric values for y-dimension of grid

centre

vector of central values for all beta parameters

realscale

logical. If TRUE input and output of x and y is on the untransformed (inverse-link) scale.

plot

logical. If TRUE a contour plot is produced

plotfitted

logical. If TRUE the MLE from object is shown on the plot (+)

ncores

integer number of threads for parallel processing

...

other arguments passed to contour

Details

centre is set by default to the fitted values of the beta parameters in object. This has the effect of holding parameters other than those in betapar at their fitted values.

If xval or yval is not provided then 11 values are set at equal spacing between 0.8 and 1.2 times the values in centre (on the `real' scale if realscale = TRUE and on the `beta' scale otherwise).

Contour plots may be customized by passing graphical parameters through the ... argument.

Setting ncores = NULL uses the existing value from the environment variable RCPP_PARALLEL_NUM_THREADS (see setNumThreads).

Examples

Run this code

if (FALSE) {

LLsurface(secrdemo.CL, xval = seq(0.16,0.40,0.02),
    yval = 25:35, nlevels = 20)

## now verify MLE
## click on MLE and apparent `peak'
if (interactive()) {
    xy <- locator(2)
    LLsurface(secrdemo.CL, xval = xy$x, yval = xy$y, plot = FALSE)
}

}

Run the code above in your browser using DataLab