Nothing
#'@title Empirical likelihood multiplication factor (ELMF)
#'@description Compute the joint probability based on the sample and the independent case
#'@param mp Precipitation
#'@param mt Temperature
#'@param threp Threshold of precipitation (e.g., 50th percentile)
#'@param thret Threshold of temperature
#'@references Zscheischler, J. and S. I. Seneviratne (2017). Dependence of drivers affects risks associated with compound events. Science Advances, 3(6): e1700263.
#'@usage ELMF(mp,mt,threp,thret)
#' @return ELMF
#' @export
#' @examples
#'mp=matrix(rnorm(120,0,1),ncol=1)
#'mt=matrix(rnorm(120,0,1),ncol=1)
#'threp=20
#'thret=80
#'res<-ELMF(mp,mt,threp,thret)
#'
ELMF<-function(mp,mt,threp,thret)
{
n <- length(mp)
y <- matrix(data=0, nrow = n, ncol = 1)
# Define the matrix
y1 <- matrix(data=0, nrow = n, ncol = 1)
y2 <- matrix(data=0, nrow = n, ncol = 1)
# Spefify the Quantile (from percentile threp, threp)
p0 <- quantile(mp,threp/100)
t0 <- quantile(mt,thret/100)
for (i in 1:n)
{
if (mp[i]<=p0)
{
y1[i]= 1
}
if (mt[i]>t0)
{
y2[i]= 1
}
}
y <- y1*y2
# The empirical joint probability of the dependence case
pd=sum(y)/n
# The joint probability of the independence case
# For the dry-hot case (e.g., 20th for P and 80th for T gives a 0.04 probability)
pi=threp/100*(100-thret)/100
# The likelihood multiplication factor
lmf=pd/pi
res<-cbind(pd,pi,lmf)
return(res)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.