dc.PlotLogLikelihoodContours: Plot Log-Likelihood Contours

Description Usage Arguments Details See Also Examples

View source: R/dc.R

Description

Creates a set of contour plots, such that there is a contour plot for every pair of parameters varying.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dc.PlotLogLikelihoodContours(
  loglikelihood.fcn,
  predicted.params,
  ...,
  n.divs = 2,
  multiple.screens = FALSE,
  num.contour.lines = 10,
  zoom.percent = 0.9,
  allow.neg.params = FALSE,
  param.names = c("param 1", "param 2", "param 3", "param 4")
)

Arguments

loglikelihood.fcn

log-likelihood function to plot.

predicted.params

estimated parameters.

...

all additional arguments required by the log-likelihood function. For example, bgbb.rf.matrix.LL requires rf.matrix; pnbd.cbs.LL requires cal.cbs and hardie (defaults to TRUE); and bgnbd.cbs.LL requires cal.cbs.

n.divs

integer representing how fine-grained the contour plot is. A higher value will produce a higher resolution plot with smoother contour lines, but will take longer to plot. n.divs also affects the boundaries of the contour plot; see details.

multiple.screens

if TRUE, plots each contour plot on a separate R graphics window.

num.contour.lines

number of contour lines to plot in the window.

zoom.percent

determines boundaries of contour plot. See details.

allow.neg.params

if FALSE, the contour plot will not include negative values (see details). This should be set to false for the BG/BB and Pareto/NBD models.

param.names

a vector containing parameter names.

Details

For each contour plot, the non-varying parameters are kept constant at the predicted values.

The contour will extend out by (n.divs * zoom.percent) in both directions and both dimensions from the estimated parameter values. The exception is if allow.neg.params is FALSE. In this case, the contour plot will end at zero if it would have extended into negative parameter values.

The estimated parameter values will be indicated by the intersection of two red lines.

See Also

dc.PlotLogLikelihoodContour

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# **Example for BG/BB model:
data(donationsSummary)
rf.matrix <- donationsSummary$rf.matrix

# starting-point parameters
bgbb.startingparams <- c(1, 1, 0.5, 3)
# estimated parameters
bgbb.est.params <- bgbb.EstimateParameters(rf.matrix, bgbb.startingparams)

# set up parameter names for a more descriptive result
bgbb.param.names <- c("alpha", "beta", "gamma", "delta")

# plot-log likelihood contours:
dc.PlotLogLikelihoodContours(bgbb.rf.matrix.LL,
                             bgbb.est.params, 
                             rf.matrix = rf.matrix, 
                             n.divs = 5, 
                             num.contour.lines = 8, 
                             zoom.percent = 0.3, 
                             allow.neg.params = FALSE, 
                             param.names = bgbb.param.names)

# **Example for Pareto/NBD model:
data(cdnowSummary)
cbs <- cdnowSummary$cbs

# Speed up calculations:
cbs <- dc.compress.cbs(cbs)

# parameters estimated using pnbd.EstimateParameters
pnbd.est.params <- cdnowSummary$est.params

# set up parameter names for a more descriptive result
pnbd.param.names <- c("r", "alpha", "s", "beta")

# plot log-likelihood contours:
dc.PlotLogLikelihoodContours(pnbd.cbs.LL, 
                             pnbd.est.params, 
                             cal.cbs = cbs, 
                             hardie = TRUE,
                             n.divs = 5, 
                             num.contour.lines = 15, 
                             zoom.percent = 0.3, 
                             allow.neg.params = FALSE, 
                             param.names = pnbd.param.names)

# **Example for BG/NBD model:
data(cdnowSummary)
cbs <- cdnowSummary$cbs

# parameters estimated using bgnbd.EstimateParameters
bgnbd.est.params <- cdnowSummary$est.params

# set up parameter names for a more descriptive result
bgnbd.param.names <- c("r", "alpha", "s", "beta")

# plot log-likelihood contours:
dc.PlotLogLikelihoodContours(bgnbd.cbs.LL, 
                             bgnbd.est.params, 
                             cal.cbs = cbs, 
                             n.divs = 5, 
                             num.contour.lines = 15, 
                             zoom.percent = 0.3, 
                             allow.neg.params = FALSE, 
                             param.names = bgnbd.param.names)

BTYD documentation built on Nov. 18, 2021, 1:10 a.m.