0

I have the following data to import from CSV to an xts, as the date-price are inconsistent in the data seek to merge. For some dates there is no entry. When using merge/merge.xts there are a variety of errors below. What is best methodology?

Date          2y    Date         10y    Date       BankRate 
02/08/2016  0.21    02/08/2016  0.815   02/08/2016  0.5 
01/08/2016  0.164   01/08/2016  0.73    01/08/2016  0.5 
... 
09/06/2000  6.145   12/06/2000  5.108   05/01/2000  5.5 
08/06/2000  6.169   09/06/2000  5.118   04/01/2000  5.5 
07/06/2000  6.122   08/06/2000  5.162   03/01/2000  5.5 
  1. Using as.xts(read.zoo(...)) gives error index has 2621 bad entries at data rows: 3 4 8...
  2. Using

    grid <- read.csv("gridukyield.csv", header=T) 
    grid$Date <- as.Date(grid$Date, "%d/%m/%Y") 
    UK2y <- grid[,c("Date","X2y")] 
    UK2y <- as.zoo(UK2y)    
    

    gives error charToDate(x) string not in a unambiguous format

  3. Using

    dates <- xts(Date = seq(as.Date("2000-01-01"), as.Date("2016-08-01"), by='1 day')) 
    dates <- dates[isWeekday(dates)] 
    group <- merge(dates, UK2y, by="Date", all = T )   
    

    gives error improper length of one or more arguments to merge.xts

What is best methodology?

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
rrg
  • 655
  • 2
  • 6
  • 24
  • It's difficult to help you without a [reproducible example](http://stackoverflow.com/q/5963269/271616). We don't have your CSV file, so we can't try most of the code you've provided. The block of data in your question isn't comma-separated, and appears to have multiple Date columns. That might cause the issues in 1 and 2. The problem with your `merge.xts` call in 3 is that the `merge` generic does not define a `by` argument, and `merge.xts` doesn't have one. `merge.xts` always and only merges by the datetime index. – Joshua Ulrich Aug 03 '16 at 03:00
  • U may neglect the effect of the irregularity since the spacing of the observations may be the same for many observations, and hence not so highly irregular and also you may consider the fact that "transforming the data into equally spaced observations using linear interpolation can introduce a number of significant and hard to quantify biases". Ref: M. Scholes and J. Williams, “Estimating betas from nonsynchronous data”, Journal of Financial Economics 5: 309–327, 1977. http://www.sciencedirect.com/science/article/pii/0304405X77900411 I suggest you to ignore the dates where entries missing – Erdogan CEVHER Aug 03 '16 at 11:43

0 Answers0