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

# Partial Co-Moments (Symmetric) Expectation Methods
pcmExpectation<-function(pme, corr, tail="lower", moment)
{
	UseMethod("pcmExpectation")
}

.pcmExpectation<-function(pme, corr, tail="lower", moment)
{
	if(class(pme)=="PME"){
		if(pme@datatype=="single") stop("you did not supply a valid PME object (only contains single data estimate)")
		x<-as.data.frame(pme)[,4]
		if(dim(corr)[2]!=length(x)) stop("correlation matrix width and partial moments do not appear to have the same length")
		m=pme@moment[1]
		tail = pme@tail[1]
	}
	else{
		x<-as.numeric(pme)
		m=moment
		tail = tail
	}
	threshold = pme@threshold
	cpm<-(x)%o%(x)*corr
	colnames(cpm)<-colnames(pme@data)
	rownames(cpm)<-colnames(pme@data)
	ans<-new("PCME",tail = tail,
			corr = corr,
			moment = m,
			pm = as.matrix(cpm))
	return(ans)
}

setMethod("pcmExpectation", signature(pme="PME"), .pcmExpectation)
setMethod("pcmExpectation", signature(pme="vector"), .pcmExpectation)

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.