tag:blogger.com,1999:blog-5049613389055921243.post7819443229257939951..comments2024-03-05T16:42:05.992+05:30Comments on We think therefore we R: Principal component analysis : Use extended to Financial economics : Part 2Shreyeshttp://www.blogger.com/profile/02952702110986035135noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5049613389055921243.post-77863498302942303402011-11-29T22:45:13.234+05:302011-11-29T22:45:13.234+05:30Madhav,
The problem, as I see it, is because you ...Madhav,<br /><br />The problem, as I see it, is because you have not specified how to read the "#N/A"'s in the data.(Note its "#N/A" and not just NA, which is spoiling the numbers)<br /><br />See if you dont specify in the beginning that the #N/A's are not to be treated as strings, R would assign weird numeric values to these #N/A's (which will basically screw up the calculations. For eg:<br /><br />> exchange <- read.csv("Exchange_rates.csv")<br />> class(exchange$Exchange.rates)<br />[1] "factor"<br /><br />> exchange <- read.csv("Exchange_rates.csv", na.strings="#N/A")<br />> class(exchange$Exchange.rates)<br />[1] "numeric"<br /><br />So you see that the (na.strings="#N/A") makes sure that<br />it doesn't treat the #N/A's as strings. I think this should solve your problem.Shreyeshttps://www.blogger.com/profile/02952702110986035135noreply@blogger.comtag:blogger.com,1999:blog-5049613389055921243.post-74074973291864160522011-11-29T22:00:35.860+05:302011-11-29T22:00:35.860+05:30I get funny results when I run the approx() functi...I get funny results when I run the approx() function for exchange rates. Specifically, the original data has<br /><br />Year Exchange.rates Change<br />1 01-Jan-01 46.66 -0.192884698<br />2 02-Jan-01 46.69 0.064294899<br />3 03-Jan-01 46.7 0.021417862<br />4 04-Jan-01 46.74 0.085653105<br />5 05-Jan-01 46.74 0<br />6 08-Jan-01 46.69 -0.106974754<br />7 09-Jan-01 46.66 -0.064253587<br />8 10-Jan-01 46.61 -0.107158165<br />9 11-Jan-01 46.63 0.042909247<br />10 12-Jan-01 46.61 -0.042890843<br />11 15-Jan-01 46.53 -0.171636988<br /><br /><br />and after running your code I get<br /><br /><br />Year Exchange.rates Change<br />1 01-Jan-01 506 -0.192884698<br />2 02-Jan-01 509 0.064294899<br />3 03-Jan-01 510 0.021417862<br />4 04-Jan-01 514 0.085653105<br />5 05-Jan-01 514 0<br />6 08-Jan-01 509 -0.106974754<br />7 09-Jan-01 506 -0.064253587<br />8 10-Jan-01 501 -0.107158165<br />9 11-Jan-01 503 0.042909247<br />10 12-Jan-01 501 -0.042890843<br />11 15-Jan-01 493 -0.171636988<br /><br /><br />Any idea what is happening to the Exchange.rate variable?MKhttps://www.blogger.com/profile/03144859563025317904noreply@blogger.comtag:blogger.com,1999:blog-5049613389055921243.post-84416602822447275162011-10-23T14:22:22.091+05:302011-10-23T14:22:22.091+05:30My apologies Andre, I have updated the link.
Than...My apologies Andre, I have updated the link.<br /><br />Thanks for pointing it out.Shreyeshttps://www.blogger.com/profile/02952702110986035135noreply@blogger.comtag:blogger.com,1999:blog-5049613389055921243.post-46895611546542058332011-10-23T13:51:10.274+05:302011-10-23T13:51:10.274+05:30Hello,
Thank you for the interesting article.
I w...Hello, <br />Thank you for the interesting article.<br />I want to replicate the exercise, but the links for exchange rates and MIBOR are the same.<br />Please can you fix this.<br />Thanks,<br />AndreAnonymousnoreply@blogger.com