1

I have problems with setting up multivariate time series data in R. My data set looks good when I import it to R with command, and it includes date and some variables:

data = read.table("dataset.txt", header=TRUE) 

When I try to get my variables out for VAR-estimations, I use following:

variable1   = ts(data$variable1, start = c(1999,2), frequency = 12)
variable2   = ts(data$variable2, start = c(1999,2), frequency = 12)

However, the object variable1 is different from data$variable1. Could someone help me with this?

My intention is to bind variables like

y = window(cbind(variable1, variable2), start=c(1999,3)) 

and then move on with VAR estimations, but I don't get this far as variables are not what they are supposed to be.

Edit: For example: data$variable1 gives the right values for variable1 but after ts(data$variable1)gives something that has nothing to do with my data

Sample of data:

            indpro_us   indpro_ea
1.2.1999    4,511755808 4,548599834
1.3.1999    4,513438595 4,561218298
1.4.1999    4,515985904 4,564348191
1.5.1999    4,523444813 4,564348191
1.6.1999    4,521834228 4,572646994
1.7.1999    4,52803965  4,578826211
1.8.1999    4,532080003 4,579852378
1.9.1999    4,528239464 4,584967479
1.10.1999   4,541301307 4,593097605
1.11.1999   4,54604313  4,597138014
1.12.1999   4,553642127 4,591071262
1.1.2000    4,553733723 4,59511985`

command:

indpro_us   = ts(data$indpro_us, start = c(1999, 2), frequency = 12)

"indpro_us" doesn't give me that data.

Adam Quek
  • 6,973
  • 1
  • 17
  • 23
Vilbur
  • 11
  • 3
  • 1
    It would be easier to help if you provided a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). You aren't very specific on what the differences are. Maybe you just need ` data = read.table("dataset.txt", header=TRUE, stringsAsFactors=FALSE)` but if you expect your data to be numeric then it's likely you have bad values in there. – MrFlick May 08 '17 at 21:39
  • Dear MrFlick, thank you for you comment. I wasn't specific enough. Here is a sample of my data, it is fully numeric. http://imgur.com/a/QcmeT – Vilbur May 08 '17 at 21:45
  • 1
    Those commas tell me R doesn't think they are numeric. Look at `sapply(data, class)`. I'm guessing those columns weren't imported as numeric. But to be sure, you should share data in a [reproducible format](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example); images of data aren't as helpful. – MrFlick May 08 '17 at 21:47
  • I added the data in a reproducible format now. Sorry for the inconvenience. You might be right about the commas instead of dots, I have to check that. – Vilbur May 08 '17 at 21:53
  • 1
    Well, a `dput()` would have been more helpful. But maybe `data = read.table("dataset.txt", header=TRUE, dec=",")` would work? I can't tell if your data is space or tab-delimited. Nor am I sure what locale is active on your machine. – MrFlick May 08 '17 at 21:56
  • MrFlick, BIG thank you! That solved my problem! adding dec="," was everything that I needed here. Thank you. – Vilbur May 08 '17 at 22:01

0 Answers0