kobeProb: kobeProb

Description Usage Arguments Value Examples

View source: R/kobe-funcs.R

Description

Calculates the probability of an obervations occurring in a 2D cell using HPDregionplot Given a sample calculates the bivariate region of highest marginal posterior density for two variables, using kde2d from MASS to calculate a bivariate density.

Usage

1
2
kobeProb(x, y, prob = c(0.5, 0.75, 0.95), n = 21, h = c(bandwidth.nrd(x),
  bandwidth.nrd(y)), lims = NULL, na.rm = FALSE)

Arguments

x

a vector

y

a vector

prob

probability levels

n

number of points at which to evaluate the density grid

h

bandwidth of 2D kernel smoother (previous default value was c(1,1), which worked poorly with some plots with very small scales; if not specified, defaults to values in kde2d)

lims

limits, specified as (x.lower,x.upper,y.lower,y.upper) (passed to kde2d)

na.rm

logical; if true, any NA and NaN's are removed from x before calculations

Value

a data.frame with three variables x, y coordinates of the grid points, vectors of length n. level contours corresponding to prob

Examples

1
2
3
4
5
## Not run: 
   y=rnorm(20)
   x  =rnorm(20)
   kobeProb(x,y)
## End(Not run)

kobe documentation built on May 30, 2017, 12:15 a.m.