R - Get joint probabilities from 2D Kernel Density Estimate -
i have 2 vectors s , v, , using function kde2d
, following plot of joint density:
using data, possible obtain empirical estimate of joint probability, in form p(s[i],v[j]) ?
in question how find/estimate probability density function density function in r suggested use approxfun
height of value in 1d kde plot. there way extend idea 2 dimensions?
one approach use bilinear interpolation of grid returned kde2d
:
library(fields) points <- data.frame(x=0:2, y=c(0, 5, 5)) interp.surface(k, points) # [1] 0.066104795 0.040191482 0.001943069
data:
library(mass) set.seed(144) x <- rnorm(1000) y <- 5*x + rnorm(1000) k <- kde2d(x, y)
Comments
Post a Comment