Learn R Programming

MLEcens (version 0.1-2)

plotDens1: Create a univariate density plot of the MLE

Description

This function creates a univariate density plot of the MLE. To be precise, it can plot the density (d/dx) P(X

Usage

plotDens1(mle, margin, int=NULL, col=1, lty=1, add=FALSE,
          xlim=NULL, ylim=NULL, xlab="", ylab="", main="", sub="")

Arguments

mle
List with elements 'p' and 'rects', as outputted by computeMLE.
margin
Indicates which margin should be plotted: 1 = x-margin, 2 = y-margin. So if margin=1, the MLE for (d/dx) P(X
int
This indicates the range of interest of the variable that was not chosen in margin. If int is specified, it should be of the form c(a,b), with a
col
Line color. The default value is 1="black".
lty
Line type. The default value is 1="solid".
add
Logical, indicating if the lines should be added to an existing plot. The default value is FALSE.
xlim
Range for the horizontal axis, defaulting to the range of x-coordinates (if margin=1) or y-coordinates (if margin=2) of the relevant corners of maximal interesctions.
ylim
Range for the vertical axis, defaulting to the range of values of the estimate.
xlab,ylab
Labels of the x- and y-axis. The default values are empty.
main
Title of the plot.
sub
Sub title of the plot.

Value

  • No value is returned.

concept

  • nonparametric maximum likelihood estimator
  • censored data

Details

In many cases we assign specific values to represent +/- infinity and (see, e.g., actg181). Note that these values determine the size of maximal intersections that extend to +/- infinity, and hence they also determine the value of the density at such maximal intersections. The value of the density at such maximal intersections is therefore meaningless.

See Also

computeMLE

Examples

Run this code
# Load example data:
data(ex)

# Compute the MLE:
mle <- computeMLE(ex)

# Bivariate density plot of the MLE:
#   Numbers represent the mass p in the maximal intersections
par(mfrow=c(2,2))
plotDens2(mle, xlim=range(ex[,1:2]), ylim=range(ex[,3:4]), 
 col="lightgray", main="Bivariate density plot of the MLE", 
 key=FALSE, numbers=TRUE)
plotRects(ex, add=TRUE)

# Univariate density plots of the MLE:

#   Plot of the marginal density of Y
plotDens1(mle, margin=2, xlim=range(ex[,3:4]), 
 main="Marginal density plot, 
 y-margin", xlab="y", ylab=expression(f[Y](y))) 

#   Plot of the marginal density of X 
plotDens1(mle, margin=1, xlim=range(ex[,1:2]), 
 main="Marginal density plot, 
 x-margin", xlab="x", ylab=expression(f[X](x)))

Run the code above in your browser using DataLab