Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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))
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
138 views
Welcome To Ask or Share your Answers For Others

1 Answer

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))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...