Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dgaitplot

Plotting the GAIT Combo Density


Description

Plots a 1- or 2-parameter GAIT combo probability mass function.

Usage

dgaitplot(theta.p, fam = "pois", alt.mix = NULL, inf.mix = NULL,
    alt.mlm = NULL, inf.mlm = NULL, truncate = NULL,
    max.support = Inf, pobs.mix = 0, pobs.mlm = 0,
    pstr.mix = 0, pstr.mlm = 0, byrow.ai = FALSE,
    theta.a = theta.p, theta.i = theta.p, deflation = FALSE,
    plot.it = TRUE, new.plot = TRUE, offset.x = ifelse(new.plot, 0, 0.25),
    type.plot = "h", xlim = c(0, min(100, max.support + 2)),
    ylim = NULL, xlab = "", ylab = "Probability", main = "",
    cex.main = 1.2, posn.main = NULL,
    lty.p = "solid", lty.a.mix = "longdash", lty.a.mlm = "longdash",
    lty.i.mix = "dashed", lty.i.mlm = "dashed", col.p = "pink2",
    col.a.mix = "#007FFF", col.a.mlm = "blue",
    col.i.mix = "#3F00FF", col.i.mlm = "purple",
    col.t = "tan", cex.p = 1, lwd.p = NULL, lwd.a = NULL, lwd.i = NULL,
    iontop = TRUE, las = 0, lend = "round",
    axes.x = TRUE, axes.y = TRUE, Plot.trunc = TRUE, cex.t = 1,
    pch.t = 1, baseparams.argnames = NULL, ...)

Arguments

theta.p

Numeric, usually scalar but may have length 2. This matches with, e.g., lambda.p for Gaitpois. A length 2 example is c(mean.p, dispind.p) for Gaitgenpois1, in which case fam = "genpois1".

fam

Character, paste0("dgait", fam) should be a d-type function returning the PMF. The default is for the GAIT Poisson combo.

alt.mix, inf.mix, alt.mlm, inf.mlm

See Gaitpois and gaitpoisson.

truncate, max.support

See Gaitpois and gaitpoisson.

pobs.mix, pobs.mlm, pstr.mix, pstr.mlm, byrow.ai

See Gaitpois and gaitpoisson.

theta.a, theta.i

Similar to theta.p, and they should have the same length too.

deflation

Logical. Allow deflation?

plot.it

Logical. Plot the PMF?

new.plot, offset.x

If new.plot then plot is called. If multiple plots are desired then use offset.x to shift the lines.

xlim, ylim, xlab, ylab

See par and plot.default.

main, cex.main, posn.main

Character, size and position of main for the title. See title, par and plot.default. The position is used if it is a 2-vector.

lty.p, lty.a.mix, lty.a.mlm, lty.i.mix, lty.i.mlm

Line type for parent, altered and inflated. See par and plot.default.

col.p, col.a.mix, col.a.mlm, col.i.mix, col.i.mlm

Line colour for parent (nonspecial), altered and inflated values. See par and plot.default. Roughly, by default, the parent is pink, the altered are azure (blue) and the inflated are indigo (purplish/violet).

col.t

Point colour for truncated values, the default is "tan".

type.plot, cex.p

The former matches 'type' argument in plot.default. The latter is the size of the point if type.plot = "p" or type.plot = "b", etc.

lwd.p, lwd.a, lwd.i

Line width for parent, altered and inflated. See par and plot.default. By default par()\$lwd is used for all of them.

las, lend

See par.

iontop

Logical. Draw the inflated bars on top? The default is to draw the spikes on top, but if FALSE then the spikes are drawn from the bottom—this makes it easier to see their distribution.

axes.x, axes.y

Logical. Plot axes? See par and plot.default.

Plot.trunc, cex.t, pch.t

Logical. Plot the truncated values? If so, then specify the size and plotting character. See par and plot.default.

baseparams.argnames

Character string specifying the argument name for the generic parameter theta, e.g., "lambda" for gaitpoisson, By appending .p, there is an argument called lambda.p in dgaitpois. Another example is for gaitlog: "shape" appended with .p means that dgaitlog should have an argument called shape.p. This argument is optional and increases the reliability of the do.call call internally.

...

Currently unused but there is provision for passing graphical arguments in in the future; see par.

Details

This is meant to be a crude function to plot the PMF of the GAIT combo model. Some flexibility is offered via many graphical arguments, but there are still many improvements that could be done.

Value

A list is returned invisibly. The components are:

x

The integer values between the values of xlim.

pmf.z

The value of the PMF, by calling the d-type function with all the arguments fed in.

mid.pmf

For inflated values, the value where the spikes begin, which are at the same level as the scaled parent distribution. This is a convenient way to obtain them as it is quite cumbersome to compute manually. For non-inflated values, they are the value of pmf.z.

Note

This utility function may change a lot in the future.

Author(s)

T. W. Yee.

See Also

Examples

## Not run: 
i.mix <- seq(0, 25, by = 5)
mean.p <- 10 
dispind.p <- 8^2 / mean.p  # Var(Y) = dispind.p * mean.p
dgaitplot(c(mean.p, dispind.p), fam = "genpois1",
  alt.mix = i.mix + 1, inf.mix = i.mix, max.support = 33,
  pobs.mix = 0.1, pstr.mix = 0.1, lwd.p = 2, lwd.a = 2, lwd.i = 2) 
## End(Not run)

VGAM

Vector Generalized Linear and Additive Models

v1.1-5
GPL-3
Authors
Thomas Yee [aut, cre], Cleve Moler [ctb] (author of several LINPACK routines)
Initial release
2021-01-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.