R/methods-PMU.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.
##
#################################################################################

pmUtility<-function(data,threshold,urc,lrc,lmoment=1,umoment=1)
{
	UseMethod("pmUtility")
}

.pmUtility<-function(data,threshold,urc,lrc,lmoment=1,umoment=1)
{
	x<-sort(data)
	lx<-x[x<=threshold]
	ux<-x[x>threshold]
	lans=-lrc*abs(lx-threshold)^lmoment
	uans=urc*(ux-threshold)^umoment
	utility<-c(lans,uans)
	ans<-new("PMU",
			data=data,
			threshold = threshold,
			urc = urc,
			lrc = lrc,
			lmoment = lmoment,
			umoment = umoment,
			utility = utility)
	return(ans)
}

setMethod("pmUtility",signature(data="vector"), .pmUtility)

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.