m@ithiii_shiv@ m@iii@g oii y@hoo@com
2022-May-24 14:00 UTC
[R] How to improve accuracy of output?
Dear Forum In my code, I am trying to compute Value at risk. I have an issue as mentioned below: I have defined? options(digits = 14) But my output is something like>? df$price[1] 98.7185273? ? ? ? ?103.10265923? ............ However, if use Excel, I get values as 98.718527356108?103.10265923704 and so on. Is there any way I can improve on R output accuracy. Problem is If I use? options(digits = 20) I still get same prices as when I was using options(digits = 14) and on the other hand?my confidence level value, which should be equal to 0.99, gets distorted to 0.989999999999 impacting? Value at Risk value. Please guide Regards Maithreyi [[alternative HTML version deleted]]
I think you have to use print(df$price, digits = 14) On Tue, May 24, 2022, 10:01 maithili_shiva--- via R-help < r-help at r-project.org> wrote:> Dear Forum > In my code, I am trying to compute Value at risk. > I have an issue as mentioned below: > I have defined > > > options(digits = 14) > But my output is something like > > df$price > [1] 98.7185273 103.10265923 ............ > However, if use Excel, I get values as > 98.718527356108 103.10265923704 > and so on. > Is there any way I can improve on R output accuracy. > Problem is If I use > options(digits = 20) > I still get same prices as when I was using options(digits = 14) and on > the other hand my confidence level value, which should be equal to 0.99, > gets distorted to 0.989999999999 impacting Value at Risk value. > Please guide > Regards > Maithreyi > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Dear Maithreyi, You need to read FAQ 7.31. 0.99 and 0.9899999999999 are equivalent. And their difference is most likely not relevant. Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkelinx at inbo.be Havenlaan 88 bus 73, 1000 Brussel inbo.be /////////////////////////////////////////////////////////////////////////////////////////// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /////////////////////////////////////////////////////////////////////////////////////////// <inbo.be> Op di 24 mei 2022 om 16:01 schreef maithili_shiva--- via R-help < r-help at r-project.org>:> Dear Forum > In my code, I am trying to compute Value at risk. > I have an issue as mentioned below: > I have defined > > > options(digits = 14) > But my output is something like > > df$price > [1] 98.7185273 103.10265923 ............ > However, if use Excel, I get values as > 98.718527356108 103.10265923704 > and so on. > Is there any way I can improve on R output accuracy. > Problem is If I use > options(digits = 20) > I still get same prices as when I was using options(digits = 14) and on > the other hand my confidence level value, which should be equal to 0.99, > gets distorted to 0.989999999999 impacting Value at Risk value. > Please guide > Regards > Maithreyi > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hello, I cannot reproduce this print behavior, with digits=14, there are 14 digits printed. x <- c(98.718527356108, 103.10265923704) x #> [1] 98.71853 103.10266 old_dig <- options(digits = 14) x #> [1] 98.718527356108 103.102659237040 options(old_dig) Maybe there's something else going on? Hope this helps, Rui Barradas ?s 15:00 de 24/05/2022, maithili_shiva--- via R-help escreveu:> Dear Forum > In my code, I am trying to compute Value at risk. > I have an issue as mentioned below: > I have defined > > > options(digits = 14) > But my output is something like >> ? df$price > [1] 98.7185273? ? ? ? ?103.10265923? ............ > However, if use Excel, I get values as > 98.718527356108?103.10265923704 > and so on. > Is there any way I can improve on R output accuracy. > Problem is If I use > options(digits = 20) > I still get same prices as when I was using options(digits = 14) and on the other hand?my confidence level value, which should be equal to 0.99, gets distorted to 0.989999999999 impacting? Value at Risk value. > Please guide > Regards > Maithreyi > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.