StephQ
StephQ

Reputation: 2092

Kernel estimation of log-pdf

It's easy to plot a kernel estimate for the probability density function (pdf) of a random variable given an observation vector via:

plot(density(x))

I would like to do the same but for the log-pdf (log of the probability density function).

Upvotes: 4

Views: 240

Answers (1)

Karl
Karl

Reputation: 2019

You can do

d <- density(x)
plot(d$x, log(d$y), type="l")

or maybe you'd prefer

plot(d, log="y")

Upvotes: 3

Related Questions