[R] Joint distributions
Jorunn Slagstad
jorunn.slagstad at gmail.com
Thu Sep 18 10:28:56 CEST 2008
Dear R-help!
I need to draw contour lines in a plot of wave heights (Hs) versus peak
periods (Tp) showing the joint probabilities of 1-year wave heights~peak
periods, 10-year wave heights~peak periods and 100-year wave heights~peak
periods.
I've used the contourplot() function in the plot I've added in this mail.
You can use the added dataset "Rhelpdata.txt" to reproduce a similar plot:
D0=read.table("Rhelpdata.txt",header=TRUE)
library(lattice)
library(MASS)
x=D0$totaltp
y=D0$totalhm0
p1=1/(365*4)
Ps=c(p1,p1/10,p1/100)
contourplot(z~x+y,data=con2tr(kde2d(x,y,n=50)),xlim=c(0,32),ylim=c(0,16),xlab="Peak
period (sec)",ylab="Significant wave height
(m)",region=TRUE,fill=TRUE,at=Ps,labels=c("1yr","10yr","100yr"))
My problem is that I wish for the contour lines to extend to non-observed
return values. For ex. the 100-year value of wave heights is 15,5 m and 32,5
sec for peak periods. The contour lines are supposed to show "the worsed
expected sea-state" in 1- 10- and 100-year periods.
Is this possible to incorporate in the contourplot()-function?
My guess is that to add these contour lines I have to calculate the joint
distribution of the wave heights (Hs) and the peak periods (Tp), f(Hs,Tp),
and then calculate the q-probability contour lines from this distribution.
I know the distributions f(Hs) and f(Tp), which I have assumed to be
generalized Pareto distributed as
library(ismev)
library(evd)
Zh=5; Zt=10;
Tppars=gpd.fit(x,Zt)$mle
Hspars=gpd.fit(y,Zh)$mle
and so the return values of each parameter separately are calculated as:
yTp100=qgpd(1-p1/100,Zt,Tppars[1],Tppars[2])
yHp100=qgpd(1-p1/100,Zh,Hppars[1],Hppars[2])
My question are as followed:
1) Is there any function in R which can help me calculate a joint
distribution when the separate distributions are known?
or
2) Is there any way I can extend the contour lines in my plot to contain
values of the worsed expected sea-state during 100-years?
I am very grateful for reply!
Regards
Jorunn Slagstad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: contour1.pdf
Type: application/pdf
Size: 9320 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080918/5ae94a8c/attachment.pdf>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Rhelpdata.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080918/5ae94a8c/attachment.txt>
More information about the R-help
mailing list