R/methods-riskMeasures.R

#################################################################################
##
##   R package pmoments by Alexios Ghalanos Copyright (C) 2008
##   This file is part of the R package pmoments.
##
##   The R package pmoments is free software: you can redistribute it and/or modify
##   it under the terms of the GNU General Public License as published by
##   the Free Software Foundation, either version 3 of the License, or
##   (at your option) any later version.
##
##   The R package pmoments is distributed in the hope that it will be useful,
##   but WITHOUT ANY WARRANTY; without even the implied warranty of
##   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##   GNU General Public License for more details.
##
#################################################################################

psRisk<-function(A, b, a ,h, W, distribution,subdivisions=100000, ...)
{
	UseMethod("psRisk")
}

.psRisk<-function(A, b, a ,h, W, distribution, subdivisions=100000, ...)
{
	if(missing(W)){
		W = function(x) 1
		z=eval(parse(text=paste("function(x) ((abs(x-b)^a) * d",distribution,"(x, ...))",sep="")))
	} else{
		z=eval(parse(text=paste("function(x) ((abs(x-b)^a) * W(x,...) * d",distribution,"(x, ...))",sep="")))
	}
	ans = integrate(z, lower=-Inf,upper=A,subdivisions=subdivisions)
	ans= ans$value^h
	sol<-new("PSRISK", A = A,
			b = b,
			a = a,
			h = h,
			W = W,
			distribution = distribution,
			fit = list(...),
			riskMeasure = ans)
}

setMethod("psRisk", signature(A="numeric", b = "numeric",a = "numeric",h ="numeric",
				W = "missing",distribution = "vector"), .psRisk)

setMethod("psRisk", signature(A="numeric", b = "numeric",a = "numeric",h ="numeric",
				W = "function",distribution = "vector"), .psRisk)

Try the pmoments package in your browser

Any scripts or data that you put into this service are public.

pmoments documentation built on May 2, 2019, 4:42 p.m.