R/Method-AssetClassAttribution.R

#'Method for Asset Class Attribution
#'

setGeneric(name = "AssetClassperformanceAttribution",
           def = function(object){
             standardGeneric("AssetClassperformanceAttribution")
           })
setMethod(f="AssetClassperformanceAttribution",
          signature = "AssetClassAttribution",
          definition = function(object){
            #Calculate Active Return
            AssetClass<-object@AssetClass
            PortfolioReturn<-object@PortfolioReturns
            Benchmark<-object@BenchmarkReturns

            ActiveReturn<-PortfolioReturn-Benchmark #Active Returns

            PortfolioWeight<-object@PortfolioWeights
            BenchmarkWeight<-object@BenchmarkWeights

            ExcessWeight<-PortfolioWeight-BenchmarkWeight #Active Weights

            #Attribute
            Allocationeffect <- (object@PortfolioWeights - object@BenchmarkWeights) * (object@BenchmarkReturns
                                                                                       - sum(object@BenchmarkWeights * object@BenchmarkReturns))

            SelectionEffect <- (object@PortfolioReturns - object@BenchmarkReturns) * object@BenchmarkWeights


            InteractionEffect <- (object@PortfolioWeights - object@BenchmarkWeights) *(object@PortfolioReturns
                                                                                       - object@BenchmarkReturns)
            # Form data frame for overal performance reports
            Performance <- data.frame(AssetClass = AssetClass,
                                      PortfolioReturn = PortfolioReturn,
                                      Benchmark = Benchmark,
                                      ActiveReturn = ActiveReturn,
                                      PortfolioWeight = PortfolioWeight,
                                      BenchmarkWeight = BenchmarkWeight,
                                      ExcessWeight = ExcessWeight,
                                      AllocationEffect = Allocationeffect,
                                      SellectionEffect = SelectionEffect,
                                      InteractionEffect = InteractionEffect)
            Performance
          }
)
CarlvinJerry/InnovaPerformanceAttribution documentation built on May 16, 2019, 7:26 a.m.