Re: [R] A data selection problem, suggestions highly appreciated

2004-05-27 Thread Heywood, Giles
First convert your dates to POSIXct, similar to the following:

tmp <- strptime("Jan1 18:56:24",format="%b%d %H:%M:%S")

[Here is a synthetic example for demo purposes] 

tmp <- seq.POSIXt(from=Sys.time(),length=100,by=1)

Then assign observations to 5s periods, and detect changes in these:

a5secperiod <- floor(as.numeric(tmp)/5)
lastinperiod <- tmp[which(diff(c(a5secperiod[1],a5secperiod))!=0)-1]

You may find it convenient to use the class 'its' in package 'its' (on CRAN)
to store the data and POSIX dates in a single object.

- Giles

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Yong Wang
> Sent: 26 May 2004 20:34
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: [R] A data selection problem, suggestions highly appreciated
> 
> 
> Hi, All
> I get following question:
> A data format like following:
> 
> [Day time  x y]
> 
> Jan1 18:56:24 x1 y1
> Jan1 18:56:25 x2 y2
> Jan1 18:56:27 x3 y3
> Jan1 18:56:28 x4 y4
> Jan1 18:56:31 x5 y5
> .
> .
> 
> what I wanna do is to partion the time interval by unit of 5 seconds.
> and pick x,y corresponding to the last time within that 
> interval. for the 
> example above,
> suppose 18:56:24 is the starting time, the time included in 
> the interval 
> will be up to 18:56:28, therefore I want to get x4 and y4, 
> and store them 
> somewhere else. 
> you might know this is the so called high frequency data. can 
> you let me 
> know how to do this partion and pick in R or Splus. 
> suggestions are really and hihgly appreciated. 
> 
> thank you very much.
> best regards
> yong
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Common principle components

2004-05-27 Thread Heywood, Giles
A typo in previous post: for latter, read former.  Apologies for the
confusion.


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Common principle components

2004-05-26 Thread Heywood, Giles
I was a lttle shocked to see your report of 3.2M hits for the correct
speeling versus 1.8M for incorrect.  This is a ratio of just 1.8!  Google
normally has much higher power than this, as the arbiter of spelling
disputes.

A quick google reveals however that your search is for
"principal"+"components" and principle"+"components".  A search for the
complete strings yields a ratio of 14.8 in favour of the latter.

- Giles



> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Spencer Graves
> Sent: 26 May 2004 17:25
> To: Martin Maechler
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] Common principle components
> 
> 
> Google just returned "about" 1.8M hits for "principle components" and 
> 3.2M hits for "principal components".  Evidently, 
> eigenvectors are more 
> your friend (pal) than a structure for the space by a factor 
> of roughly 
> 2 to 1. 
> 
> spencer graves
> 
> Martin Maechler wrote:
> 
> >>"JosePG" == J Pedro Granadeiro <[EMAIL PROTECTED]>
> >>on Wed, 26 May 2004 16:01:22 +0100 writes:
> >>
> >>
> >
> >JosePG> I am sorry for not being clear. I meant the 
> methods detailed in:
> >JosePG> Flury, B. (1988). Common Principle Components 
> Analysis and Related 
> >JosePG> Multivariate Models, John Wiley and Sons, New York. 
> >
> >Well, I'm 100% sure the title of that book is different
> >(and so should be your e-mail subject)
> >
> >Hint: Look carefully at the end of the 2nd word ...
> >
> >__
> >[EMAIL PROTECTED] mailing list
> >https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> >  
> >
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] irregular time series

2004-05-25 Thread Heywood, Giles
The 'its' class may be useful to you for printing/plotting/aligning data,
but as Jason says, you will need to rely on other packages such as stats
(formerly ts) for analysis, using the appropriate na.action.

Two comments in addition:

Since your data is (from what you say) regular but incomplete, you may well
not need any of the irregular time-series functionality.

In the frequency domain, I should point out that Nyquist frequency is a
reciprocal function of the sample interval (e.g. daily), not the sample
length.  Increasing the sample length will in fact reduce the sampling
interval in the frequency domain, leaving Nyquist unchanged.

- Giles

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Jason Turner
> Sent: 20 May 2004 16:45
> To: McClatchie, Sam (PIRSA-SARDI)
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: [R] irregular time series
> 
> 
> On Thu, May 20, 2004 at 02:23:46PM +0930, McClatchie, Sam 
> (PIRSA-SARDI) wrote:
> [long time series, broken in two with a gap]
> > I realise that I could just break each series into two segments and
> > cross-correlate with the shorter series, but I'd rather 
> deal with the whole
> > series to increase the nyquist frequency. I think the its 
> function in the
> > irregular time series package will create a class its 
> object with the right
> > time stamps, but can this then be used in the same was as a 
> class ts object
> > for the correlation and spectral anayses?  
> 
> its does some nice things for storing, plotting, and manipulating
> irregular time series, but isn't long on the analysis.
> 
> A few options:
> 
> 1) Analyze the two sub-series separately.
> 2) There is some merit to de-mean or de-trending both series,
> zero-padding the shorter so its length matches the longer, and 
> performing spectral analysis that way.  Frequencies near zero
> should be treated with suspicion, however.
> 3) Jim Lindsey has some continuous ARMA and Kalman filter routines
> on his site (Google for "Lindsey" and "rmutil", which is the
> name of one of those packages).
> 4) I'm working on an R version of the Lomb periodogram, which
> was built for irregular series, but I've no guarantees when I'll
> roll it up - rather busy most days.  I do remember seeing an S
> version on someone's web page, but that was a while ago, and it
> was the "direct" or slow method.
> 
> Hope that helps
> 
> Jason
> 
> 
> 
> -- 
> Indigo Industrial Controls Ltd.
> http://www.indigoindustrial.co.nz
> 64-21-343-545
> [EMAIL PROTECTED]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Aggregating frequency of irregular time series

2004-04-07 Thread Heywood, Giles
Although this thread might be considered closed by some, I'd like to make a
late contribution, since I contributed the extractIts() function in the
'its' package.

See ?itsSubset, which gives details of:

extractIts(x,weekday=FALSE,find=c("all","last","first"),period=c("week","mon
th"),partials=TRUE,select)

Using this on its own just 'extracts', using it with cumsum() and diff()
will give you 'sum' aggregation albeit with loss of precision.  As for
'average', it would depend how you want to average...

- Giles

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Ivan Alves
> Sent: 26 March 2004 21:51
> To: [EMAIL PROTECTED]
> Subject: [R] Aggregating frequency of irregular time series
> 
> 
> Thanks to all once again for the very useful suggestions. I will have 
> to teach myself some real S before tackling the writting of the 
> AggregateSeries-like function! I brace myself.
> 
> Kind regards,
> 
> Ivan
> ___
> Ivan Alves
> mailto://[EMAIL PROTECTED]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] get.hist.quote - is great, but am I missing something?

2004-03-03 Thread Heywood, Giles
If you wish to 'skip' (i.e. not interpolate) weekends in its, you could use
the following:

prices <- priceIts(instrument="ongc.ns")
plot(union(prices,newIts(start=start(prices),end=end(prices))),interp="none"
)

- Giles

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Dirk 
> Eddelbuettel
> Sent: 03 March 2004 16:02
> To: Ajay Shah
> Cc: r-help
> Subject: Re: [R] get.hist.quote - is great, but am I missing 
> something?
> 
> 
> On Wed, Mar 03, 2004 at 03:25:14PM +0530, Ajay Shah wrote:
> > I find it's just great to be able to say:
> > 
> >   library(tseries)
> >   x <- get.hist.quote(instrument="ongc.ns")
> > 
> > and it gets a full time-series of the stock price of the symbol
> > ongc.ns from Yahoo quote.
> > 
> > However, once my hopes have been raised by such beauty :-) I get
> > disappointed when I do
> > 
> > > plot(x)
> 
> a) use  plotOHLC(x), not plot(), PlotOHLC is also in tseries.
> 
> b) install the its package which has a variant of get.hist.quote
>and plots that too (though it doesn;t skip weekends)
>
> > and the annotation is horrible! The x axis is not labelled as
> > dates. The default plot method for get.hist.quote should be better,
> > no?
> 
> So are you intending to contribute one?  
>  
> > I was not able to understand the object returned by 
> get.hist.quote. If
> > I say:
> > 
> > > summary(x)
> >   Open High LowClose  
> >  Min.   : 397.0   Min.   : 407.3   Min.   :395.1   Min.   :398.4  
> >  1st Qu.: 494.2   1st Qu.: 501.4   1st Qu.:482.7   1st Qu.:490.4  
> >  Median : 614.9   Median : 622.7   Median :600.7   Median :610.0  
> >  Mean   : 615.6   Mean   : 627.1   Mean   :599.7   Mean   :611.9  
> >  3rd Qu.: 690.5   3rd Qu.: 707.4   3rd Qu.:676.2   3rd Qu.:691.5  
> >  Max.   :1000.0   Max.   :1000.0   Max.   :930.0   Max.   :944.9  
> >  NA's   :  88.0   NA's   :  88.0   NA's   : 88.0   NA's   : 88.0  
> > 
> > there is no mention of a 'time' variable. And, I'm unable to extract
> > (say) a vector of closing prices - e.g. if I say:
> > 
> > > closingprices <- x$Close
> > > print(closingprices)
> > NULL
> > 
> > I guess I'm not understanding the object that 
> get.hist.quote makes. In
> > general, what are R facilities for discovering what a given 
> object is?
> 
> class(x)
> str(x)
> ...
> 
> Hth, Dirk
> 
> -- 
> The relationship between the computed price and reality is as 
> yet unknown.  
>  -- From the 
> pac(8) manual page
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] match.call(), S4

2004-03-03 Thread Heywood, Giles
I get different results from match.call(), according to whether a function
is dispatched via S3 or S4.  Specifically, when I use S4 dispatch in the
following example, the match.call() result is of length 1 less than I
expect.  I need to add an extra comma to get the same results as in the S3
method.

example

setClass("foo",representation("matrix"))
setMethod("[", c("foo","ANY"),  function(x, i, j, drop, ...)
{
mc <- match.call()
print(mc)
xmat <- [EMAIL PROTECTED]
mc[[2]] <- as.name("xmat")
return(eval(mc))
}) 
"[.bar" <- function(x, ...)
{
mc <- match.call()
print(mc)
xmat <- unclass(x)
mc[[1]] <- as.name("[")
mc[[2]] <- as.name("xmat")
return(eval(mc))
}

ff <- new("foo",matrix(1:6,2,3))
bb <- structure(matrix(1:6,2,3),class="bar")

all.equal(bb[1],ff[1,]) #did not expect to need the extra comma in
ff[1,]
all.equal(bb[1,],ff[1,,])


--output


> all.equal(ff[1,],bb[1])
ff[i = 1]
[1] "length of mc is  3"
"[.bar"(x = bb, 1)
[1] "length of mc is  3"
[1] TRUE
> all.equal(bb[1,],ff[1,,])
"[.bar"(x = bb, 1, )
[1] "length of mc is  4"
ff[i = 1, ]
[1] "length of mc is  4"
[1] TRUE

--final comment

This is a minimal example.  I am really trying to invoke the method of the
superclass (matrix) after modifying the range arguments in the extract
method.  Perhaps there's a better way to do the whole kaboodle?

Thanks

- Giles
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor8.1
year 2003   
month11 
day  21 
language R  


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] get.hist.quote - is great, but am I missing something?

2004-03-03 Thread Heywood, Giles
If you use priceIts() in package 'its' (Irregular Time Series), you get
similar functionality, and the labelling etc in plot() recognizes the
calendar.  You can also do further calendar-based extractions, etc.

- Giles

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Ajay Shah
> Sent: 03 March 2004 09:55
> To: r-help
> Subject: [R] get.hist.quote - is great, but am I missing something?
> 
> 
> I find it's just great to be able to say:
> 
>   library(tseries)
>   x <- get.hist.quote(instrument="ongc.ns")
> 
> and it gets a full time-series of the stock price of the symbol
> ongc.ns from Yahoo quote.
> 
> However, once my hopes have been raised by such beauty :-) I get
> disappointed when I do
> 
> > plot(x)
> 
> and the annotation is horrible! The x axis is not labelled as
> dates. The default plot method for get.hist.quote should be better,
> no?
> 
> I was not able to understand the object returned by get.hist.quote. If
> I say:
> 
> > summary(x)
>   Open High LowClose  
>  Min.   : 397.0   Min.   : 407.3   Min.   :395.1   Min.   :398.4  
>  1st Qu.: 494.2   1st Qu.: 501.4   1st Qu.:482.7   1st Qu.:490.4  
>  Median : 614.9   Median : 622.7   Median :600.7   Median :610.0  
>  Mean   : 615.6   Mean   : 627.1   Mean   :599.7   Mean   :611.9  
>  3rd Qu.: 690.5   3rd Qu.: 707.4   3rd Qu.:676.2   3rd Qu.:691.5  
>  Max.   :1000.0   Max.   :1000.0   Max.   :930.0   Max.   :944.9  
>  NA's   :  88.0   NA's   :  88.0   NA's   : 88.0   NA's   : 88.0  
> 
> there is no mention of a 'time' variable. And, I'm unable to extract
> (say) a vector of closing prices - e.g. if I say:
> 
> > closingprices <- x$Close
> > print(closingprices)
> NULL
> 
> I guess I'm not understanding the object that get.hist.quote makes. In
> general, what are R facilities for discovering what a given object is?
> 
> -- 
> Ajay Shah   Consultant
> [EMAIL PROTECTED]  Department of Economic Affairs
> http://www.mayin.org/ajayshah   Ministry of Finance, New Delhi
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] an extension to 'array'

2004-03-02 Thread Heywood, Giles
1. I want to extend the 'array' class, and prefer to use S4 in the belief
that this is the best structure for new projects (as the documentation
says).  I actually wish to do something similar to the excellent Oarray by
Jonathan Rougier, but as this class is S3, I can't see how to extend it by
S4.  Am I being dumb here?

2. Seeking then to define a similar class in S4, my principal task is to
modify (extend?) a the extractor "[", modifying the range variables i,j,...
. I run into problems here, though.  The following is a minimal example:

setClass("xarray",representation("array"))

setMethod(f="[", 
   signature=signature("xarray","ANY"),  
   definition=function(x,i,j, ..., drop)
{
xcall <- match.call()
  #sundry processes on xcall to adjust i,j,...
y <- [EMAIL PROTECTED]
xcall[[2]] <- as.name("y")
eval(xcall)
}
   )   

foo <- new("xarray",array(1:24,c(2,3,4)))
foo[1,1,1,drop=FALSE]   #gives expected result i.e. a 1 in a [1,1,1] array
foo[1,1,,drop=FALSE]#again gives the expected result in a [1,1,4] array
foo[1,,,drop=FALSE] #gives an error "Error in y[i = 1, , drop = FALSE] :
incorrect number of dimensions"

Examining match.call() e.g. in the browser shows that there is indeed one
fewer argument than is required 

Called from: foo[1, , , drop = FALSE]
Browse[1]> xcall
y[i = 1, , drop = FALSE]

3.  I welcome input on this, at different levels, including the following:

- Is there a relatively small correction to what I have attempted and all is
well? 

- Can I instead extend the (perfectly functional) S3 class Oarray using S4?


- What is the better way to do what I am attempting in the last 3 lines of
my method i.e. a small tweak to the arguments of a S4 class using variables
from its slots, then calling the method for the superclass?

- Is there a package on CRAN which, by my studying it closely, I will gain
enlightenment?

I might also get RTFM, but then I *have* read quite a lot of the
documentation.  If the advice is RTFM, I request some assistance in finding
the correct sections for my question.  I would happily read the whole of the
Green Book if I could gain enlightenment from it, but there have been a lot
of changes since it was written.

Thanks

- Giles


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Irregular Time series

2003-12-04 Thread Heywood, Giles
You could take a look at the irregular time-series (its) package
on CRAN.  Your series is certainly irregular, and possibly a little
er... sparse.  Anyway, the following might get you started:

require(its)
mydates <- c("28.8.1962","27.6.1977","19.7.1989","26.6.1995","26.7.1999")
data <- matrix(1:5,dimnames=list(mydates,NULL))
its.format("%d.%m.%Y")
its(data)

- Giles

> -Original Message-
> From: annie lenox [mailto:[EMAIL PROTECTED]
> Sent: 04 December 2003 12:56
> To: [EMAIL PROTECTED]
> Subject: [R] Irregular Time series
> 
> 
> Could you please give me some help on R?
> 
> I have got an irregular time series: 28.8 1962, 27.6.1977, 19.7.1989, 
> 26.6.1995, 26.7.1999.
> For these days, I know the surface of different vegetal formations.
> 
> How may I use these data?
> 
> Is the pastecs library appropritate?
> 
> Thanks for your help
> 
> Virginie
> 
> _
> 
> http://search.fr.msn.ch
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Bollinger Bands

2003-11-25 Thread Heywood, Giles
You might wish to have a look at the 'its' package for irregular 
time-series on CRAN.  If your prices are in an its called price, 
then the following will get you on your way.  Since it is not efficient 
either in storage or computation, I offer it because it might be 
convenient for display, further processing, etc.

library(its)
...
tmp <- lagdistIts(diff(log(price)),1,20)
rollvol <- its(as.matrix(sqrt(apply(tmp,1,var,na.rm=TRUE

- Giles

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 24 November 2003 15:19
> To: [EMAIL PROTECTED]
> Subject: [R] Bollinger Bands
> 
> 
> Is there a way to create Bollinger Bands without having to loop on the
> observations of a time serie?
> 
> Any help appreciated
> 
> Thanks
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: Subject: RE: [R] Time plot question.

2003-11-13 Thread Heywood, Giles
The following is an example of a dataframe containing times, 
plus some numeric data.

foo <- c("12:39:26","12:40:22","12:41:19")
bar <- data.frame(foo,1:3,11:13)

Note that the times are of class 'factor' (their class changes
in this case, as they go into the dataframe).

To convert this dataframe to an 'its', do the following:

library(its)
its.format("%H:%M:%S")
its(x=as.matrix(bar[,2:3]),dates=as.POSIXct(x=strptime(as.character(bar[[1]]
),format=its.format(

Incidentally, since these types of question come up from
time to time on the R-help ist, I intend to expand the 'its' 
documentation with some more examples and illustrations, in
a 'vignette'.

- Giles

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 12 November 2003 18:09
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Subject: RE: [R] Time plot question.
> 
> 
> Hello,
> 
> Thank you for your reply. I am missing an intermediate step as
> 
> > plot( strptime( Time, format = "%H:%M:%S"), FreeMemory)
> Error in strptime(Time, format = "%H:%M:%S") :
> invalid `x' argument
> > plot( strptime( c(Time), format = "%H:%M:%S"), FreeMemory)
> Error in strptime(c(Time), format = "%H:%M:%S") :
> invalid `x' argument
> 
> does not work. My "Time" data is part of a data.frame. Do I need to
> "as.POSIXlt" this in some way, and if so, how?
> I will continue to work on this, and buy a suitable book on R 
> so as not to
> plague this excellent news group with such questions. I could 
> generate a
> sequence of ISODates similar to my
> data, but I would like to use the actual Time coordinates 
> instead. Here is
> my "Time" data below:
> 
> > Time
>   [1] 12:39:26 12:40:22 12:41:19 12:42:15 12:43:11 12:44:08 12:45:04
> 12:46:00
>   [9] 12:46:57 12:47:53 12:48:49 12:49:46 12:50:42 12:51:38 12:52:35
> 12:53:31
>  [17] 12:54:27 12:55:24 12:56:20 12:57:16 12:58:13 12:59:09 13:00:05
> 13:01:01
>  [25] 13:01:58 13:02:54 13:03:50 13:04:47 13:05:43 13:06:39 13:07:36
> 13:08:32
>  [33] 13:09:28 13:10:25 13:11:21 13:12:17 13:13:14 13:14:10 13:15:06
> 13:16:03
>  [41] 13:16:59 13:17:55 13:18:52 13:19:48 13:20:44 13:21:41 13:22:37
> 13:23:33
>  [49] 13:24:30 13:25:26 13:26:22 13:27:19 13:28:15 13:29:11 13:30:07
> 13:31:04
>  [57] 13:32:00 13:32:56 13:33:53 13:34:49 13:35:46 13:36:42 13:37:39
> 13:38:35
>  [65] 13:39:32 13:40:28 13:41:24 13:42:21 13:43:17 13:44:13 13:45:10
> 13:46:06
>  [73] 13:47:02 13:47:59 13:48:55 13:49:51 13:50:48 13:51:44 13:52:40
> 13:53:37
>  [81] 13:54:33 13:55:29 13:56:26 13:57:22 13:58:19 13:59:15 14:00:11
> 14:01:08
>  [89] 14:02:05 14:03:01 14:03:57 14:04:54 14:05:50 14:06:46 14:07:42
> 14:08:39
>  [97] 14:09:35 14:10:31 14:11:28 14:12:24 14:13:20 14:14:17 14:15:13
> 14:16:09
> [105] 14:17:06 14:18:02 14:18:58 14:19:55 14:20:51 14:21:47 14:22:44
> 14:23:40
> [113] 14:24:36 14:25:32 14:26:29 14:27:25 14:28:21 14:29:18 14:30:14
> 14:31:10
> 120 Levels: 12:39:26 12:40:22 12:41:19 12:42:15 12:43:11 12:44:08 ...
> 14:31:10
> >
> 
> Enjoying a little "R and R",
> 
> John
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Calendar Time Series

2003-11-12 Thread Heywood, Giles
I'm not sure what a calendar time series is, but it may be helpful
to consider it as an irregular time series, depending on what 
analysis or display you are wanting to do.  As you say, there are
packages (including 'its') for this purpose.

- Giles

> -Original Message-
> From: Brian Beckage [mailto:[EMAIL PROTECTED]
> Sent: 11 November 2003 16:34
> To: [EMAIL PROTECTED]
> Subject: [R] Calendar Time Series
> 
> 
> Hello,
> 
> Does R have any facilities for calendar time series?  I'm working 
> with a 40 year long, daily time series and I would like to have each 
> datum associated with a calendar date.  I searched the R website and 
> found several new packages for irregular time series but none for cts.
> 
> By the way, I just installed 1.8.0 on Mac OSX and the installation 
> was effortless!  I also very much like having the option of using R 
> on the Mac with Aqua or X11.  Thanks to all who have contributed to 
> the R project!
> 
> Thanks for your help,
> Brian
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] ts vs. POSIX

2003-10-29 Thread Heywood, Giles
Well, I'm not sure I understand the question exactly, 
but you might want to have a look at the package 'its', 
as Achim said.

A practical example might look like:

You have a .csv file as follows (I have chosen the date
format at random).

,x,y
Monday 08-Sep-2003,1,11
Monday 15-Sep-2003,2,22
Monday 22-Sep-2003,3,33
Monday 29-Sep-2003,4,44

Then the following reads the data into an 'its' object

require(its)
its.format("%A %d-%b-%Y")
xy <- its(readcsvIts("c:/temp/weekly.csv"))

>From there on it depends what you want to do - 'its' 
class inherits from matrix, which may be a useful 
property.

- Giles

> -Original Message-
> From: Jason Turner [mailto:[EMAIL PROTECTED]
> Sent: 28 October 2003 23:55
> To: Erin Hodgess
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] ts vs. POSIX
> 
> 
> Erin Hodgess wrote:
> > What if I have a time series which is collected every 
> Monday, please?
> > 
> > What is the proper way to use the start option within the ts command
> > in order to indicate that this is Monday data, please?
> > 
> 
> ts objects don't directly support dates.  There is some provision for 
> monthly data, but this isn't the same as uniform, 
> across-the-board date 
> support.  What they do have is a start time, a deltat, and frequency 
> (observations per period).  The main reason to use ts objects *isn't* 
> the date/time handling, but for the nice functions (acf, 
> spectrum, etc) 
> you can use for regularly spaces time samples.
> 
> For weekly data, I'd use one of the following approaches 
> (assuming the 
> series starts in the first Monday of 2003):
> 
> 1)
> # dates in a year,week format
>  > foo <- ts(1:100,start=c(2003,1),frequency=52)
> 
> or
> 
> 2)
> # dates as numeric representation of POSIXct objects
> foo <- 
> ts(1:100,start=as.numeric(as.POSIXct("2003-1-6")),deltat=60*60*24*7)
>  > start(foo)
> [1] 1041764400
>  > end(foo)
> [1] 1101639600
>  > last <- end(foo)
>  > class(last) <- "POSIXct"
>  > last
> [1] "2004-11-29 New Zealand Daylight Time"
> 
> (2) depends on as.numeric(POSIXct.object) giving a sensible, 
> single-digit answer.  This is not guaranteed.  It works today, but 
> nobody promised this approach would work tomorrow.
> 
> Hope that helps.
> 
> Cheers
> 
> Jason
> -- 
> Indigo Industrial Controls Ltd.
> http://www.indigoindustrial.co.nz
> 64-21-343-545
> [EMAIL PROTECTED]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] High frequency time-series

2003-10-22 Thread Heywood, Giles
You may find the irregular time-series (its) package on CRAN 
helpful.  

If your raw data were in a csv file thus:

x
april 26 2002 15:00:00  1.1
april 26 2002 15:15:00  1.2
april 26 2002 15:30:00  1.3
april 26 2002 15:45:00  1.4

Then you could read it in thus:

require("its")
its.format("%B %d %Y %H:%M:%S")
x <- its(readcsvIts("c:/temp/mydata.csv"))

If on the other hand you already have the times in POSIX
form, it is slightly simpler e.g.
 
x <- its(xmat,POSIXdate)

 Giles

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 22 October 2003 14:10
> To: r-help r-help
> Subject: [R] High frequency time-series
> 
> 
> Having to collect hourly electricity loads and 
> quarter-of-an-hour electricity production data for some years 
> I think that the tidiest way of doing it is to resort to ts 
> but I don't know how to define such a frequency starting from 
> a set date.
> 
> Leafing through r-help mail archives I've found this *ALMOST* 
> satisfactory message:
> ==
> .
>  > I have a series of hourly rainfall and quarterly flow 
> > measurements (i.e. 4 times an hour) of a catchment
> 
> > Maybe time series are easier, but in 
> > 
> > ts(data = NA, start = X,... 
> > 
> > X should be a number or a vector. how does this coresponds to a 
> > data and hour (e.g. april 26,2002, 15:00:00)? 
> 
> 
> If your observations are equidistant, e.g. you've got 24 hourly 
> measurements per day, you could do something like this for the above 
> example: 
> 
> 
> R> rain <- ts(rain, start = c(26, 15), freq = 24) 
> R> flow <- ts(flow, start = c(26, 15), freq = 96) 
> ...
> 
> 
> But how does R know that we are speaking of a timeseries 
> starting from April 26, 2002 and not, say, Feb 26, 2000?
> There's some piece of info missing in the answer.
> 
> Am I correct?
> Please help.
> 
> Ciao from Rome
> 
> Vittorio
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] ts - unit conversion

2003-09-30 Thread Heywood, Giles
Financial data, as you point out, is generally irregular, which is
in essence what prompted the devlopment of the irregular time-series
(its) package, which is posted on CRAN (v0.1.2 posted today, incidentally).
In the its class, the time-stamps of the rows of a matrix are represented 
using the POSIXct class, so irregularity can be represented accurately.

Inspection of get.hist.quote() shows that it would be quite straightforward
to adapt it to return an 'its'.  I would do so myself, but have no
spare time in the short term to do this (and I'm behind a proxy/firewall
which seems to complicate matters).

Giles

> -Original Message-
> From: michaell taylor [mailto:[EMAIL PROTECTED]
> Sent: 30 September 2003 16:51
> To: [EMAIL PROTECTED]
> Subject: [R] ts - unit conversion
> 
> 
> 
> I've been using R for a while, but now find myself needing to 
> understand
> time-series objects for a short course I am teaching.  I am putting
> together some daily financial datasets for illustration, but 
> having some
> trouble in aggregating the data to months or weeks. I am getting a
> "cannot change frequency from 1 to 12" message.  
> 
> I am not sure that aggregation is where I want to go anyway.  Assuming
> for the moment that I had one full year of data, I would like the
> observations to relate to real months with various numbers of 
> days, not
> simply 1/12th of a year.  It is unclear to me how sophisticated the
> aggregator is in this regard.
> 
> I have V&R but it seems there may be some SPlus/R differences 
> here. Any
> suggestions for documents that addresses these issues would be
> wonderful.  Thanks.
> 
> > ibm <- get.hist.quote('ibm',start='2003-01-01')
> trying URL
> `http://chart.yahoo.com/table.csv?s=ibm&a=11&b=31&c=2002&d=8&e
> =28&f=2003&g=d&q=q&y=0&z=ibm&x=.csv'
> Content type `application/octet-stream' length unknown
> opened URL
> 
> downloaded 8990 bytes
> 
> time series starts 2002-12-30
> time series ends   2003-09-25
> 
> Just to check what I have
> 
> > attributes(ibm)
> $dim
> [1] 270   4
> 
> $dimnames
> $dimnames[[1]]
> NULL
> 
> $dimnames[[2]]
> [1] "Open"  "High"  "Low"   "Close"
> 
> 
> $tsp
> [1] 37621 37890 1
> 
> $class
> [1] "mts" "ts"
> 
> Attempting to pull monthly means .
> 
> > aggregate(ibm,12,mean)
> Error in aggregate.ts(ibm, 12, mean) : cannot change 
> frequency from 1 to
> 12
> 
> I thought perhaps I had a non-integer number of months in the 
> data which
> may be causing problems.
> 
> > length(ibm)
> [1] 1080
> > 1080/12
> [1] 90
> >
> 
> Alternatively...making the data coordinate to real months...
> > ibm <- get.hist.quote('ibm',start='2003-01-01',end='2003-08-31')
> trying URL
> `http://chart.yahoo.com/table.csv?s=ibm&a=11&b=31&c=2002&d=7&e
> =30&f=2003&g=d&q=q&y=0&z=ibm&x=.csv'
> Content type `application/octet-stream' length unknown
> opened URL
> ...
> downloaded 8082 bytes
> 
> time series starts 2002-12-30
> time series ends   2003-08-28
> > aggregate(ibm,12,mean)
> Error in aggregate.ts(ibm, 12, mean) : cannot change 
> frequency from 1 to
> 12
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Date on x-axis of xyplot

2003-09-23 Thread Heywood, Giles
One thing you could do is to use the 'its' (irregular time-series) 
package on CRAN.

e.g. using a trivial dataset

require(its)
its.format("%Y-%m-%d") #defines text format of dates in dimnames
df <- data.frame(1:3,(1:3)^2)
dimnames(df) <- list(c("2003-01-03","2003-01-06","2003-01-07"),letters[1:2])
plot(its(as.matrix(df)),type="p")

or more simply

mat <-
structure(1:6,dim=c(3,2),dimnames=list(c("2003-01-03","2003-01-06","2003-01-
07"),letters[1:2]))
plot(its(mat),type="p")

Clearly plot does not provide the same functionality as the 
beautifully crafted xyplot of lattice, but dates do get handled
as an abcissa. Incidentally the implementation of 'its' uses the 
POSIXct class, but this is largely encapsulated.

Giles

> -Original Message-
> From: Charles H. Franklin [mailto:[EMAIL PROTECTED]
> Sent: 17 September 2003 04:00
> To: [EMAIL PROTECTED]
> Subject: [R] Date on x-axis of xyplot
> 
> 
> xyplot doesn't seem to want to label my x-axis with dates but 
> instead puts
> the day-number for each date.
> 
> begdate is the number of days since January 1, 1960 and was initially
> created by
> 
> library(date)
> 
> ...
> 
> polls$begdate<-mdy.date(begmm,begdd,begyy)
> 
> I create a new dataframe (pollstack) which includes begdate. 
> In the process
> begdate seems to lose its date attribute so I redo it as:
> 
> > pollstack$begdate<-as.date(pollstack$begdate)
> 
> after which
> 
> > attach(pollstack)
> > summary(pollstack)
>begdate   pct  names
>  First :15Nov2002   Min.   : 0.000   Clark   : 54
>  Last  :10Sep2003   1st Qu.: 2.000   Dean: 54
> Median : 5.000   Edwards : 54
> Mean   : 6.991   Gephardt: 54
> 3rd Qu.:12.000   Graham  : 54
> Max.   :29.000   Kerry   : 54
>  (Other) :216
> >
> 
> And all seems well.
> 
> But xyplot continues to use day number on the x-axis. My 
> plots are created
> by
> 
>  print(xyplot(pct ~ begdate | names, pch=2, cex=.2,
>prepanel = function(x, y) prepanel.loess(x, y, span = 1),
>main="2004 Democratic Primary Race",
>xlab = "Date of Survey",
>ylab = "Percent Support",
>panel = function(x, y) {
>panel.grid(h=-1, v= -1)
>panel.xyplot(x, y, pch=1,col=2,cex=.7)
>panel.loess(x,y, span=.65, lwd=2,col=4)
>   }, ) )
> 
> What am I missing?
> 
> Thanks!
> 
> Charles
> 
> 
> 
> /**
> ** Charles H. Franklin
> ** Professor, Political Science
> ** University of Wisconsin, Madison
> ** 1050 Bascom Mall
> ** Madison, WI 53706
> ** 608-263-2022 Office
> ** 608-265-2663 Fax
> ** mailto:[EMAIL PROTECTED] (best)
> ** mailto:[EMAIL PROTECTED] (alt)
> ** http://www.polisci.wisc.edu/~franklin
> **/
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Changing Tick Marks for Date Plots

2003-09-09 Thread Heywood, Giles
The way to control number of tickmarks in plot is via par(lab)

par(lab=c(5,5,7)) #the default
plot(rnorm(20),rnorm(20))
par(lab=3*c(5,5,7))
plot(rnorm(20),rnorm(20))

However this does not work for axis.POSIXct, which the function
called by the plot method for 'its'.  I am not sure why this is.

The parameter that controls the location of tickmarks and labels
in axis.POSIXct is 'at'.  You could use this, thus:

plot(x$dates,x$values,type="l",xaxt = "n")
axis.POSIXct(x = x$dates, side = 1,
at=x$dates[seq(1,500,100)],format="%b-%Y")

At present, the plot method for 'its' class does not pass the 'at'
parameter through to axis.POSIXct.  It could, and probably will, 
in the next version.  You could easily do the fix.

Giles

> -Original Message-
> From: Sean Carmody [mailto:[EMAIL PROTECTED]
> Sent: 09 September 2003 14:26
> To: [EMAIL PROTECTED]
> Subject: [R] Changing Tick Marks for Date Plots
> 
> 
> I have been experimenting with various approaches to
> plotting (irregular) time-series with reasonable
> success. One thing I have been able to do is change
> the number of tick marks on the axis. Consider the
> following simple example:
> 
> > x <- as.data.frame(matrix(ncol=2,nrow=500))
> > names(x) <- c("dates","values")
> > x$dates <- as.POSIXct(Sys.time()+1:500*86400)
> > x$values <- cumsum(rnorm(500
> > plot(x$dates,x$values,type="l")
> 
> The resulting plot only has two tick-marks: 2004 and
> 2005 (depending on today's date!). I have the same
> problem when I use the "its" library:
> 
> > library(its)
> > plot(as.its(x),format="%b-%Y")
> 
> Any suggestions would be greatly appreciated.
> 
> Regards,
> Sean.
> 
> 
> 
> http://search.yahoo.com.au - Yahoo! Search
> - Looking for more? Try the new Yahoo! Search
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Yet another beginner question

2003-09-09 Thread Heywood, Giles
The Irregular Time-Series ('its') class could be helpful to you.
The following does the basics of what you have asked.

require(its)
its.format("%m/%d/%y")
myits <-
its(cbind(reelect,new),dates=as.POSIXct(x=strptime(dateofpoll,format=its.for
mat(
plot(myits,type="b")

You may want to customise the graphical parameters using par(), 
or passing extra parameters to plot() which will pass them through,
to axis.POSIXct, for example to control the number of x-axis ticks, 
which in this example defaults to 1.

On the smoothing issue, I can't really help.

The its package is to be found on CRAN.

Giles
> -Original Message-
> From: Peter Flom [mailto:[EMAIL PROTECTED]
> Sent: 08 September 2003 22:08
> To: [EMAIL PROTECTED]
> Subject: [R] Yet another beginner question
> 
> 
> Thanks for all the help on my earlier questions.
> 
> 
> How do you plot a simple time series with unequal intervals?  I have
> the following
> 
> dateofpoll <- as.ts(c("6/1/02", "7/1/02", "10/1/02", "1/4/03",
> "1/25/03",
> "6/7/03", "7/16/03", "8/17/03", "9/4/03"))
> reelect <- c(51, 47, 49, 51, 49, 49, 46, 45, 40)
> new <- c(28, 32, 35, 36, 41, 38, 47, 48, 52)
> 
> what I'd like is to plot reelect and new  (maybe with smoothing) on a
> time scale, with the x axis labeled for date.
> 
> But I can't figure out how, despite looking at ?ts and various things
> there
> 
> 
> Thanks in advance
> 
> 
> 
> 
> 
> Peter L. Flom, PhD
> Assistant Director, Statistics and Data Analysis Core
> Center for Drug Use and HIV Research
> National Development and Research Institutes
> 71 W. 23rd St
> www.peterflom.com
> New York, NY 10010
> (212) 845-4485 (voice)
> (917) 438-0894 (fax)
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Plotting dates

2003-09-02 Thread Heywood, Giles

One solution is to use the Irregular Time-Series (its) package
on CRAN.

LeafDig <- cbind(Leafminers,Diglyphus)
dimnames(LeafDig)[[1]] <-
c("05/02/03","05/09/03","05/16/03","05/23/03","05/30/03","06/07/03","06/14/0
3")
require("its")
its.format("%m/%d/%y")
plot(its(LeafDig),format="%d %b %y")

You can select date format you require via the format parameter.

Giles

> -Original Message-
> From: Grum, Mikkel [IPGRI-SSA-Nairobi] [mailto:[EMAIL PROTECTED]
> Sent: 02 September 2003 15:01
> To: [EMAIL PROTECTED]
> Subject: [R] Plotting dates
> 
> 
> I'm trying to plot observations against observation dates and 
> getting julian
> dates along the x-axis:
> 
> library(date)
> Week<-as.date(c("05/02/03","05/09/03","05/16/03","05/23/03","0
> 5/30/03","06/0
> 7/03","06/14/03"))
> Leafminers<-c(0,2,5,10,4,6,5)
> Diglyphus<-c(0,0,4,5,7,3,1)
> LeafDig<-cbind(Week,Leafminers,Diglyphus)
> plot(LeafDig,ylim=c(0,20),main="Leafminers",ylab="Observed
> numbers",xlab="",adj=0,bty="l")
> points(Diglyphus,pch=2)
> lines(Diglyphus,lty=2)
> legend(1,18,c("Leafminers","Diglyphus"),lty=c(1,2),pch=c(1,2))
> 
> How do I get some more intelligeble dates, like the dates below (but
> preferably with 03, ie. 2May03) and spaced with the 
> observations (every
> seventh day) rather than the 10 days that seem to be default??
> 
> > Week
> [1] 2May3  9May3  16May3 23May3 30May3 7Jun3  14Jun3
> 
> ALSO, why won't the three last lines of code in the top 
> example show on the
> graph?
> 
> cheers,
> Mikkel
> 
> 
> 
> Mikkel Grum
> International Plant Genetic Resources Institute (IPGRI)
> Sub-Saharan Africa Group
> ***
> PO Box 30677
> 00100 Nairobi, Kenya
> Tel: +254 20 524505(direct)/524500(IPGRI)
> Fax: +254 20 524501(IPGRI)/524001(ICRAF)
> [EMAIL PROTECTED]
> www.ipgri.org
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] readcsvIts() to create irregular time series

2003-09-02 Thread Heywood, Giles
> BUT;
> 1. What can you do with informat and outformat? Is it the same as
> its.format() before the its function?

its.format() sets the text representation format for the times, and 
once set, it persists within that R session.  It is often convenient
to set this format just once in a session, since in many circumstances
multiple date formats serve only to distract and confuse.  The arguments
informat and outformat in readcsvIts override the value set in 
its.format().

> 
> 2. Can the its be plotted onto a ts? And is a correlation analysis in
> between the two objects possible?
> 

All regular time-series can be represented as irregular time-series -
they are a special case.  If you want to use both, I suggest you convert
your regular time-series to irregular.  You might for example use
seq.POSIXt(start,end,by="month") to set up a monthly series of POSIX
dates, and its(matrix,seq.POSIXt(start,end,by="month")) will then provide
you with a reglar time-series reprented as an 'its'.

Having done this, you can plot multiple series, which may not have the 
same time-stamps, using for example:

xy <- unionIts(Fire,its(matrix,seq.POSIXt(start,end,by="month"))
plot(xy)

> 2. Can the its be plotted onto a ts? And is a correlation analysis in
> between the two objects possible?

A meaningful calculation of correlation normally requires the data to be 
aligned in time (I can't think of an exception to this).  So you need to 
ensure that you have at least some of the data 'aligned' to start off with.
For example, if you have an 'its' x with daily data, and a 'its' y with
monthly data, you could do the following:

cor(intersectIts(x,y))

It relies for success on at least some subset of the POSIX dates being 
equal, i.e. that the result of the intersect operation is not NULL.

Giles


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] readcsvIts() to create irregular time series

2003-09-01 Thread Heywood, Giles
Jan

The function readcsvIts reads a csv file into a matrix.  To convert 
the matrix into an 'its', apply the its function to the matrix.

So for your example

its.format("%m/%d/%Y")
test­ <- its(readcsvIts(filename))
is.its(test)

"TRUE"

The its documentation for readcsvIts states incorrectly that an 'its'
object is returned, so your confusion is understandable.  I will correct 
this in the next release.

Giles

> -Original Message-
> From: Jan Verbesselt [mailto:[EMAIL PROTECTED]
> Sent: 01 September 2003 15:00
> To: [EMAIL PROTECTED]
> Subject: [R] readcsvIts() to create irregular time series
> 
> 
> Dear,
> 
> Thanks for the previous tips about 'its' for importing the following
> data.
> 5/10/1998,7
> 5/11/1998,5
> 5/12/1998,2
> 5/14/1998,1
> 5/15/1998,1
> 5/19/1998,1
> 5/20/1998,1
> 
> 1. When using the following command;
> test<-readcsvIts('Fires98.csv',informat=its.format("%m/%d/%Y")
> ,header=FA
> LSE)
> 
> the function reads in the data from the csv file as;
>V2
> 05/10/1998  7
> 05/11/1998  5
> 
> When testing if it's a its object
> is.its(test) 
> the result is FALSE.
> When do you use informat or outformat? 
> What goes wrong?
> 
> 2. When reading in the data as a table;
> m1 <- read.table('Fires98.csv',header=FALSE, sep=",", dec=".")
>   V1 V2
> 1  5/10/1998  7
> 2  5/11/1998  5
> ...
> test2 <- its(m1,dates=as.POSIXct(x=strptime(dimnames(V1)[[1]]
> format=its.format("%m/%d/%Y"))) )...Doesn't work! 
> 
> I have difficulties defining the first V1 column as its object.
> 
> Thanks in advance for helping me out,
> Jan
> 
> 
> 
> __
> __
> __
> Jan Verbesselt 
> Research Associate 
> Lab of Geomatics and Forest Engineering K.U. Leuven
> Vital Decosterstraat 102. B-3000 Leuven Belgium 
> Tel:+32-16-329750 
> Fax: +32-16-329760
> http://perswww.kuleuven.ac.be/~u0027178/VCard/mycard.php?name=janv
> http://gloveg.kuleuven.ac.be/
> __
> __
> __
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Read date for timeserie object

2003-08-21 Thread Heywood, Giles
You might wish to have a look at the package 'its' for handling irregular 
time-series.  If your data is in a .csv file, the following would enable
you to handle the data in its irregular form.

its.format("%m/%d/%Y")
readcsvIts(filename)

- Giles

> -Original Message-
> From: Jan Verbesselt [mailto:[EMAIL PROTECTED]
> Sent: 21 August 2003 15:07
> To: [EMAIL PROTECTED]
> Subject: [R] Read date for timeserie object
> Importance: High
> 
> 
> Dear all,
> 
> Is there a simple trick to read in data with the following format and
> create a Time Serie object of it?
> 
> Date  CountOfField2
> 5/10/1998 7
> 5/11/1998 5
> 5/12/1998 2
> 5/14/1998 1
> 5/15/1998 1
> 5/19/1998 1
> 5/20/1998 1
> 5/21/1998 1
> 5/24/1998 2
> 5/25/1998 1
> 5/26/1998 2
> 
> 2002
> ...
> 
> R should recognize that some dates are not available...(NA). You can
> define start and end date Ok, and frequency= 365 is ok...but is it
> possible that recognizes the gaps?
> 
> Thanks a lot,
> Jan
> 
> 
> __
> __
> __
> Jan Verbesselt 
> Research Associate 
> Lab of Geomatics and Forest Engineering K.U. Leuven
> Vital Decosterstraat 102. B-3000 Leuven Belgium 
> Tel:+32-16-329750 
> Fax: +32-16-329760
> http://perswww.kuleuven.ac.be/~u0027178/VCard/mycard.php?name=janv
> http://gloveg.kuleuven.ac.be/
> __
> __
> __
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] New package: irregular time-series (its)

2003-08-18 Thread Heywood, Giles
The issue to which you refer is putting 2 time-series with 
non-aligned (or inconsistent) time-stamps onto a consistent
basis.  There are four functions to assist with this task
in the 'its' package: try ?its-join for help.

In essence, there are two approaches to the problem.  In one,
you take the union of the time-stamps as the consistent basis,
and in the other approach, you take the intersection.  From
what you say, it sounds like you want the union, for your 
application, i.e. unionIts(A,B).  You can then apply the 
interpolation function of your choice.

If you have further points to raise, and the documentation 
provided does not answer your questions, I suggest you contact 
me off-list.

Regards

Giles Heywood

> -Original Message-
> From: Fan [mailto:[EMAIL PROTECTED]
> Sent: 17 August 2003 17:12
> To: Heywood, Giles
> Subject: Re: [R] New package: irregular time-series (its)
> 
> 
> Hello Giles,
> 
> Congratulations for your contributed R package its.
> 
> I'm having a little problem, and I'd like to know if
> there's already a general function in its (or other packages)
> to manage it. If not, could you add such function in its ?
> 
> With irregular time series, we need sometimes MERGE 2
> or several time series with different periodicities, for
> example:
> 
> A = a monthly regular time series (ex. end of each month),
> B = a business daily time series
> 
> To analyse conjointly the 2 series, one need to "expand"
> A to a daily series with the same time points as B (with
> the option of different method of interpolation: constant,
> linear, spline, etc.).
> 
> Thanks in advance
> --
> Fan
> 
> Heywood, Giles wrote:
> > I have uploaded to CRAN a new package named 'its' 
> (Irregular Time-Series).
> > It
> > implements irregular time-series as an S4 class, extending 
> the matrix class,
> > and records the time-stamp of each row in the matrix using 
> POSIX.  Print,
> > plot,
> > extraction, append, and related functionality are available.
> > 
> > Feedback and suggestions are welcome.
> > 
> > Giles Heywood
> > 
> > 
> > 
> **
>  
> > This is a commercial communication from Commerzbank AG.\ \ 
> T...{{dropped}}
> > 
> > ___
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-announce
> > 
> > __
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > 
> 
> 
> 


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] New package: irregular time-series (its)

2003-08-14 Thread Heywood, Giles
I have uploaded to CRAN a new package named 'its' (Irregular Time-Series).
It
implements irregular time-series as an S4 class, extending the matrix class,
and records the time-stamp of each row in the matrix using POSIX.  Print,
plot,
extraction, append, and related functionality are available.

Feedback and suggestions are welcome.

Giles Heywood


** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}

___
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-announce

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Import time series data with uneven dates

2003-06-19 Thread Heywood, Giles
A solution is at hand using the 'irts' (irreglar time-series) 
class from package tseries.

If your raw data is in a csv file, you could proceed as follows:

mydata <- read.csv(filename,header=TRUE)
basedate <- as.POSIXct(strptime("2003-01-01 00:00:00",format="%Y-%m-%d %X"))
rawdates <- basedate+(mydata[,1]-floor(mydata[,1]))*24*60*60*365 -60*60
truncdates <-
as.POSIXct(strptime(format.POSIXct(rawdates,format="%Y-%m-%d"),,format="%Y-%
m-%d"))
require(tseries)
x <- irts(time=truncdates,mydata[,2])

The result is an object of class 'irts'.

The format of the dates in your file is particularly unhelpful! If
they are available in a format recognisable by strptime, the above
could be simplified and made more robust.

Incidentally, I plan to post a slightly different 'its' (irregular 
time-series) package sometime soon.

Giles

> -Original Message-
> From: Ariel Andres [mailto:[EMAIL PROTECTED]
> Sent: 19 June 2003 03:51
> To: [EMAIL PROTECTED]
> Subject: [R] Import time series data with uneven dates
> 
> 
> I am trying to import a file of daily index closing prices in 
> business time
> which excludes weekends and holidays so deltat is not 
> constant. My file
> looks like the following:
> dateclose
> 2003.0055   47.05
> 2003.0082 45.71
> 2003.0164   43.45
> 2003.0192   42.96
> 2003.0219   44.56
> 2003.0247   42.99
> 2003.0274   42.28
> 2003.0356   41.74
> etc.
> 
> >From what I saw in the EuStockMarkets file, it appears that 
> they are also
> using years and fractions of years as the measure of time. 
> How do I read my
> file and still keep 'date' as the date?
> 
> Thanks!
> 
> A. Andres
> 95 Wellington St W
> Toronto, Ontario
> M5J 2N7
> 
> __
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


** 
This is a commercial communication from Commerzbank AG.\ \ This ... {{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help