Hi Hamid,
 
Not sure why would you need missing data, but you can definitely generate it:).

 

A few random thoughts:
 
First, you can generate all possible timestamps from the beginning to the end 
of the interval (skipping weekends and skipping the stamps when the markets are 
closed). Then for each of yours time series, you can check whether it has the 
missing timestamps.

 

To generate the full set of timestamps, you can use R of course - POSIXlt and 
POSIXct are the classes to take a look at. They both support arithmetic like 
adding seconds and IMO can be used together with any time series.

 

I also have a little C# program which generates timestamps in a given interval 
- let me know and I will send it to you. Then if you are using one of the time 
series packages in R (xts, zoo, etc) you can check whether a particular 
timestamp exists like:

 

if(length(gspc["2009-12-05"]) != 0) --- this will be true if the time series 
gspc has the date.

 

Regards,

Ivan
 
> Date: Sun, 13 Dec 2009 13:08:25 -0800
> From: shef...@googlemail.com
> To: r-help@r-project.org
> Subject: Re: [R] Need help to complete missing value (Date and Time) in Sp500 
> Data
> 
> 
> Hi uwe,
> here the example:
> 1) Dataset sp500 has values at 01.05.2008:
> 
> 30.04.2008 21:56;1.385,63;1.385,63;1.385,14;1.385,14;0
> 30.04.2008 21:57;1.385,67;1.385,67;1.384,48;1.384,48;0
> 30.04.2008 21:58;1.384,74;1.384,91;1.384,27;1.384,91;0
> 30.04.2008 21:59;1.385,05;1.385,81;1.385,05;1.385,08;0
> 01.05.2008 15:30;1.385,97;1.385,97;1.384,14;1.384,54;0
> 01.05.2008 15:31;1.384,61;1.385,30;1.384,61;1.385,30;0
> 01.05.2008 15:32;1.385,03;1.385,54;1.385,03;1.385,54;0
> 01.05.2008 15:33;1.386,01;1.386,01;1.385,56;1.385,83;0
> 01.05.2008 15:34;1.385,61;1.385,61;1.385,00;1.385,00;0
> 01.05.2008 15:35;1.384,72;1.385,29;1.384,72;1.385,12;0
> 01.05.2008 15:36;1.385,26;1.385,26;1.384,47;1.384,48;0
> 01.05.2008 15:37;1.384,11;1.384,11;1.383,89;1.383,89;0
> 01.05.2008 15:38;1.383,63;1.383,75;1.383,33;1.383,75;0
> 01.05.2008 15:39;1.383,90;1.384,29;1.383,76;1.383,76;0
> 01.05.2008 15:40;1.383,66;1.383,66;1.383,07;1.383,08;0
> 01.05.2008 15:41;1.383,16;1.383,39;1.383,16;1.383,31;0
> 01.05.2008 15:42;1.383,70;1.383,94;1.383,69;1.383,69;0
> 01.05.2008 15:43;1.384,11;1.385,12;1.384,11;1.385,12;0
> 01.05.2008 15:44;1.385,26;1.385,72;1.385,26;1.385,72;0
> 01.05.2008 15:45;1.385,83;1.386,78;1.385,83;1.386,78;0
> 01.05.2008 15:46;1.386,89;1.387,09;1.386,89;1.386,96;0
> 01.05.2008 15:47;1.386,74;1.386,94;1.386,73;1.386,73;0
> 
> 2) but in the dataset dax (because the 1.5 is not work day in Germany ) is
> missing all the minute data. (there are some of these days the data missing)
> 
> 30.04.2008 17:28;6.947,29;6.947,69;6.944,64;6.946,21;547.527
> 30.04.2008 17:29;6.945,92;6.948,49;6.945,10;6.945,83;888.986
> 02.05.2008 09:00;6.982,06;6.982,06;6.980,25;6.980,88;1.202.110
> 02.05.2008 09:01;6.980,08;6.980,75;6.971,93;6.971,93;367.080
> 02.05.2008 09:02;6.972,88;7.031,30;6.972,88;7.026,16;2.097.588
> 02.05.2008 09:03;7.026,72;7.029,12;7.024,96;7.027,16;373.875
> 02.05.2008 09:04;7.027,06;7.029,64;7.024,17;7.026,32;421.565
> 02.05.2008 09:05;7.026,32;7.026,67;7.022,40;7.025,08;490.090
> 02.05.2008 09:06;7.024,21;7.025,31;7.021,45;7.021,70;500.031
> 02.05.2008 09:07;7.021,72;7.022,31;7.015,32;7.015,76;486.933
> 02.05.2008 09:08;7.017,90;7.022,94;7.017,90;7.022,23;461.801
> 02.05.2008 09:09;7.022,23;7.022,55;7.018,54;7.018,99;593.412
> 
> 
> 
> Uwe Ligges-3 wrote:
> > 
> > 
> > 
> > Hamid wrote:
> >> Hi Uwe,
> >> yes you are right, but I just wanted to show the date format I use. The
> >> whole data is very huge (about 20000 rows).
> >> 
> >> Nevertheless I like first to find the missing dates/Times. Then put 0. I
> >> know they are some different approach to impute missing data, but for me
> >> is
> >> important to find a way to identify the missing gaps and then put the
> >> values
> >> (I think then it is not complicated to put other values instead of zero).
> >> Do you have any idea to find it out and put the values in ?
> > 
> > 
> > 
> > Well, the problem is that I cannot imagine how your "gaps" look like, 
> > hence I asked for the example. Please provide an example (just a few 
> > rows) of the data how it looks like and then how you want it to be 
> > afterwards.
> > 
> > That would be very helpful to allow readers of the list to respond.
> > 
> > Uwe Ligges
> > 
> > 
> > 
> >> Thanks in advance
> >> Hamid
> >> 
> >> Uwe Ligges-3 wrote:
> >>>
> >>>
> >>> Hamid wrote:
> >>>> Dear all,
> >>>> here my problem my be somone can help to solve this.
> >>>>
> >>>> I have tow timeseries from different stock market with different length
> >>>> (diff ca. 4000 )
> >>>> Now I would to add the missing times of the one of this series with
> >>>> proper
> >>>> time (they are minute data) and set the value to 0 since I need to have
> >>>> the
> >>>> same length for my calculation. 
> >>>>
> >>>> I tried to use the seq in R and merge but without success because of
> >>>> format
> >>>> of the date.
> >>>> My data of one vector i like to complete and extend to the length of
> >>>> the
> >>>> other vectors looks like:
> >>> Well, this seems to be very complete, hence no idea what you want to 
> >>> add, please specify a reproducible example.
> >>>
> >>> Uwe Ligges
> >>>
> >>>
> >>>
> >>>> Date;open;hight;low;close;Volume
> >>>> 02.04.2008 09:00;6.749,24;6.755,55;6.746,89;6.754,11;0
> >>>> 02.04.2008 09:01;6.754,70;6.754,70;6.748,13;6.749,55;0
> >>>> 02.04.2008 09:02;6.749,36;6.757,00;6.745,50;6.749,38;0
> >>>> 02.04.2008 09:03;6.748,08;6.753,84;6.748,08;6.753,84;0
> >>>> 02.04.2008 09:04;6.753,79;6.755,59;6.752,18;6.752,41;0
> >>>> 02.04.2008 09:05;6.753,23;6.753,23;6.748,17;6.748,47;0
> >>>> 02.04.2008 09:06;6.749,43;6.750,62;6.748,22;6.748,26;0
> >>>> 02.04.2008 09:07;6.748,26;6.748,89;6.745,54;6.745,54;0
> >>>> 02.04.2008 09:08;6.745,49;6.746,58;6.744,82;6.745,58;0
> >>>> 02.04.2008 09:09;6.745,62;6.745,98;6.741,47;6.741,55;0
> >>>> 02.04.2008 09:10;6.741,58;6.741,73;6.737,21;6.739,85;0
> >>>> 02.04.2008 09:11;6.739,10;6.742,81;6.738,24;6.742,53;0
> >>>> 02.04.2008 09:12;6.742,32;6.742,80;6.740,42;6.741,81;0
> >>>> 02.04.2008 09:13;6.741,84;6.744,78;6.741,84;6.744,60;0
> >>>> 02.04.2008 09:14;6.744,60;6.744,60;6.740,54;6.740,54;0
> >>>> 02.04.2008 09:15;6.740,45;6.740,67;6.736,32;6.737,68;0
> >>>> 02.04.2008 09:16;6.737,72;6.740,68;6.737,45;6.740,11;0
> >>>> 02.04.2008 09:17;6.740,04;6.746,34;6.740,04;6.746,34;0
> >>>> 02.04.2008 09:18;6.746,21;6.750,64;6.746,21;6.749,99;0
> >>>> 02.04.2008 09:19;6.750,61;6.752,95;6.749,07;6.750,69;0
> >>>> 02.04.2008 09:20;6.750,82;6.751,01;6.748,20;6.750,74;0
> >>>> 02.04.2008 09:21;6.750,57;6.752,98;6.748,62;6.752,98;0
> >>>> 02.04.2008 09:22;6.752,74;6.756,24;6.752,74;6.753,84;0
> >>>> 02.04.2008 09:23;6.753,90;6.755,51;6.752,70;6.753,05;0
> >>>>
> >>>> Thanks in advance for any help!
> >>>> H.
> >>> ______________________________________________
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>>
> >>
> > 
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> > 
> > 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/Need-help-to-complete-missing-value-Date-and-Time-in-Sp500-Data-tp962671p963123.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

                                          
_________________________________________________________________


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to