问题
I am trying to plot the beta-gumbel distribution using R(software) by the following, The genreal idea is that, in the pdf of beta distribution, instead of plugging in x, we use the cdf of gumbel instead. But I couldn't get the right plot.
x <- seq(-3, 3, length=100)
Fx = pgumbel(x,loc=0,scale=1)
y = dbeta(Fx,shape1=0.5,shape2=0.5)
plot(x, y, type="l", lty=2, xlab="x value", ylab="Density",ylim=c(0,1))
回答1:
I don't believe you when you say that you didn't use any add-on packages: pgumbel()
is not in base R. library("sos"); findFn("pgumbel")
finds it in a variety of places, I used the evd
package.
There are a couple of small issues here.
library("evd")
The main thing is that you want length=100
rather than by=100
(which gives you a single-element x
vector):
x <- seq(-3, 3, length=100)
The actual computations are OK:
Fx = pgumbel(x,loc=0,scale=1)
y = dbeta(Fx,shape1=0.5,shape2=0.5)
You need to change ylim
to be able to see what's going on. However, I also think you need to do something to account for the differential dx
in order to get a proper density function (that's more of a StackExchange than a StackOverflow question though).
par(las=1,bty="l") ## my personal preferences
plot(x, y, type="l", lty=2, xlab="x value", ylab="Density",ylim=c(0,40))
来源:https://stackoverflow.com/questions/16744596/how-to-make-a-plot-of-generalized-beta-distribution