zoo object -> ts object

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

zoo object -> ts object

nop27392
Dear all,

I obtained data from the net using

get.hist.quote(instrument = "^DJI", start = "1995-01-01", end = "2004-12-31",
                       quote = "Close")

as suggested n this discussion. The result is a zoo object. How to transform it
in time series object in order to perform log-return etc?

Thanks in advance
Vitor Teixeira

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: zoo object -> ts object

Achim Zeileis
On Thu, 18 May 2006 10:31:44 +0100 [hidden email] wrote:

> Dear all,
>
> I obtained data from the net using
>
> get.hist.quote(instrument = "^DJI", start = "1995-01-01", end =
> "2004-12-31", quote = "Close")
>
> as suggested n this discussion. The result is a zoo object. How to
> transform it in time series object in order to perform log-return etc?

If z is your "zoo" object:
z <- get.hist.quote(instrument = "^DJI", start = "1995-01-01",
  end = "2004-12-31 ", quote = "Close")
then you can do
  plot(diff(log(z)))

So why convert to another class?
See vignette("zoo") for more information on "zoo" and its relations to
other time series classes.

hth,
Z


> Thanks in advance
> Vitor Teixeira
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: zoo object -> ts object

Gabor Grothendieck
In reply to this post by nop27392
On 5/18/06, [hidden email] <[hidden email]> wrote:

> Dear all,
>
> I obtained data from the net using
>
> get.hist.quote(instrument = "^DJI", start = "1995-01-01", end = "2004-12-31",
>                       quote = "Close")
>
> as suggested n this discussion. The result is a zoo object. How to transform it
> in time series object in order to perform log-return etc?
>

In addition to what Achim already mentioned

- note the retclass= argument on get.hist.quote
- note that in addition to the vignette Achim mentioned there is a
second vignette
  vignette("zoo-quickref")
that specifically has examples of log returns.
- Ajay Shah's web site has some useful examples:
  http://www.mayin.org/ajayshah/KB/R/index.html

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance