Good afternoon Brian and thank you for getting back to me, much appreciated!
I have attached the sample data below. data as: "xts" "zoo" Weights calculated as df_w <- df[,1:3]/rowSums(df[,1:3]) > df Date FX Shares Commodities 2020-01-02 892 8,609 17,864 2020-01-03 9,971 10,454 3,478 2020-01-04 9,446 19,453 40,373 2020-01-05 - 7,362 15,760 35,030 2020-01-06 - 5,006 13,780 - 1,786 2020-01-07 - 3,760 757 - 34,151 2020-01-08 - 3,739 6,265 - 41,606 2020-01-09 - 5,589 22,874 - 23,932 2020-01-10 - 8,482 18,005 10,922 2020-01-11 - 4,884 2,465 25,374 2020-01-12 - 1,140 16,825 36,941 2020-01-13 - 4,341 1,413 17,187 2020-01-14 - 746 18,655 7,193 2020-01-15 - 497 - 20,688 - 30,418 2020-01-16 - 9,872 - 9,579 6,703 2020-01-17 6,011 - 11,616 16,286 2020-01-18 4,023 - 8,166 45,782 2020-01-19 5,446 - 23,821 26,343 2020-01-20 1,173 - 3,731 1,126 2020-01-21 3,858 - 17,266 27,975 2020-01-22 8,586 - 9,468 38,842 2020-01-23 467 11,088 19,451 2020-01-24 - 9,049 14,817 2,098 2020-01-25 - 2,324 23,952 35,510 2020-01-26 - 6,534 2,902 - 20,131 2020-01-27 - 1,641 7,147 - 6,921 2020-01-28 3,974 13,986 - 24,161 I have tested some functions from PerformanceAnalytics 1. table.Arbitrary(df, metrics=c("VaR","mean"), metricsNames=c("modVaR","mean"), p=.95) FX Shares Commodities Average Return -782.1784 4624.844 8569.309 Standard Deviation 5705.4913 13602.512 24924.682 Ok 2. table.Arbitrary(df, metrics=c("VaR", "ES"), metricsNames=c("Modified VaR","Modified Expected Shortfall")) VaR calculation produces unreliable result (risk over 100%) for column: 1 : 9603.44809651169 VaR calculation produces unreliable result (risk over 100%) for column: 1 : 19496.0283854767 VaR calculation produces unreliable result (risk over 100%) for column: 1 : 34970.4906301062, etc. FX Shares Commodities modVaR -1.0000 -1.000 -1.000 mean -782.1784 4624.844 8569.309 modVaR does not make sense. (well, the values are there, after "VaR calculation produces unreliable result (risk over 100%) for column: 1 : " Mean works fine. 3. table.Distributions, works fine. 4. table.DownsideRisk, give similar error as table.Arbitrary does above for VaR and ES. VaR calculation produces unreliable result (risk over 100%) for column: 1 : 8879.0654029 ES calculation produces unreliable result (risk over 100%) for column: 1 : 9460.7561265, .... etc FX Shares Commodities Historical VaR (95%) -1.000 -1.000 -1.000000e+00 Historical ES (95%) -1.000 -1.000 -1.000000e+00 Modified VaR (95%) -1.000 -1.000 -1.000000e+00 Modified ES (95%) -1.000 -1.000 -1.000000e+00 5. table.RollingPeriods and table.Stats, works fine. 6. chart.Histogram does not work, same error as above. 7. Expected Shortfall > # first do normal ES calc > ES(df, p=.95, method="historical") ES calculation produces unreliable result (risk over 100%) for column: 1 : 9460.7561265 ES calculation produces unreliable result (risk over 100%) for column: 2 : 22254.650985 ES calculation produces unreliable result (risk over 100%) for column: 3 : 37878.379905 FX Shares Commodities ES -1 -1 -1 > # now use modified Cornish Fisher calc to take non-normal distribution into > account > ES(df, p=.95, method="modified") ES calculation produces unreliable result (risk over 100%) for column: 1 : 10844.7485269339 ES calculation produces unreliable result (risk over 100%) for column: 2 : 22667.3644584819 ES calculation produces unreliable result (risk over 100%) for column: 3 : 40970.5338686356 FX Shares Commodities ES -1 -1 -1 When i use weights = df_w (df_w <- df[,1:3]/rowSums(df[,1:3])) i get the following error message. > ES(df, portfolio_method="component", weights = df_w) Error in ES(df, portfolio_method = "component", weights = df_w) : number of items in weights not equal to number of columns in R So my queation is as follows: 1. Can i use the following chart.* table.* with my data? - chart.Histogram, chart.Boxplot(df), chart.QQPlot(df), chart.VaRSensitivity(df), chart.BarVaR, ... 2. Do i calculate the weights (df_w) correctly? it does not seem to be the case. SHould i even include it? I would like to be able to visualise boxplots, Histograms with methods, VaRSensitivity and tables/stats per Assetclass and total. Without being able to understand how to solve this, there seems to be some tweek i miss at an initial state that might solve the "ES / VaR calculation produces unreliable result (risk over 100%) for column: 1(n) " Any guidance / hints would be greaT Wish you all a nice start to the week. Best Johan From: Brian G. Peterson<mailto:br...@braverock.com> Sent: den 5 februari 2021 02:58 To: Johan Palleschitz<mailto:pallesch...@outlook.com>; r-sig-finance@r-project.org<mailto:r-sig-finance@r-project.org> Subject: Re: [R-SIG-Finance] PnL data - PerformanceAnalytics / VaR/ES should work with a distribution of cash P&L as well as a distribution of returns. Can you present an example that isn't behaving as you expect it to? Regards, Brian On Wed, 2021-02-03 at 17:58 +0000, Johan Palleschitz wrote: Good evening all, I have PnL data in EUR that i want use for ES, VaR calculationw/reports, as described in the documentation. I have read the PerformanceAnalytics guideline, searched on SO but i do not find a solution that works for me. Any suggestion or indication where i should look would be very appreciated!! Have a nice evening!! Regards Johan _______________________________________________ R-SIG-Finance@r-project.org<mailto:R-SIG-Finance@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-finance&data=04%7C01%7C%7C0c54da22c98c449a18c408d8c979972a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637480871365848685%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=BN3HMvLaReZhzErKv8hXDkQDzWAd1ZhcXmZUPlgQzd0%3D&reserved=0> -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go. [[alternative HTML version deleted]] _______________________________________________ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.