具有多条密度曲线的叠加直方图用于广义帕累托分布
Overlay histogram with multiple density curves for generalized pareto distribution
我想为广义帕累托分布绘制具有多条密度曲线的叠加直方图。如您所见,密度曲线并不清晰可见。他们有办法说清楚吗?谢谢
library(eva)
data(lowestoft)
data = as.vector(lowestoft)
d1 = dgpd(data, 0, 31.38105, 10.15003)
d2 = dgpd(data, 0, 2.9431553, 0.6778055)
d3 = dgpd(data,0, 5.413916, 17.162103)
d4 = dgpd(data,0, 43.18705, 13.98005)
N = length(data)
allden = c(d1, d2, d3, d4)
settings = c(rep('d1', N), rep('d2', N),
rep('d3', N), rep('d4', N))
mydata = data.frame(x= rep(data, 4), allden = allden, Methods = settings)
ggplot(mydata, aes(x)) +
geom_histogram(aes(y = stat(density)), binwidth = 1, fill = "grey", color = "black")+
geom_line(aes(x = x, y=allden, color = Methods))
您可以做的一件事是为 geom_line
添加一个单独的缩放 y 轴,就像这样
library(eva)
data(lowestoft)
data = as.vector(lowestoft)
d1 = dgpd(data, 0, 31.38105, 10.15003)
d2 = dgpd(data, 0, 2.9431553, 0.6778055)
d3 = dgpd(data,0, 5.413916, 17.162103)
d4 = dgpd(data,0, 43.18705, 13.98005)
N = length(data)
allden = c(d1, d2, d3, d4)
settings = c(rep('d1', N), rep('d2', N),
rep('d3', N), rep('d4', N))
mydata = data.frame(x= rep(data, 4), allden = allden, Methods = settings)
coef <- 8
ggplot(mydata, aes(x,allden)) +
geom_histogram(aes(y = stat(density)), binwidth = 1, fill = "grey", color = "black") +
geom_line(aes(x = x, y=allden*coef, color = Methods)) +
scale_y_continuous(name="Histogram Axis",
sec.axis = sec_axis(trans~./coef, name='Line Axis'))
我想为广义帕累托分布绘制具有多条密度曲线的叠加直方图。如您所见,密度曲线并不清晰可见。他们有办法说清楚吗?谢谢
library(eva)
data(lowestoft)
data = as.vector(lowestoft)
d1 = dgpd(data, 0, 31.38105, 10.15003)
d2 = dgpd(data, 0, 2.9431553, 0.6778055)
d3 = dgpd(data,0, 5.413916, 17.162103)
d4 = dgpd(data,0, 43.18705, 13.98005)
N = length(data)
allden = c(d1, d2, d3, d4)
settings = c(rep('d1', N), rep('d2', N),
rep('d3', N), rep('d4', N))
mydata = data.frame(x= rep(data, 4), allden = allden, Methods = settings)
ggplot(mydata, aes(x)) +
geom_histogram(aes(y = stat(density)), binwidth = 1, fill = "grey", color = "black")+
geom_line(aes(x = x, y=allden, color = Methods))
您可以做的一件事是为 geom_line
添加一个单独的缩放 y 轴,就像这样
library(eva)
data(lowestoft)
data = as.vector(lowestoft)
d1 = dgpd(data, 0, 31.38105, 10.15003)
d2 = dgpd(data, 0, 2.9431553, 0.6778055)
d3 = dgpd(data,0, 5.413916, 17.162103)
d4 = dgpd(data,0, 43.18705, 13.98005)
N = length(data)
allden = c(d1, d2, d3, d4)
settings = c(rep('d1', N), rep('d2', N),
rep('d3', N), rep('d4', N))
mydata = data.frame(x= rep(data, 4), allden = allden, Methods = settings)
coef <- 8
ggplot(mydata, aes(x,allden)) +
geom_histogram(aes(y = stat(density)), binwidth = 1, fill = "grey", color = "black") +
geom_line(aes(x = x, y=allden*coef, color = Methods)) +
scale_y_continuous(name="Histogram Axis",
sec.axis = sec_axis(trans~./coef, name='Line Axis'))