|
I am trying to run some Rmetrics code (e.g. feasiblePortfolio,
frontierPortfolio) using data that is already set up as expected returns and a variance/covariance matrix. The fPortfolio documentation suggests that the "data" argument to portfolioData is "a time series or a named list, containing either a series of returns or named entries ?mu? and ?Sigma? being mean and covariance matrix." Yet when I try to run this on code like this (example in mail archives) : #install.packages("MBESS") #for cor2cov mu <- c( 0.1, 0.08, 0.065) sigma <- c( 0.18, 0.12, 0.09 ) correlationMatrix <- rbind( c( 1, 0.8, 0.9 ), c( 0.8, 1, 0.75), c( 0.9, 0.75, 1) ) covarianceMatrix <- cor2cov(correlationMatrix, sigma ) data = list( mu = mu, Sigma = covarianceMatrix ) frontier<-portfolioFrontier(data) I get the message Error: class(data) == "timeSeries" is not TRUE Now obviously I know what the error message means. But it suggests that I am overlooking something such as a parameter or that the doc is wrong. Further down in the documentation there is a description of this dataset Simulated Mean-Cov Data Set: This data is taken from chapter 1.3.2 in Scherer, M., Martin, R.D. (2005); Introduction To Modern Portfolio Optimization with NuOPT, S-PLUS and S+Bayes, Springer, Berlin. It is a list of covariance matrix and the return means of imaginary assets. It is an example set for learning about optimization. which suggests to mean that I am missing something. Can anyone tell me a) can I run the Rmetrics codes above using mu and Sigma and if so what parameters do I need to use or what do I need to do differently? b) where can I find the "Simulated Mean-Cov" dataset so that I can play with it and otherwise see if I have misformatted my inputs? Is there an example available that I can be pointed to which would show how it is used (and which would presumably answer question (a)? Thank you in advance for any advice, pointers, code, etc. And patience - most of all! Regards, Matt Considine _______________________________________________ [hidden email] 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. |
|
I did a simple test to read from csv file using the following commands:
getSymbols('GOOG')write.csv(file='test.csv', data.frame(GOOG) )getSymbols('test',src='csv')head(TEST) I am puzzled by the result that always show the same date which is 'today'.Any help on this will be greatly appreciated. thanks, Jun ===== result ===============2012-01-27 646.50 647.00 621.23 622.46 5822600 622.462012-01-27 629.75 633.80 616.91 623.14 4395600 623.142012-01-27 623.50 629.39 621.12 625.96 2400000 625.962012-01-27 631.22 632.89 626.50 629.64 1875200 629.642012-01-27 626.26 626.95 621.06 624.99 2307300 624.992012-01-27 631.98 631.98 625.68 628.58 1909300 628.582012-01-27 626.63 634.00 622.12 632.91 2761700 632.912012-01-27 640.99 640.99 631.46 639.57 6276500 639.572012-01-27 590.53 591.00 581.70 585.99 10576300 585.992012-01-27 586.00 588.66 583.16 585.52 3412900 585.522012-01-27 586.32 587.68 578.00 580.93 3055800 580.932012-01-27 577.51 578.71 566.38 569.49 4987700 569.492012-01-27 571.98 574.48 564.55 568.10 3226200 568.10 [[alternative HTML version deleted]] _______________________________________________ [hidden email] 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. |
|
Hi Jun,
Specifying the date format via setSymbolLookup fixes it. I'm not sure if there is a more general solution. setSymbolLookup(test=list(src="csv",format="%Y-%m-%d")) getSymbols('test',src='csv') Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com On Fri, Jan 27, 2012 at 7:40 PM, Jun Zhu <[hidden email]> wrote: > I did a simple test to read from csv file using the following commands: > getSymbols('GOOG')write.csv(file='test.csv', data.frame(GOOG) )getSymbols('test',src='csv')head(TEST) > I am puzzled by the result that always show the same date which is 'today'.Any help on this will be greatly appreciated. > thanks, > Jun > ===== result ===============2012-01-27 646.50 647.00 621.23 622.46 5822600 622.462012-01-27 629.75 633.80 616.91 623.14 4395600 623.142012-01-27 623.50 629.39 621.12 625.96 2400000 625.962012-01-27 631.22 632.89 626.50 629.64 1875200 629.642012-01-27 626.26 626.95 621.06 624.99 2307300 624.992012-01-27 631.98 631.98 625.68 628.58 1909300 628.582012-01-27 626.63 634.00 622.12 632.91 2761700 632.912012-01-27 640.99 640.99 631.46 639.57 6276500 639.572012-01-27 590.53 591.00 581.70 585.99 10576300 585.992012-01-27 586.00 588.66 583.16 585.52 3412900 585.522012-01-27 586.32 587.68 578.00 > 580.93 3055800 580.932012-01-27 577.51 578.71 566.38 569.49 4987700 569.492012-01-27 571.98 574.48 564.55 568.10 3226200 568.10 > > > > > [[alternative HTML version deleted]] > > > _______________________________________________ > [hidden email] 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. _______________________________________________ [hidden email] 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. |
|
On 27 January 2012 20:58, Joshua Ulrich <[hidden email]> wrote:
> Hi Jun, > > Specifying the date format via setSymbolLookup fixes it. I'm not sure > if there is a more general solution. > > setSymbolLookup(test=list(src="csv",format="%Y-%m-%d")) > getSymbols('test',src='csv') I had the same problem, it seems to be to make more sense if I can set the format via setDefaults('getSymbols.csv'.... having to set set the setSymbolLookup for each symbol is too much. Jim. _______________________________________________ [hidden email] 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. |
|
This post has NOT been accepted by the mailing list yet.
|
| Powered by Nabble | Edit this page |
