<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-14139</id>
	<title>Nabble - Rmetrics</title>
	<updated>2009-11-28T08:14:19Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/Rmetrics-f14139.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Rmetrics-f14139.html" />
	<subtitle type="html">Mailing list for discussions relating to use of GNU R in 'finance', i.e. financial engineering, financial economics, empirical finance, computational finance,  Rmetrics home is &lt;a href=&quot;http://www.itp.phys.ethz.ch/econophysics/R/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26554488</id>
	<title>Re: WG: quantmod addTA() How to scale the y axis</title>
	<published>2009-11-28T08:14:19Z</published>
	<updated>2009-11-28T08:14:19Z</updated>
	<author>
		<name>Konrad Hoppe</name>
	</author>
	<content type="html">Hello Vince,
&lt;br&gt;&lt;br&gt;The whole code on that is the following:
&lt;br&gt;&lt;br&gt;install.packages(&amp;quot;quantmod&amp;quot;)
&lt;br&gt;library(quantmod)
&lt;br&gt;&lt;br&gt;from.dat &amp;lt;- as.Date(&amp;quot;01/01/03&amp;quot;, format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;to.dat &amp;lt;- as.Date(Sys.Date(), format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&lt;br&gt;getSymbols(&amp;quot;BOS3.DE&amp;quot;, src=&amp;quot;yahoo&amp;quot;, from = from.dat, to = to.dat)
&lt;br&gt;BOS3.DE &amp;lt;- adjustOHLC(BOS3.DE)
&lt;br&gt;chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=&amp;quot;addSMA(200)&amp;quot;, yrange=c(5,50))
&lt;br&gt;&lt;br&gt;&lt;br&gt;regards
&lt;br&gt;Konrad
&lt;br&gt;&lt;br&gt;&lt;br&gt;-----Ursprüngliche Nachricht-----
&lt;br&gt;Von: R. Vince [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rvince99@...&lt;/a&gt;] 
&lt;br&gt;Gesendet: Samstag, 28. November 2009 15:59
&lt;br&gt;An: Konrad Hoppe; 'Joshua Ulrich'
&lt;br&gt;Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;Betreff: Re: [R-SIG-Finance] WG: quantmod addTA() How to scale the y axis
&lt;br&gt;&lt;br&gt;Konrad,
&lt;br&gt;&lt;br&gt;Can you share your completed code on this with all? Thanks, R. Vince
&lt;br&gt;&lt;br&gt;----- Original Message ----- 
&lt;br&gt;From: &amp;quot;Konrad Hoppe&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;konradhoppe@...&lt;/a&gt;&amp;gt;
&lt;br&gt;To: &amp;quot;'Joshua Ulrich'&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;josh.m.ulrich@...&lt;/a&gt;&amp;gt;
&lt;br&gt;Cc: &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;&amp;gt;
&lt;br&gt;Sent: Saturday, November 28, 2009 9:36 AM
&lt;br&gt;Subject: Re: [R-SIG-Finance] WG: quantmod addTA() How to scale the y axis
&lt;br&gt;&lt;br&gt;&lt;br&gt;Thank you very much. I haven't seen that point, because I was unsure what
&lt;br&gt;the method plots.
&lt;br&gt;And the 'addSMA' is a good hint because as I told you I'm new to the package
&lt;br&gt;and actually don't know its whole functionality.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;Konrad
&lt;br&gt;&lt;br&gt;-----Ursprüngliche Nachricht-----
&lt;br&gt;Von: Joshua Ulrich [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;josh.m.ulrich@...&lt;/a&gt;]
&lt;br&gt;Gesendet: Samstag, 28. November 2009 15:28
&lt;br&gt;An: Konrad Hoppe
&lt;br&gt;Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;Betreff: Re: [R-SIG-Finance] WG: quantmod addTA() How to scale the y axis
&lt;br&gt;&lt;br&gt;Konrad,
&lt;br&gt;&lt;br&gt;There are no intersections because chartSeries() plots the unadjusted
&lt;br&gt;data and you're overlaying an average of the split and dividend
&lt;br&gt;adjusted series. &amp;nbsp;You need to adjust the raw data before charting.
&lt;br&gt;&lt;br&gt;BOS3.DE &amp;lt;- adjustOHLC(BOS3.DE)
&lt;br&gt;chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=&amp;quot;addSMA(200)&amp;quot;, yrange=c(5,50))
&lt;br&gt;&lt;br&gt;Note that &amp;quot;addSMA&amp;quot; replicates your &amp;quot;addTA(average(...))&amp;quot; call by using
&lt;br&gt;the SMA function from TTR.
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;Josh
&lt;br&gt;--
&lt;br&gt;&lt;a href=&quot;http://www.fosstrading.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.fosstrading.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Sat, Nov 28, 2009 at 7:33 AM, Konrad Hoppe &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;konradhoppe@...&lt;/a&gt;&amp;gt;
&lt;br&gt;wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Okay, I'm sorry. Now I've constructed an example. I would be very glad if
&lt;br&gt;&amp;gt; you can help me:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #--------------------------------------------------------#
&lt;br&gt;&amp;gt; install.packages(&amp;quot;quantmod&amp;quot;)
&lt;br&gt;&amp;gt; library(quantmod)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #use for example the 200-days average implemented by:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; average &amp;lt;- function(thisVector,grad){
&lt;br&gt;&amp;gt; res &amp;lt;- vector(length=length(thisVector))
&lt;br&gt;&amp;gt; for(i in grad:length(res)){
&lt;br&gt;&amp;gt; res[i] &amp;lt;- mean(thisVector[(i-(grad-1)):i], na.rm=T)
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; for(i in 1:(grad-1)){
&lt;br&gt;&amp;gt; res[i] &amp;lt;- NA
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; return(as.numeric(res))
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #construct the chartSeries plot and get the data:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; from.dat &amp;lt;- as.Date(&amp;quot;01/01/03&amp;quot;, format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&amp;gt; to.dat &amp;lt;- as.Date(Sys.Date(), format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&amp;gt; getSymbols(&amp;quot;BOS3.DE&amp;quot;, src=&amp;quot;yahoo&amp;quot;, from = from.dat, to = to.dat)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=NULL, yrange=c(5,50))
&lt;br&gt;&amp;gt; addTA(average(Ad(BOS3.DE),200), on=1,yrange=c(5,50))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # check the correctness of plot by the difference:
&lt;br&gt;&amp;gt; addTA(average(Ad(BOS3.DE),200)-Ad(BOS3.DE))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # but that looks quite different compared to:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; boss &amp;lt;- as.vector(Ad(BOS3.DE))
&lt;br&gt;&amp;gt; plot(boss, type=&amp;quot;l&amp;quot; , ylim=c(0,50))
&lt;br&gt;&amp;gt; par(new=T)
&lt;br&gt;&amp;gt; plot(average(boss,200) , type=&amp;quot;l&amp;quot; , ylim=c(0,50),ylab=&amp;quot;&amp;quot;)
&lt;br&gt;&amp;gt; #-------------------------------------------------------------#
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks in advance.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt; Konrad
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -----Ursprüngliche Nachricht-----
&lt;br&gt;&amp;gt; Von: Brian G. Peterson [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;brian@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Gesendet: Samstag, 28. November 2009 00:29
&lt;br&gt;&amp;gt; An: Konrad Hoppe
&lt;br&gt;&amp;gt; Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Betreff: Re: [R-SIG-Finance] quantmod addTA() How to scale the y axis
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Konrad Hoppe wrote:
&lt;br&gt;&amp;gt;&amp;gt; Dear mailinglist members,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I'm new to the quantmod package and I got some trouble with the addTA()
&lt;br&gt;&amp;gt;&amp;gt; method.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I want to add some indicators in the plot on position 1, hence behind the
&lt;br&gt;&amp;gt;&amp;gt; original data. But the indicators are plotted to low, they don't have any
&lt;br&gt;&amp;gt;&amp;gt; intersections with the raw-data.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; When I plot both lines with the standard plot function there are some
&lt;br&gt;&amp;gt;&amp;gt; intersections and also when I plot the difference between those two
&lt;/div&gt;series
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; on position 0, there are some intersections with the null-line. Hence I'm
&lt;br&gt;&amp;gt;&amp;gt; sure that the plot methods got the right data.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I've already tried the solution with setting the yrange (setting it for
&lt;br&gt;&amp;gt; all
&lt;br&gt;&amp;gt;&amp;gt; plots to the same range), but that doesn't work.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Does anybody have an idea?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; Yes, I have an idea.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please construct a reproducible example, and provide your code. It is
&lt;br&gt;&amp;gt; nearly impossible to &amp;quot;have an idea&amp;quot; when you've described things in
&lt;br&gt;&amp;gt; broad generalities. If you take the time to construct an example of
&lt;br&gt;&amp;gt; what you're talking about (disguise your data,create fake data, rename
&lt;br&gt;&amp;gt; your indicators, whatever), then I'm almost certain someone here can
&lt;br&gt;&amp;gt; help you.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Brian
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Brian G. Peterson
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;&amp;gt; Ph: 773-459-4973
&lt;br&gt;&amp;gt; IM: bgpbraverock
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26554488&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/WG%3A--quantmod-addTA%28%29-How-to-scale-the-y-axis-tp26553286p26554488.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26553677</id>
	<title>Re: WG: quantmod addTA() How to scale the y axis</title>
	<published>2009-11-28T06:36:58Z</published>
	<updated>2009-11-28T06:36:58Z</updated>
	<author>
		<name>Konrad Hoppe</name>
	</author>
	<content type="html">Thank you very much. I haven't seen that point, because I was unsure what
&lt;br&gt;the method plots. 
&lt;br&gt;And the 'addSMA' is a good hint because as I told you I'm new to the package
&lt;br&gt;and actually don't know its whole functionality.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;Konrad
&lt;br&gt;&lt;br&gt;-----Ursprüngliche Nachricht-----
&lt;br&gt;Von: Joshua Ulrich [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;josh.m.ulrich@...&lt;/a&gt;] 
&lt;br&gt;Gesendet: Samstag, 28. November 2009 15:28
&lt;br&gt;An: Konrad Hoppe
&lt;br&gt;Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;Betreff: Re: [R-SIG-Finance] WG: quantmod addTA() How to scale the y axis
&lt;br&gt;&lt;br&gt;Konrad,
&lt;br&gt;&lt;br&gt;There are no intersections because chartSeries() plots the unadjusted
&lt;br&gt;data and you're overlaying an average of the split and dividend
&lt;br&gt;adjusted series. &amp;nbsp;You need to adjust the raw data before charting.
&lt;br&gt;&lt;br&gt;BOS3.DE &amp;lt;- adjustOHLC(BOS3.DE)
&lt;br&gt;chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=&amp;quot;addSMA(200)&amp;quot;, yrange=c(5,50))
&lt;br&gt;&lt;br&gt;Note that &amp;quot;addSMA&amp;quot; replicates your &amp;quot;addTA(average(...))&amp;quot; call by using
&lt;br&gt;the SMA function from TTR.
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;Josh
&lt;br&gt;--
&lt;br&gt;&lt;a href=&quot;http://www.fosstrading.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.fosstrading.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Sat, Nov 28, 2009 at 7:33 AM, Konrad Hoppe &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;konradhoppe@...&lt;/a&gt;&amp;gt;
&lt;br&gt;wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Okay, I'm sorry. Now I've constructed an example. I would be very glad if
&lt;br&gt;&amp;gt; you can help me:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #--------------------------------------------------------#
&lt;br&gt;&amp;gt; install.packages(&amp;quot;quantmod&amp;quot;)
&lt;br&gt;&amp;gt; library(quantmod)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #use for example the 200-days average implemented by:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; average &amp;lt;- function(thisVector,grad){
&lt;br&gt;&amp;gt;        res &amp;lt;- vector(length=length(thisVector))
&lt;br&gt;&amp;gt;        for(i in grad:length(res)){
&lt;br&gt;&amp;gt;                res[i] &amp;lt;- mean(thisVector[(i-(grad-1)):i], na.rm=T)
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        for(i in 1:(grad-1)){
&lt;br&gt;&amp;gt;                res[i] &amp;lt;- NA
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        return(as.numeric(res))
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #construct the chartSeries plot and get the data:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; from.dat &amp;lt;- as.Date(&amp;quot;01/01/03&amp;quot;, format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&amp;gt; to.dat &amp;lt;- as.Date(Sys.Date(), format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&amp;gt; getSymbols(&amp;quot;BOS3.DE&amp;quot;, src=&amp;quot;yahoo&amp;quot;, from = from.dat, to = to.dat)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=NULL, yrange=c(5,50))
&lt;br&gt;&amp;gt; addTA(average(Ad(BOS3.DE),200), on=1,yrange=c(5,50))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # check the correctness of plot by the difference:
&lt;br&gt;&amp;gt; addTA(average(Ad(BOS3.DE),200)-Ad(BOS3.DE))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # but that looks quite different compared to:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; boss &amp;lt;- as.vector(Ad(BOS3.DE))
&lt;br&gt;&amp;gt; plot(boss, type=&amp;quot;l&amp;quot; , ylim=c(0,50))
&lt;br&gt;&amp;gt; par(new=T)
&lt;br&gt;&amp;gt; plot(average(boss,200) , type=&amp;quot;l&amp;quot; , ylim=c(0,50),ylab=&amp;quot;&amp;quot;)
&lt;br&gt;&amp;gt; #-------------------------------------------------------------#
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks in advance.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt; Konrad
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -----Ursprüngliche Nachricht-----
&lt;br&gt;&amp;gt; Von: Brian G. Peterson [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;brian@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Gesendet: Samstag, 28. November 2009 00:29
&lt;br&gt;&amp;gt; An: Konrad Hoppe
&lt;br&gt;&amp;gt; Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Betreff: Re: [R-SIG-Finance] quantmod addTA() How to scale the y axis
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Konrad Hoppe wrote:
&lt;br&gt;&amp;gt;&amp;gt; Dear mailinglist members,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I'm new to the quantmod package and I got some trouble with the addTA()
&lt;br&gt;&amp;gt;&amp;gt; method.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I want to add some indicators in the plot on position 1, hence behind the
&lt;br&gt;&amp;gt;&amp;gt; original data. But the indicators are plotted to low, they don't have any
&lt;br&gt;&amp;gt;&amp;gt; intersections with the raw-data.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; When I plot both lines with the standard plot function there are some
&lt;br&gt;&amp;gt;&amp;gt; intersections and also when I plot the difference between those two
&lt;/div&gt;series
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; on position 0, there are some intersections with the null-line. Hence I'm
&lt;br&gt;&amp;gt;&amp;gt; sure that the plot methods got the right data.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I've already tried the solution with setting the yrange (setting it for
&lt;br&gt;&amp;gt; all
&lt;br&gt;&amp;gt;&amp;gt; plots to the same range), but that doesn't work.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Does anybody have an idea?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; Yes, I have an idea.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please construct a reproducible example, and provide your code.  It is
&lt;br&gt;&amp;gt; nearly impossible to &amp;quot;have an idea&amp;quot; when you've described things in
&lt;br&gt;&amp;gt; broad generalities.  If you take the time to construct an example of
&lt;br&gt;&amp;gt; what you're talking about (disguise your data,create fake data, rename
&lt;br&gt;&amp;gt; your indicators, whatever), then I'm almost certain someone here can
&lt;br&gt;&amp;gt; help you.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;     - Brian
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Brian G. Peterson
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;&amp;gt; Ph: 773-459-4973
&lt;br&gt;&amp;gt; IM: bgpbraverock
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553677&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/WG%3A--quantmod-addTA%28%29-How-to-scale-the-y-axis-tp26553286p26553677.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26553618</id>
	<title>Re: WG: quantmod addTA() How to scale the y axis</title>
	<published>2009-11-28T06:27:49Z</published>
	<updated>2009-11-28T06:27:49Z</updated>
	<author>
		<name>Joshua Ulrich</name>
	</author>
	<content type="html">Konrad,
&lt;br&gt;&lt;br&gt;There are no intersections because chartSeries() plots the unadjusted
&lt;br&gt;data and you're overlaying an average of the split and dividend
&lt;br&gt;adjusted series. &amp;nbsp;You need to adjust the raw data before charting.
&lt;br&gt;&lt;br&gt;BOS3.DE &amp;lt;- adjustOHLC(BOS3.DE)
&lt;br&gt;chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=&amp;quot;addSMA(200)&amp;quot;, yrange=c(5,50))
&lt;br&gt;&lt;br&gt;Note that &amp;quot;addSMA&amp;quot; replicates your &amp;quot;addTA(average(...))&amp;quot; call by using
&lt;br&gt;the SMA function from TTR.
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;Josh
&lt;br&gt;--
&lt;br&gt;&lt;a href=&quot;http://www.fosstrading.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.fosstrading.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Sat, Nov 28, 2009 at 7:33 AM, Konrad Hoppe &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553618&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;konradhoppe@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Okay, I'm sorry. Now I've constructed an example. I would be very glad if
&lt;br&gt;&amp;gt; you can help me:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #--------------------------------------------------------#
&lt;br&gt;&amp;gt; install.packages(&amp;quot;quantmod&amp;quot;)
&lt;br&gt;&amp;gt; library(quantmod)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #use for example the 200-days average implemented by:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; average &amp;lt;- function(thisVector,grad){
&lt;br&gt;&amp;gt;        res &amp;lt;- vector(length=length(thisVector))
&lt;br&gt;&amp;gt;        for(i in grad:length(res)){
&lt;br&gt;&amp;gt;                res[i] &amp;lt;- mean(thisVector[(i-(grad-1)):i], na.rm=T)
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        for(i in 1:(grad-1)){
&lt;br&gt;&amp;gt;                res[i] &amp;lt;- NA
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        return(as.numeric(res))
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #construct the chartSeries plot and get the data:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; from.dat &amp;lt;- as.Date(&amp;quot;01/01/03&amp;quot;, format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&amp;gt; to.dat &amp;lt;- as.Date(Sys.Date(), format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;&amp;gt; getSymbols(&amp;quot;BOS3.DE&amp;quot;, src=&amp;quot;yahoo&amp;quot;, from = from.dat, to = to.dat)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=NULL, yrange=c(5,50))
&lt;br&gt;&amp;gt; addTA(average(Ad(BOS3.DE),200), on=1,yrange=c(5,50))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # check the correctness of plot by the difference:
&lt;br&gt;&amp;gt; addTA(average(Ad(BOS3.DE),200)-Ad(BOS3.DE))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # but that looks quite different compared to:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; boss &amp;lt;- as.vector(Ad(BOS3.DE))
&lt;br&gt;&amp;gt; plot(boss, type=&amp;quot;l&amp;quot; , ylim=c(0,50))
&lt;br&gt;&amp;gt; par(new=T)
&lt;br&gt;&amp;gt; plot(average(boss,200) , type=&amp;quot;l&amp;quot; , ylim=c(0,50),ylab=&amp;quot;&amp;quot;)
&lt;br&gt;&amp;gt; #-------------------------------------------------------------#
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks in advance.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt; Konrad
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -----Ursprüngliche Nachricht-----
&lt;br&gt;&amp;gt; Von: Brian G. Peterson [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553618&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;brian@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Gesendet: Samstag, 28. November 2009 00:29
&lt;br&gt;&amp;gt; An: Konrad Hoppe
&lt;br&gt;&amp;gt; Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553618&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Betreff: Re: [R-SIG-Finance] quantmod addTA() How to scale the y axis
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Konrad Hoppe wrote:
&lt;br&gt;&amp;gt;&amp;gt; Dear mailinglist members,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I'm new to the quantmod package and I got some trouble with the addTA()
&lt;br&gt;&amp;gt;&amp;gt; method.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I want to add some indicators in the plot on position 1, hence behind the
&lt;br&gt;&amp;gt;&amp;gt; original data. But the indicators are plotted to low, they don't have any
&lt;br&gt;&amp;gt;&amp;gt; intersections with the raw-data.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; When I plot both lines with the standard plot function there are some
&lt;br&gt;&amp;gt;&amp;gt; intersections and also when I plot the difference between those two series
&lt;br&gt;&amp;gt;&amp;gt; on position 0, there are some intersections with the null-line. Hence I'm
&lt;br&gt;&amp;gt;&amp;gt; sure that the plot methods got the right data.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I've already tried the solution with setting the yrange (setting it for
&lt;br&gt;&amp;gt; all
&lt;br&gt;&amp;gt;&amp;gt; plots to the same range), but that doesn't work.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Does anybody have an idea?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; Yes, I have an idea.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please construct a reproducible example, and provide your code.  It is
&lt;br&gt;&amp;gt; nearly impossible to &amp;quot;have an idea&amp;quot; when you've described things in
&lt;br&gt;&amp;gt; broad generalities.  If you take the time to construct an example of
&lt;br&gt;&amp;gt; what you're talking about (disguise your data,create fake data, rename
&lt;br&gt;&amp;gt; your indicators, whatever), then I'm almost certain someone here can
&lt;br&gt;&amp;gt; help you.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;     - Brian
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Brian G. Peterson
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;&amp;gt; Ph: 773-459-4973
&lt;br&gt;&amp;gt; IM: bgpbraverock
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553618&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553618&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/WG%3A--quantmod-addTA%28%29-How-to-scale-the-y-axis-tp26553286p26553618.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26553286</id>
	<title>WG:  quantmod addTA() How to scale the y axis</title>
	<published>2009-11-28T05:33:10Z</published>
	<updated>2009-11-28T05:33:10Z</updated>
	<author>
		<name>Konrad Hoppe</name>
	</author>
	<content type="html">Okay, I'm sorry. Now I've constructed an example. I would be very glad if
&lt;br&gt;you can help me:
&lt;br&gt;&lt;br&gt;#--------------------------------------------------------#
&lt;br&gt;install.packages(&amp;quot;quantmod&amp;quot;)
&lt;br&gt;library(quantmod)
&lt;br&gt;&lt;br&gt;#use for example the 200-days average implemented by:
&lt;br&gt;&lt;br&gt;average &amp;lt;- function(thisVector,grad){
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; res &amp;lt;- vector(length=length(thisVector))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i in grad:length(res)){
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; res[i] &amp;lt;- mean(thisVector[(i-(grad-1)):i], na.rm=T)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i in 1:(grad-1)){
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; res[i] &amp;lt;- NA
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return(as.numeric(res))
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;#construct the chartSeries plot and get the data:
&lt;br&gt;&lt;br&gt;from.dat &amp;lt;- as.Date(&amp;quot;01/01/03&amp;quot;, format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;to.dat &amp;lt;- as.Date(Sys.Date(), format=&amp;quot;%m/%d/%y&amp;quot;)
&lt;br&gt;getSymbols(&amp;quot;BOS3.DE&amp;quot;, src=&amp;quot;yahoo&amp;quot;, from = from.dat, to = to.dat)
&lt;br&gt;&lt;br&gt;chartSeries(BOS3.DE,theme=&amp;quot;white&amp;quot;,TA=NULL, yrange=c(5,50))
&lt;br&gt;addTA(average(Ad(BOS3.DE),200), on=1,yrange=c(5,50))
&lt;br&gt;&lt;br&gt;# check the correctness of plot by the difference:
&lt;br&gt;addTA(average(Ad(BOS3.DE),200)-Ad(BOS3.DE))
&lt;br&gt;&lt;br&gt;# but that looks quite different compared to:
&lt;br&gt;&lt;br&gt;boss &amp;lt;- as.vector(Ad(BOS3.DE))
&lt;br&gt;plot(boss, type=&amp;quot;l&amp;quot; , ylim=c(0,50))
&lt;br&gt;par(new=T)
&lt;br&gt;plot(average(boss,200) , type=&amp;quot;l&amp;quot; , ylim=c(0,50),ylab=&amp;quot;&amp;quot;)
&lt;br&gt;#-------------------------------------------------------------#
&lt;br&gt;&lt;br&gt;Thanks in advance.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;Konrad
&lt;br&gt;&lt;br&gt;&lt;br&gt;-----Ursprüngliche Nachricht-----
&lt;br&gt;Von: Brian G. Peterson [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553286&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;brian@...&lt;/a&gt;] 
&lt;br&gt;Gesendet: Samstag, 28. November 2009 00:29
&lt;br&gt;An: Konrad Hoppe
&lt;br&gt;Cc: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553286&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;r-sig-finance@...&lt;/a&gt;
&lt;br&gt;Betreff: Re: [R-SIG-Finance] quantmod addTA() How to scale the y axis
&lt;br&gt;&lt;br&gt;Konrad Hoppe wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Dear mailinglist members,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'm new to the quantmod package and I got some trouble with the addTA()
&lt;br&gt;&amp;gt; method. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I want to add some indicators in the plot on position 1, hence behind the
&lt;br&gt;&amp;gt; original data. But the indicators are plotted to low, they don't have any
&lt;br&gt;&amp;gt; intersections with the raw-data. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; When I plot both lines with the standard plot function there are some
&lt;br&gt;&amp;gt; intersections and also when I plot the difference between those two series
&lt;br&gt;&amp;gt; on position 0, there are some intersections with the null-line. Hence I'm
&lt;br&gt;&amp;gt; sure that the plot methods got the right data. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I've already tried the solution with setting the yrange (setting it for
&lt;/div&gt;all
&lt;br&gt;&amp;gt; plots to the same range), but that doesn't work.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Does anybody have an idea?
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;Yes, I have an idea.
&lt;br&gt;&lt;br&gt;Please construct a reproducible example, and provide your code. &amp;nbsp;It is 
&lt;br&gt;nearly impossible to &amp;quot;have an idea&amp;quot; when you've described things in 
&lt;br&gt;broad generalities. &amp;nbsp;If you take the time to construct an example of 
&lt;br&gt;what you're talking about (disguise your data,create fake data, rename 
&lt;br&gt;your indicators, whatever), then I'm almost certain someone here can 
&lt;br&gt;help you.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;- Brian
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Brian G. Peterson
&lt;br&gt;&lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;Ph: 773-459-4973
&lt;br&gt;IM: bgpbraverock
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26553286&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/WG%3A--quantmod-addTA%28%29-How-to-scale-the-y-axis-tp26553286p26553286.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26549092</id>
	<title>Re: quantmod addTA() How to scale the y axis</title>
	<published>2009-11-27T15:28:42Z</published>
	<updated>2009-11-27T15:28:42Z</updated>
	<author>
		<name>Brian G. Peterson</name>
	</author>
	<content type="html">Konrad Hoppe wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Dear mailinglist members,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'm new to the quantmod package and I got some trouble with the addTA()
&lt;br&gt;&amp;gt; method. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I want to add some indicators in the plot on position 1, hence behind the
&lt;br&gt;&amp;gt; original data. But the indicators are plotted to low, they don't have any
&lt;br&gt;&amp;gt; intersections with the raw-data. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; When I plot both lines with the standard plot function there are some
&lt;br&gt;&amp;gt; intersections and also when I plot the difference between those two series
&lt;br&gt;&amp;gt; on position 0, there are some intersections with the null-line. Hence I'm
&lt;br&gt;&amp;gt; sure that the plot methods got the right data. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I've already tried the solution with setting the yrange (setting it for all
&lt;br&gt;&amp;gt; plots to the same range), but that doesn't work.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Does anybody have an idea?
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;/div&gt;Yes, I have an idea.
&lt;br&gt;&lt;br&gt;Please construct a reproducible example, and provide your code. &amp;nbsp;It is 
&lt;br&gt;nearly impossible to &amp;quot;have an idea&amp;quot; when you've described things in 
&lt;br&gt;broad generalities. &amp;nbsp;If you take the time to construct an example of 
&lt;br&gt;what you're talking about (disguise your data,create fake data, rename 
&lt;br&gt;your indicators, whatever), then I'm almost certain someone here can 
&lt;br&gt;help you.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;- Brian
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Brian G. Peterson
&lt;br&gt;&lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;Ph: 773-459-4973
&lt;br&gt;IM: bgpbraverock
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26549092&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/quantmod-addTA%28%29-How-to-scale-the-y-axis-tp26548745p26549092.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26548745</id>
	<title>quantmod addTA() How to scale the y axis</title>
	<published>2009-11-27T14:37:53Z</published>
	<updated>2009-11-27T14:37:53Z</updated>
	<author>
		<name>Konrad Hoppe</name>
	</author>
	<content type="html">Dear mailinglist members,
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;I'm new to the quantmod package and I got some trouble with the addTA()
&lt;br&gt;method. 
&lt;br&gt;&lt;br&gt;I want to add some indicators in the plot on position 1, hence behind the
&lt;br&gt;original data. But the indicators are plotted to low, they don't have any
&lt;br&gt;intersections with the raw-data. 
&lt;br&gt;&lt;br&gt;When I plot both lines with the standard plot function there are some
&lt;br&gt;intersections and also when I plot the difference between those two series
&lt;br&gt;on position 0, there are some intersections with the null-line. Hence I'm
&lt;br&gt;sure that the plot methods got the right data. 
&lt;br&gt;&lt;br&gt;I've already tried the solution with setting the yrange (setting it for all
&lt;br&gt;plots to the same range), but that doesn't work.
&lt;br&gt;&lt;br&gt;Does anybody have an idea?
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;Konrad Hoppe
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26548745&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/quantmod-addTA%28%29-How-to-scale-the-y-axis-tp26548745p26548745.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26546762</id>
	<title>Re: Discretising intra-day data -- how to get by with less memory?</title>
	<published>2009-11-27T11:18:51Z</published>
	<updated>2009-11-27T11:18:51Z</updated>
	<author>
		<name>Gabor Grothendieck</name>
	</author>
	<content type="html">One other thing to consider is whether you could use zooreg instead of
&lt;br&gt;zoo and in that case you might not need to fill in the gaps:
&lt;br&gt;&lt;br&gt;&amp;gt; z &amp;lt;- zoo(c(11, 13, 14), c(1, 3, 4))
&lt;br&gt;&amp;gt; zz &amp;lt;- as.zooreg(z)
&lt;br&gt;&amp;gt; zz
&lt;br&gt;&amp;nbsp;1 &amp;nbsp;3 &amp;nbsp;4
&lt;br&gt;11 13 14
&lt;br&gt;&amp;gt; lag(zz)
&lt;br&gt;&amp;nbsp;0 &amp;nbsp;2 &amp;nbsp;3
&lt;br&gt;11 13 14
&lt;br&gt;&lt;br&gt;Note how time 3 was lagged to become time 2 even though the original
&lt;br&gt;series had no time 2.
&lt;br&gt;&lt;br&gt;On Fri, Nov 27, 2009 at 12:27 PM, Ajay Shah &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546762&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ajayshah@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Fri, Nov 27, 2009 at 07:37:03AM -0500, Gabor Grothendieck wrote:
&lt;br&gt;&amp;gt;&amp;gt; What you are asking for has the potential to create huge data sets
&lt;br&gt;&amp;gt;&amp;gt; depending on the time range of the data and N. What are they?   If
&lt;br&gt;&amp;gt;&amp;gt; that is the problem then its not just a matter of how memory intensive
&lt;br&gt;&amp;gt;&amp;gt; the code is but just about any manipulation will fail.  Do the
&lt;br&gt;&amp;gt;&amp;gt; problems arise on the aggregate or moving back and forth between zoo
&lt;br&gt;&amp;gt;&amp;gt; and ts?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The object I'm dealing with has 13,667,891 rows and a lot of columns.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I thought it might make sense to:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  thinz &amp;lt;- z[,1]
&lt;br&gt;&amp;gt;  figure out the row numbers for the aggregate(blah, tail, 1) operation in thinz
&lt;br&gt;&amp;gt;  discretised &amp;lt;- z[therownums,]
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So instead of doing an aggregate(blah,tail,1), we'd analyse thinz and
&lt;br&gt;&amp;gt; come up with an integer vector therownums, and use that to make the
&lt;br&gt;&amp;gt; discretised object.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This would be memory efficient since thinz has only one column.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Ajay Shah                                      &lt;a href=&quot;http://www.mayin.org/ajayshah&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mayin.org/ajayshah&lt;/a&gt;&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546762&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ajayshah@...&lt;/a&gt;                             &lt;a href=&quot;http://ajayshahblog.blogspot.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://ajayshahblog.blogspot.com&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;lt;*(:-? - wizard who doesn't know the answer.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546762&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26546762.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26546418</id>
	<title>Re: Data</title>
	<published>2009-11-27T10:45:30Z</published>
	<updated>2009-11-27T10:45:30Z</updated>
	<author>
		<name>Jeff Ryan</name>
	</author>
	<content type="html">One last idea. Interactive Brokers has a nice platform to work from.
&lt;br&gt;&lt;br&gt;The IBrokers package lets connect and retrieve data from R. Options &amp;nbsp;
&lt;br&gt;data is limited to live contracts, but you can pull 1 min bars back to &amp;nbsp;
&lt;br&gt;contract inception.
&lt;br&gt;&lt;br&gt;There is a reasonably high account minimum, but they may be open to &amp;nbsp;
&lt;br&gt;academic access. I think I recall some special program that allows for &amp;nbsp;
&lt;br&gt;paper trading for students for free.
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;Jeff
&lt;br&gt;&lt;br&gt;Jeffrey A. Ryan
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeffrey.ryan@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;ia: insight algorithmics
&lt;br&gt;www.insightalgo.com
&lt;br&gt;&lt;br&gt;On Nov 27, 2009, at 12:30 PM, Renato Costa &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;noldo22@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Thank you all for the comments.
&lt;br&gt;&amp;gt; I just need some prices to compare to my simulations with T=30,60,90 &amp;nbsp;
&lt;br&gt;&amp;gt; and 180 and see if according to my simulations the market price is &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;quot;cheap&amp;quot; or &amp;quot;expensive&amp;quot; .
&lt;br&gt;&amp;gt; I will continue looking for it but I believe I will have to buy it &amp;nbsp;
&lt;br&gt;&amp;gt; eventually.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Renato
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Fri, Nov 27, 2009 at 3:54 PM, J Ryan &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeff.a.ryan@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Every day you have more than 300k equity option prices series. At &amp;nbsp;
&lt;br&gt;&amp;gt; EOD frequency, that is 300k prices. At 1min intervals your looking &amp;nbsp;
&lt;br&gt;&amp;gt; at 120 million per day. You can see why it won't be free.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What sort of research are doing? &amp;nbsp;Do you need end of day? &amp;nbsp;Book &amp;nbsp;
&lt;br&gt;&amp;gt; data? &amp;nbsp;How much data? &amp;nbsp;A year, a day, 10 years.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; You can use getOptionChain in quantmod to download delayed data from &amp;nbsp;
&lt;br&gt;&amp;gt; yahoo, but that isn't historical.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; With option data you'll find that you get what you pay for.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Best,
&lt;br&gt;&amp;gt; Jeff
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Jeffrey A. Ryan
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeffrey.ryan@...&lt;/a&gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ia: insight algorithmics
&lt;br&gt;&amp;gt; www.insightalgo.com
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Nov 27, 2009, at 10:03 AM, Renato Costa &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;noldo22@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Dear all
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I need to get some call option data to compare with some of my &amp;nbsp;
&lt;br&gt;&amp;gt; simulations.
&lt;br&gt;&amp;gt; Stock prices are easy to find but for options most of the sites I &amp;nbsp;
&lt;br&gt;&amp;gt; looked for
&lt;br&gt;&amp;gt; it I would have to pay for that.
&lt;br&gt;&amp;gt; Does anyone know if I can get some option prices for free?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help is appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Renato
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;&amp;gt; Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;&amp;gt; Pontifical Catholic University (PUC-Rio)
&lt;br&gt;&amp;gt; Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;&amp;gt; Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;&amp;gt; Rio de Janeiro
&lt;br&gt;&amp;gt; BRASIL
&lt;br&gt;&amp;gt; ( 9 months research at Curtin University of technology: Nov 2008 - &amp;nbsp;
&lt;br&gt;&amp;gt; July
&lt;br&gt;&amp;gt; 2009)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;&amp;gt; Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;&amp;gt; Pontifical Catholic University (PUC-Rio)
&lt;br&gt;&amp;gt; Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;&amp;gt; Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;&amp;gt; Rio de Janeiro
&lt;br&gt;&amp;gt; BRASIL
&lt;br&gt;&amp;gt; ( 9 months research at Curtin University of technology: Nov 2008 - &amp;nbsp;
&lt;br&gt;&amp;gt; July 2009)
&lt;br&gt;&amp;gt; tel.:55-21-35271205 (PUC-Rio Brazil) &amp;nbsp; Mobiles: &amp;nbsp; 55-21-99474214 &amp;nbsp;
&lt;br&gt;&amp;gt; (Brasil)
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546418&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Data-tp26544402p26546418.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26546241</id>
	<title>Re: Data</title>
	<published>2009-11-27T10:30:58Z</published>
	<updated>2009-11-27T10:30:58Z</updated>
	<author>
		<name>Feanor22</name>
	</author>
	<content type="html">Thank you all for the comments.
&lt;br&gt;I just need some prices to compare to my simulations with T=30,60,90 and 180
&lt;br&gt;and see if according to my simulations the market price is &amp;quot;cheap&amp;quot; or
&lt;br&gt;&amp;quot;expensive&amp;quot; .
&lt;br&gt;I will continue looking for it but I believe I will have to buy it
&lt;br&gt;eventually.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;Renato
&lt;br&gt;&lt;br&gt;On Fri, Nov 27, 2009 at 3:54 PM, J Ryan &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeff.a.ryan@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Every day you have more than 300k equity option prices series. At EOD
&lt;br&gt;&amp;gt; frequency, that is 300k prices. At 1min intervals your looking at 120
&lt;br&gt;&amp;gt; million per day. You can see why it won't be free.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What sort of research are doing? &amp;nbsp;Do you need end of day? &amp;nbsp;Book data? &amp;nbsp;How
&lt;br&gt;&amp;gt; much data? &amp;nbsp;A year, a day, 10 years.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; You can use getOptionChain in quantmod to download delayed data from yahoo,
&lt;br&gt;&amp;gt; but that isn't historical.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; With option data you'll find that you get what you pay for.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Best,
&lt;br&gt;&amp;gt; Jeff
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Jeffrey A. Ryan
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeffrey.ryan@...&lt;/a&gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ia: insight algorithmics
&lt;br&gt;&amp;gt; www.insightalgo.com
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Nov 27, 2009, at 10:03 AM, Renato Costa &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;noldo22@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;Dear all
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I need to get some call option data to compare with some of my
&lt;br&gt;&amp;gt;&amp;gt; simulations.
&lt;br&gt;&amp;gt;&amp;gt; Stock prices are easy to find but for options most of the sites I looked
&lt;br&gt;&amp;gt;&amp;gt; for
&lt;br&gt;&amp;gt;&amp;gt; it I would have to pay for that.
&lt;br&gt;&amp;gt;&amp;gt; Does anyone know if I can get some option prices for free?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Any help is appreciated.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Renato
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;&amp;gt;&amp;gt; Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;&amp;gt;&amp;gt; Pontifical Catholic University (PUC-Rio)
&lt;br&gt;&amp;gt;&amp;gt; Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;&amp;gt;&amp;gt; Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;&amp;gt;&amp;gt; Rio de Janeiro
&lt;br&gt;&amp;gt;&amp;gt; BRASIL
&lt;br&gt;&amp;gt;&amp;gt; ( 9 months research at Curtin University of technology: Nov 2008 - July
&lt;br&gt;&amp;gt;&amp;gt; 2009)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;Pontifical Catholic University (PUC-Rio)
&lt;br&gt;Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;Rio de Janeiro
&lt;br&gt;BRASIL
&lt;br&gt;( 9 months research at Curtin University of technology: Nov 2008 - July
&lt;br&gt;2009)
&lt;br&gt;tel.:55-21-35271205 (PUC-Rio Brazil) &amp;nbsp; Mobiles: &amp;nbsp; 55-21-99474214 (Brasil)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26546241&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Data-tp26544402p26546241.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26545362</id>
	<title>Re: How good is Black-Scholes vs actual option prices</title>
	<published>2009-11-27T10:28:35Z</published>
	<updated>2009-11-27T10:28:35Z</updated>
	<author>
		<name>Luwingo</name>
	</author>
	<content type="html">Hi Peter- the Black-Scholes-Merton closed-form solution is not a particularly good approximation to real option prices, because of its inherent assumptions. The BSM formulation assumes lognormally distributed asset prices, constant dividend yield/risk-free rate/implied volatility, and frictionless complete continuous markets. Not one of these assumptions holds in practice.
&lt;br&gt;&lt;br&gt;However, the beauty of the BSM technique is that it is to a very large extent self-correcting; that is, one can use the correct inputs to &amp;quot;tweak&amp;quot; the option price until it most closely approximates the real world, as long as you never violate risk-neutrality and no-arbitrage principles. In practice, this means using bootstrapping techniques to build a zero rate curve from market data, using volatility term structures to find the right implied volatility, applying credit spreads to the risk-free rate to preserve risk neutrality using CDS spreads, and possibly adjusting the BSM formula for non-lognormal prices. I've done the first three in VBA using FINCAD for mark-to-market accounting purposes.
&lt;br&gt;&lt;br&gt;Regarding the MSCI paper- if they're using options on a monthly basis to hedge portfolios, the use of the 3M T-bill is not appropriate. I wouldn't even use Treasury rates for risk-free rates anyway- they're too susceptible to manipulation and are not &amp;quot;true&amp;quot; market rates. I would use the 1M LIBOR rate for a monthly hedge, not a 3M rate. It is true that the LIBOR rate is more of a swap rate, but this is conventional practice in the markets and those are the rates used for bootstrapping zero curves.
&lt;br&gt;&lt;br&gt;Also, CBOE VIX data are &amp;quot;blended&amp;quot; across a variety of strikes, which means that the implied volatility for the options used is not the &amp;quot;true&amp;quot; implied volatility for each option. If you wanted to be really rigourous, you would use the market implied volatility for a particular strike and, if you have to smooth things, use a Kalman filter or some other kernel-smoothing approach.
&lt;br&gt;&lt;br&gt;In answer to your question about the price: the VIX volatility is very likely to be lower than the true volatility for an out-of-the-money option, and very likely to be higher for an in-the-money option. So if the option is far OTM, the price given by the BSM framework will be too low, and if the option is far ITM, the price will be too high. This isn't a big deal in some illiquid commodity markets but it's a VERY big deal in highly liquid equity or rates markets.
&lt;br&gt;&lt;br&gt;I hope all of that helps to answer your question(s).
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Peter Mennie wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;MSCI published this report recently: &lt;a href=&quot;http://www.mscibarra.com/resources/pdfs/research/Portfolio_BCP_Nov_2009.pdf&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mscibarra.com/resources/pdfs/research/Portfolio_BCP_Nov_2009.pdf&lt;/a&gt;&amp;nbsp;which basically looks at various methods of mitigating extreme event risk for equity portfolios.
&lt;br&gt;&lt;br&gt;One method they test is to buy options when their indicators suggest downside risk. &amp;nbsp;On pg 13 they mention they they use Black-Scholes to estimate the price of these options, using the VIX index as volatility and US 3m T-bills for the risk free rate
&lt;br&gt;&lt;br&gt;I was wondering if anyone had any experience of how accurate this assumption is likely to be in practice, and whether in practice the price would be likely to be greater or less than this estimate
&lt;br&gt;&lt;br&gt;Peter Mennie
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;R-SIG-Finance@stat.math.ethz.ch mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/How-good-is-Black-Scholes-vs-actual-option-prices-tp26482604p26545362.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26545888</id>
	<title>Re: Data</title>
	<published>2009-11-27T09:54:20Z</published>
	<updated>2009-11-27T09:54:20Z</updated>
	<author>
		<name>Jeff Ryan</name>
	</author>
	<content type="html">Every day you have more than 300k equity option prices series. At EOD &amp;nbsp;
&lt;br&gt;frequency, that is 300k prices. At 1min intervals your looking at 120 &amp;nbsp;
&lt;br&gt;million per day. You can see why it won't be free.
&lt;br&gt;&lt;br&gt;What sort of research are doing? &amp;nbsp;Do you need end of day? &amp;nbsp;Book data? &amp;nbsp; 
&lt;br&gt;How much data? &amp;nbsp;A year, a day, 10 years.
&lt;br&gt;&lt;br&gt;You can use getOptionChain in quantmod to download delayed data from &amp;nbsp;
&lt;br&gt;yahoo, but that isn't historical.
&lt;br&gt;&lt;br&gt;With option data you'll find that you get what you pay for.
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;Jeff
&lt;br&gt;&lt;br&gt;Jeffrey A. Ryan
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545888&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeffrey.ryan@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;ia: insight algorithmics
&lt;br&gt;www.insightalgo.com
&lt;br&gt;&lt;br&gt;On Nov 27, 2009, at 10:03 AM, Renato Costa &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545888&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;noldo22@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Dear all
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I need to get some call option data to compare with some of my &amp;nbsp;
&lt;br&gt;&amp;gt; simulations.
&lt;br&gt;&amp;gt; Stock prices are easy to find but for options most of the sites I &amp;nbsp;
&lt;br&gt;&amp;gt; looked for
&lt;br&gt;&amp;gt; it I would have to pay for that.
&lt;br&gt;&amp;gt; Does anyone know if I can get some option prices for free?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help is appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Renato
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545888&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;&amp;gt; Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;&amp;gt; Pontifical Catholic University (PUC-Rio)
&lt;br&gt;&amp;gt; Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;&amp;gt; Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;&amp;gt; Rio de Janeiro
&lt;br&gt;&amp;gt; BRASIL
&lt;br&gt;&amp;gt; ( 9 months research at Curtin University of technology: Nov 2008 - &amp;nbsp;
&lt;br&gt;&amp;gt; July
&lt;br&gt;&amp;gt; 2009)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;[[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545888&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545888&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Data-tp26544402p26545888.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26545797</id>
	<title>Re: Discretising intra-day data -- how to get by	with less memory?</title>
	<published>2009-11-27T09:27:28Z</published>
	<updated>2009-11-27T09:27:28Z</updated>
	<author>
		<name>Ajay Shah</name>
	</author>
	<content type="html">On Fri, Nov 27, 2009 at 07:37:03AM -0500, Gabor Grothendieck wrote:
&lt;br&gt;&amp;gt; What you are asking for has the potential to create huge data sets
&lt;br&gt;&amp;gt; depending on the time range of the data and N. What are they? &amp;nbsp; If
&lt;br&gt;&amp;gt; that is the problem then its not just a matter of how memory intensive
&lt;br&gt;&amp;gt; the code is but just about any manipulation will fail. &amp;nbsp;Do the
&lt;br&gt;&amp;gt; problems arise on the aggregate or moving back and forth between zoo
&lt;br&gt;&amp;gt; and ts?
&lt;br&gt;&lt;br&gt;The object I'm dealing with has 13,667,891 rows and a lot of columns.
&lt;br&gt;&lt;br&gt;I thought it might make sense to:
&lt;br&gt;&lt;br&gt;&amp;nbsp; thinz &amp;lt;- z[,1]
&lt;br&gt;&amp;nbsp; figure out the row numbers for the aggregate(blah, tail, 1) operation in thinz
&lt;br&gt;&amp;nbsp; discretised &amp;lt;- z[therownums,]
&lt;br&gt;&lt;br&gt;So instead of doing an aggregate(blah,tail,1), we'd analyse thinz and
&lt;br&gt;come up with an integer vector therownums, and use that to make the
&lt;br&gt;discretised object.
&lt;br&gt;&lt;br&gt;This would be memory efficient since thinz has only one column.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ajay Shah &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://www.mayin.org/ajayshah&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mayin.org/ajayshah&lt;/a&gt;&amp;nbsp; 
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545797&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ajayshah@...&lt;/a&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://ajayshahblog.blogspot.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://ajayshahblog.blogspot.com&lt;/a&gt;&lt;br&gt;&amp;lt;*(:-? - wizard who doesn't know the answer.
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545797&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26545797.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26545973</id>
	<title>Re: [R-sig-finance] Data</title>
	<published>2009-11-27T08:50:31Z</published>
	<updated>2009-11-27T08:50:31Z</updated>
	<author>
		<name>Charles Evans-5</name>
	</author>
	<content type="html">Hi Renato,
&lt;br&gt;&lt;br&gt;If you do not have access to a Bloomberg terminal, you could try &amp;nbsp;
&lt;br&gt;someone like Trade Station.
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://tradestation.com/default_2.shtm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://tradestation.com/default_2.shtm&lt;/a&gt;&lt;br&gt;&lt;br&gt;I do not have personal experience with them, but a colleague used to &amp;nbsp;
&lt;br&gt;work for them, and he tells me that they have the sort of data that &amp;nbsp;
&lt;br&gt;you are looking for. &amp;nbsp;Trade Station charges USD 100 per month, but I &amp;nbsp;
&lt;br&gt;gather that you can join and cancel after only a month. &amp;nbsp;Not optimal, &amp;nbsp;
&lt;br&gt;but when one is a graduate student, one does what one must.
&lt;br&gt;&lt;br&gt;I do not know if R can interface with Trade Station's systems, as it &amp;nbsp;
&lt;br&gt;can with Bloomberg's.
&lt;br&gt;&lt;br&gt;Alternatively, you could try talking with local brokerages and banks &amp;nbsp;
&lt;br&gt;in your area, and see if any will provide you with access to data in &amp;nbsp;
&lt;br&gt;exchange for an acknowledgement of their sponsorship of your research.
&lt;br&gt;&lt;br&gt;I wish that I could be more helpful, but Luwingo is right. &amp;nbsp;This is &amp;nbsp;
&lt;br&gt;one of the reasons that I abandoned options as my PhD thesis topic and &amp;nbsp;
&lt;br&gt;switched to ETFs.
&lt;br&gt;&lt;br&gt;Yours,
&lt;br&gt;&lt;br&gt;C.Evans
&lt;br&gt;&lt;br&gt;&lt;br&gt;On 27 Nov 2009, at 11:20, Luwingo wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Hi Renato- option data is pretty valuable and somewhat complicated. &amp;nbsp;
&lt;br&gt;&amp;gt; It's
&lt;br&gt;&amp;gt; pretty unlikely that you will be able to find that data for free- &amp;nbsp;
&lt;br&gt;&amp;gt; especially
&lt;br&gt;&amp;gt; if you're looking for options on certain less liquid stocks. That &amp;nbsp;
&lt;br&gt;&amp;gt; said, the
&lt;br&gt;&amp;gt; CBOE has data that you can use, as do the CBOT, CME, and NYMEX. You &amp;nbsp;
&lt;br&gt;&amp;gt; probably
&lt;br&gt;&amp;gt; won't find that data too useful, though, since implied volatility &amp;nbsp;
&lt;br&gt;&amp;gt; data is
&lt;br&gt;&amp;gt; especially difficult to find for free. The best place you can find &amp;nbsp;
&lt;br&gt;&amp;gt; this data
&lt;br&gt;&amp;gt; is from any Bloomberg terminal. If you have one in your university, &amp;nbsp;
&lt;br&gt;&amp;gt; use that
&lt;br&gt;&amp;gt; to download the data onto a spreadsheet for use elsewhere.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Feanor22 wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Dear all
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I need to get some call option data to compare with some of my
&lt;br&gt;&amp;gt;&amp;gt; simulations.
&lt;br&gt;&amp;gt;&amp;gt; Stock prices are easy to find but for options most of the sites I &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; looked
&lt;br&gt;&amp;gt;&amp;gt; for
&lt;br&gt;&amp;gt;&amp;gt; it I would have to pay for that.
&lt;br&gt;&amp;gt;&amp;gt; Does anyone know if I can get some option prices for free?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Any help is appreciated.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Regards
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Renato
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; -- 
&lt;br&gt;&amp;gt;&amp;gt; PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545973&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;&amp;gt;&amp;gt; Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;&amp;gt;&amp;gt; Pontifical Catholic University (PUC-Rio)
&lt;br&gt;&amp;gt;&amp;gt; Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;&amp;gt;&amp;gt; Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;&amp;gt;&amp;gt; Rio de Janeiro
&lt;br&gt;&amp;gt;&amp;gt; BRASIL
&lt;br&gt;&amp;gt;&amp;gt; ( 9 months research at Curtin University of technology: Nov 2008 - &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; July
&lt;br&gt;&amp;gt;&amp;gt; 2009)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 	[[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545973&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/Data-tp26544402p26544564.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/Data-tp26544402p26544564.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Rmetrics mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545973&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;/div&gt;&lt;br&gt;&lt;br&gt;Most people's superstitions are beyond belief.
&lt;br&gt;C.Nothing
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26545973&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Data-tp26544402p26545973.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26544710</id>
	<title>Re: Creating a back adjusted continuous price	series from log returns</title>
	<published>2009-11-27T08:29:34Z</published>
	<updated>2009-11-27T08:29:34Z</updated>
	<author>
		<name>Patrick Burns-2</name>
	</author>
	<content type="html">I was interpreting the question as looking for:
&lt;br&gt;&lt;br&gt;price.vector &amp;lt;- original.price * exp(cumsum(return.vector))
&lt;br&gt;&lt;br&gt;&lt;br&gt;Patrick Burns
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544710&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;patrick@...&lt;/a&gt;
&lt;br&gt;+44 (0)20 8525 0696
&lt;br&gt;&lt;a href=&quot;http://www.burns-stat.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.burns-stat.com&lt;/a&gt;&lt;br&gt;(home of &amp;quot;The R Inferno&amp;quot; and &amp;quot;A Guide for the Unwilling S User&amp;quot;)
&lt;br&gt;&lt;br&gt;Whit Armstrong wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; There are many ways of doing this. You need to decide what your strategy is
&lt;br&gt;&amp;gt; for rolling the contracts (vol crossover, OI crossover, expiration, 10 days
&lt;br&gt;&amp;gt; before expiration, first notice date, etc.).
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Look here for a basic idea about how to do this:
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://github.com/armstrtw/RCommodity&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://github.com/armstrtw/RCommodity&lt;/a&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://github.com/armstrtw/RCommodity&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://github.com/armstrtw/RCommodity&lt;/a&gt;&amp;gt;-Whit
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; On Fri, Nov 27, 2009 at 9:52 AM, Wob Wu &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544710&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;wobwu22@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I am trying to create a continuous daily futures contract time series. I've
&lt;br&gt;&amp;gt;&amp;gt; already calculated the log returns for this series and want to create an
&lt;br&gt;&amp;gt;&amp;gt; artificial price series starting with the most recent price (the one with
&lt;br&gt;&amp;gt;&amp;gt; the latest date).
&lt;br&gt;&amp;gt;&amp;gt; Basically I am trying to create a price series with the following logic:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; p(-1) := exp(ln(p(0)) - r)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I have got p(T) and the log return series r and am trying to create the
&lt;br&gt;&amp;gt;&amp;gt; price series.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; with
&lt;br&gt;&amp;gt;&amp;gt; p(0) = todays price
&lt;br&gt;&amp;gt;&amp;gt; p(-1) = yesterdays price
&lt;br&gt;&amp;gt;&amp;gt; p(T) = the price at time T (current available price)
&lt;br&gt;&amp;gt;&amp;gt; r = log return between yesterdays price and todays price
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Wolfgang Wu
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; __________________________________________________
&lt;br&gt;&amp;gt;&amp;gt; Do You Yahoo!?
&lt;br&gt;&amp;gt;&amp;gt; Sie sind Spam leid? Yahoo! Mail verfÃ¼gt Ã¼ber einen herausragenden Schutz
&lt;br&gt;&amp;gt;&amp;gt; gegen Massenmails.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544710&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 	[[alternative HTML version deleted]]
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; ------------------------------------------------------------------------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544710&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544710&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Creating-a-back-adjusted-continuous-price-series-from-log-returns-tp26543447p26544710.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26544564</id>
	<title>Re: Data</title>
	<published>2009-11-27T08:20:40Z</published>
	<updated>2009-11-27T08:20:40Z</updated>
	<author>
		<name>Luwingo</name>
	</author>
	<content type="html">Hi Renato- option data is pretty valuable and somewhat complicated. It's pretty unlikely that you will be able to find that data for free- especially if you're looking for options on certain less liquid stocks. That said, the CBOE has data that you can use, as do the CBOT, CME, and NYMEX. You probably won't find that data too useful, though, since implied volatility data is especially difficult to find for free. The best place you can find this data is from any Bloomberg terminal. If you have one in your university, use that to download the data onto a spreadsheet for use elsewhere.
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Feanor22 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Dear all
&lt;br&gt;&lt;br&gt;I need to get some call option data to compare with some of my simulations.
&lt;br&gt;Stock prices are easy to find but for options most of the sites I looked for
&lt;br&gt;it I would have to pay for that.
&lt;br&gt;Does anyone know if I can get some option prices for free?
&lt;br&gt;&lt;br&gt;Any help is appreciated.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;Renato
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;PhD Student Renato Alencar Adelino da Costa (renato@ele.puc-rio.br)
&lt;br&gt;Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;Pontifical Catholic University (PUC-Rio)
&lt;br&gt;Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;Rio de Janeiro
&lt;br&gt;BRASIL
&lt;br&gt;( 9 months research at Curtin University of technology: Nov 2008 - July
&lt;br&gt;2009)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;R-SIG-Finance@stat.math.ethz.ch mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Data-tp26544402p26544564.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26544402</id>
	<title>Data</title>
	<published>2009-11-27T08:03:14Z</published>
	<updated>2009-11-27T08:03:14Z</updated>
	<author>
		<name>Feanor22</name>
	</author>
	<content type="html">Dear all
&lt;br&gt;&lt;br&gt;I need to get some call option data to compare with some of my simulations.
&lt;br&gt;Stock prices are easy to find but for options most of the sites I looked for
&lt;br&gt;it I would have to pay for that.
&lt;br&gt;Does anyone know if I can get some option prices for free?
&lt;br&gt;&lt;br&gt;Any help is appreciated.
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;&lt;br&gt;Renato
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;PhD Student Renato Alencar Adelino da Costa (&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544402&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;renato@...&lt;/a&gt;)
&lt;br&gt;Department of Electrical Engineering (Mathematical Finance)
&lt;br&gt;Pontifical Catholic University (PUC-Rio)
&lt;br&gt;Rua Marques de Sao Vicente, 225, Sala 604L
&lt;br&gt;Gavea &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CEP: 22453-900
&lt;br&gt;Rio de Janeiro
&lt;br&gt;BRASIL
&lt;br&gt;( 9 months research at Curtin University of technology: Nov 2008 - July
&lt;br&gt;2009)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544402&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Data-tp26544402p26544402.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26544245</id>
	<title>Re: Creating a back adjusted continuous price series from log returns</title>
	<published>2009-11-27T07:53:29Z</published>
	<updated>2009-11-27T07:53:29Z</updated>
	<author>
		<name>Whit Armstrong-2</name>
	</author>
	<content type="html">There are many ways of doing this. You need to decide what your strategy is
&lt;br&gt;for rolling the contracts (vol crossover, OI crossover, expiration, 10 days
&lt;br&gt;before expiration, first notice date, etc.).
&lt;br&gt;&lt;br&gt;Look here for a basic idea about how to do this:
&lt;br&gt;&lt;a href=&quot;http://github.com/armstrtw/RCommodity&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://github.com/armstrtw/RCommodity&lt;/a&gt;&lt;br&gt;&lt;br&gt;&amp;lt;&lt;a href=&quot;http://github.com/armstrtw/RCommodity&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://github.com/armstrtw/RCommodity&lt;/a&gt;&amp;gt;-Whit
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Fri, Nov 27, 2009 at 9:52 AM, Wob Wu &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544245&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;wobwu22@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I am trying to create a continuous daily futures contract time series. I've
&lt;br&gt;&amp;gt; already calculated the log returns for this series and want to create an
&lt;br&gt;&amp;gt; artificial price series starting with the most recent price (the one with
&lt;br&gt;&amp;gt; the latest date).
&lt;br&gt;&amp;gt; Basically I am trying to create a price series with the following logic:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; p(-1) := exp(ln(p(0)) - r)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have got p(T) and the log return series r and am trying to create the
&lt;br&gt;&amp;gt; price series.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; with
&lt;br&gt;&amp;gt; p(0) = todays price
&lt;br&gt;&amp;gt; p(-1) = yesterdays price
&lt;br&gt;&amp;gt; p(T) = the price at time T (current available price)
&lt;br&gt;&amp;gt; r = log return between yesterdays price and todays price
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Wolfgang Wu
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; __________________________________________________
&lt;br&gt;&amp;gt; Do You Yahoo!?
&lt;br&gt;&amp;gt; Sie sind Spam leid? Yahoo! Mail verfÃ¼gt Ã¼ber einen herausragenden Schutz
&lt;br&gt;&amp;gt; gegen Massenmails.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544245&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;/div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544245&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Creating-a-back-adjusted-continuous-price-series-from-log-returns-tp26543447p26544245.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26544240</id>
	<title>Re: SMA on Volume?</title>
	<published>2009-11-27T07:52:48Z</published>
	<updated>2009-11-27T07:52:48Z</updated>
	<author>
		<name>Joshua Ulrich</name>
	</author>
	<content type="html">Try:
&lt;br&gt;&lt;br&gt;&amp;gt; getSymbols(&amp;quot;SPY&amp;quot;)
&lt;br&gt;[1] &amp;quot;SPY&amp;quot;
&lt;br&gt;&amp;gt; chartSeries(SPY); addSMA(10,on=2)
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;Josh
&lt;br&gt;--
&lt;br&gt;&lt;a href=&quot;http://www.fosstrading.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.fosstrading.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Fri, Nov 27, 2009 at 9:33 AM, Robert Nicholson
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544240&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;robert.nicholson@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; If you're viewing a chart series and you have Volume displayed you can you specify &amp;quot;on&amp;quot; such that SMA will be overlaid on Volume graph?
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544240&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26544240&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SMA-on-Volume--tp26543997p26544240.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26543997</id>
	<title>SMA on Volume?</title>
	<published>2009-11-27T07:33:19Z</published>
	<updated>2009-11-27T07:33:19Z</updated>
	<author>
		<name>Robert Nicholson-3</name>
	</author>
	<content type="html">If you're viewing a chart series and you have Volume displayed you can you specify &amp;quot;on&amp;quot; such that SMA will be overlaid on Volume graph?
&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26543997&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/SMA-on-Volume--tp26543997p26543997.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26543677</id>
	<title>Re: Discretising intra-day data -- how to get by with less memory?</title>
	<published>2009-11-27T07:07:23Z</published>
	<updated>2009-11-27T07:07:23Z</updated>
	<author>
		<name>Jeff Ryan</name>
	</author>
	<content type="html">The three functions that can be found in xts to help here are:
&lt;br&gt;&lt;br&gt;(1) align.time: &amp;nbsp;(as Brian alluded to)
&lt;br&gt;This will simply shift all times to the next n-th second specified.
&lt;br&gt;e.g. align.time(x, n=300) &amp;nbsp;# 5 minutes
&lt;br&gt;&lt;br&gt;(2) endpoints:
&lt;br&gt;Locate the last time-stamp (obs in time-series) for each &amp;quot;k&amp;quot; &amp;quot;on&amp;quot; periods
&lt;br&gt;e.g. endpoints(x, on=&amp;quot;minutes&amp;quot;, k=5) &amp;nbsp;# 5 minutes
&lt;br&gt;&lt;br&gt;(3) merge.xts with a regular time index.
&lt;br&gt;e.g. merge(x, xts(, timeBasedSeq('2009-11-01 08:30/2009-11-01 03:00')))
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;A complete example:
&lt;br&gt;&amp;gt; x &amp;lt;- xts(1:10, Sys.time()+1:10*rnorm(10)*60)
&lt;br&gt;&amp;gt; x
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [,1]
&lt;br&gt;2009-11-27 08:48:18 &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:51:03 &amp;nbsp; &amp;nbsp;7
&lt;br&gt;2009-11-27 08:52:13 &amp;nbsp; &amp;nbsp;8
&lt;br&gt;2009-11-27 08:53:10 &amp;nbsp; 10
&lt;br&gt;2009-11-27 08:55:25 &amp;nbsp; &amp;nbsp;6
&lt;br&gt;2009-11-27 08:55:56 &amp;nbsp; &amp;nbsp;1
&lt;br&gt;2009-11-27 08:56:02 &amp;nbsp; &amp;nbsp;4
&lt;br&gt;2009-11-27 08:56:44 &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 08:59:24 &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:02:46 &amp;nbsp; &amp;nbsp;5
&lt;br&gt;&lt;br&gt;&amp;gt; xa &amp;lt;- align.time(x,60) &amp;nbsp;# align to end of minutes
&lt;br&gt;&amp;gt; xa
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [,1]
&lt;br&gt;2009-11-27 08:49:00 &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:52:00 &amp;nbsp; &amp;nbsp;7
&lt;br&gt;2009-11-27 08:53:00 &amp;nbsp; &amp;nbsp;8
&lt;br&gt;2009-11-27 08:54:00 &amp;nbsp; 10
&lt;br&gt;2009-11-27 08:56:00 &amp;nbsp; &amp;nbsp;6
&lt;br&gt;2009-11-27 08:56:00 &amp;nbsp; &amp;nbsp;1
&lt;br&gt;2009-11-27 08:57:00 &amp;nbsp; &amp;nbsp;4
&lt;br&gt;2009-11-27 08:57:00 &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 09:00:00 &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:03:00 &amp;nbsp; &amp;nbsp;5
&lt;br&gt;&lt;br&gt;&amp;gt; xa[endpoints(xa,'minutes')] &amp;nbsp;# get last obs with unique timestamp
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [,1]
&lt;br&gt;2009-11-27 08:49:00 &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:52:00 &amp;nbsp; &amp;nbsp;7
&lt;br&gt;2009-11-27 08:53:00 &amp;nbsp; &amp;nbsp;8
&lt;br&gt;2009-11-27 08:54:00 &amp;nbsp; 10
&lt;br&gt;2009-11-27 08:56:00 &amp;nbsp; &amp;nbsp;1
&lt;br&gt;2009-11-27 08:57:00 &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 09:00:00 &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:03:00 &amp;nbsp; &amp;nbsp;5
&lt;br&gt;&lt;br&gt;&amp;gt; # fill in 'regular' time series
&lt;br&gt;&amp;gt; merge(xa[endpoints(xa,'minutes')], xts( ,seq(start(xa),end(xa),by=&amp;quot;mins&amp;quot;)))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xa.endpoints.xa...minutes...
&lt;br&gt;2009-11-27 08:49:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:50:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 08:51:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 08:52:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7
&lt;br&gt;2009-11-27 08:53:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8
&lt;br&gt;2009-11-27 08:54:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10
&lt;br&gt;2009-11-27 08:55:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 08:56:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1
&lt;br&gt;2009-11-27 08:57:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 08:58:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 08:59:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 09:00:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:01:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 09:02:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NA
&lt;br&gt;2009-11-27 09:03:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5
&lt;br&gt;&lt;br&gt;&amp;gt; # optional fill=na.locf will carry forward the last observation (last trade?)
&lt;br&gt;&amp;gt; merge(xa[endpoints(xa,'minutes')], xts( ,seq(start(xa),end(xa),by=&amp;quot;mins&amp;quot;)),fill=na.locf)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xa.endpoints.xa...minutes...
&lt;br&gt;2009-11-27 08:49:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:50:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:51:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9
&lt;br&gt;2009-11-27 08:52:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7
&lt;br&gt;2009-11-27 08:53:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8
&lt;br&gt;2009-11-27 08:54:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10
&lt;br&gt;2009-11-27 08:55:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10
&lt;br&gt;2009-11-27 08:56:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1
&lt;br&gt;2009-11-27 08:57:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 08:58:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 08:59:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3
&lt;br&gt;2009-11-27 09:00:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:01:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:02:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2
&lt;br&gt;2009-11-27 09:03:00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5
&lt;br&gt;&lt;br&gt;&lt;br&gt;I didn't test against your solution(s), but this should be very fast
&lt;br&gt;and use as little memory as possible. &amp;nbsp;endpoints, align.time and
&lt;br&gt;merge.xts have all been heavily optimized for speed and memory.
&lt;br&gt;&lt;br&gt;HTH
&lt;br&gt;Jeff
&lt;br&gt;&lt;br&gt;On Fri, Nov 27, 2009 at 7:00 AM, Brian G. Peterson &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26543677&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;brian@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Brian G. Peterson wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Ajay Shah wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I'm using this function to convert intra-day data into a grid with an
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; observation each N seconds:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;  # This function consumes &amp;quot;z&amp;quot; a zoo object where timestamps are intraday
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;  # and a period for discretisation Nseconds.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;  # The key ideas are from this thread:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;  #    &lt;a href=&quot;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;  intraday.discretise &amp;lt;- function(z, Nseconds) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    toNsec &amp;lt;- function(x)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; as.POSIXct(Nseconds*ceiling(as.numeric(x)/Nseconds),
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;                                   origin = &amp;quot;1970-01-01&amp;quot;)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    d &amp;lt;- aggregate(z, toNsec, tail, 1)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    # At this point there is one problem: NA records are not created
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    # for blocks of time in which there were no records.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    # To solve this:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    dreg &amp;lt;- as.zoo(as.ts(d))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    class(time(dreg)) &amp;lt;- class(time(d))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;    dreg
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;  }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; This works correctly but it's incredibly memory-intensive. I'm running
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; out of core in running this for some problems.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Is there a way to write this which would use less RAM?
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Jeff Ryan, Abe Winter, and I came up with an align.time function a few
&lt;br&gt;&amp;gt;&amp;gt; months back:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; align.time &amp;lt;- function(x, n=30) {
&lt;br&gt;&amp;gt;&amp;gt;  structure(unclass(x) + (n - unclass(x) %% n),
&lt;br&gt;&amp;gt;&amp;gt; class=c(&amp;quot;POSIXt&amp;quot;,&amp;quot;POSIXct&amp;quot;)) }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; x is xts data
&lt;br&gt;&amp;gt;&amp;gt; n is seconds
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;  - Brian
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; Or, an earlier, slower version:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; this works well enough to generate a new index on the output of to.period:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # stamp is POSIXct object, like index(x) of an xts object
&lt;br&gt;&amp;gt; # n is number of seconds to round to, so n=k in to.period
&lt;br&gt;&amp;gt; even_seconds = function(stamp,n=60)
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt;  tzone = attr(stamp,&amp;quot;tzone&amp;quot;)
&lt;br&gt;&amp;gt;  if (is.null(tzone)) { tzone = &amp;quot;&amp;quot; }
&lt;br&gt;&amp;gt;  base = as.POSIXct(strptime( format(stamp,&amp;quot;%Y%m%d&amp;quot;), &amp;quot;%Y%m%d&amp;quot; ),tz=tzone)
&lt;br&gt;&amp;gt;  i = as.numeric(stamp) - as.numeric(base)
&lt;br&gt;&amp;gt;  i = base + n*ceiling(i/n)
&lt;br&gt;&amp;gt;  i
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Brian G. Peterson
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;&amp;gt; Ph: 773-459-4973
&lt;br&gt;&amp;gt; IM: bgpbraverock
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26543677&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Jeffrey Ryan
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26543677&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeffrey.ryan@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;ia: insight algorithmics
&lt;br&gt;www.insightalgo.com
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26543677&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26543677.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26543447</id>
	<title>Creating a back adjusted continuous price series from log returns</title>
	<published>2009-11-27T06:52:33Z</published>
	<updated>2009-11-27T06:52:33Z</updated>
	<author>
		<name>wob wu</name>
	</author>
	<content type="html">I am trying to create a continuous daily futures contract time series. I've already calculated the log returns for this series and want to create an artificial price series starting with the most recent price (the one with the latest date).
&lt;br&gt;Basically I am trying to create a price series with the following logic:
&lt;br&gt;&lt;br&gt;p(-1) := exp(ln(p(0)) - r)
&lt;br&gt;&lt;br&gt;I have got p(T) and the log return series r and am trying to create the price series.
&lt;br&gt;&lt;br&gt;with
&lt;br&gt;p(0) = todays price
&lt;br&gt;p(-1) = yesterdays price
&lt;br&gt;p(T) = the price at time T (current available price)
&lt;br&gt;r = log return between yesterdays price and todays price
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;Wolfgang Wu
&lt;br&gt;&lt;br&gt;__________________________________________________
&lt;br&gt;Do You Yahoo!?
&lt;br&gt;Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26543447&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Creating-a-back-adjusted-continuous-price-series-from-log-returns-tp26543447p26543447.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26542109</id>
	<title>Re: Discretising intra-day data -- how to get by with	less memory?</title>
	<published>2009-11-27T05:00:03Z</published>
	<updated>2009-11-27T05:00:03Z</updated>
	<author>
		<name>Brian G. Peterson</name>
	</author>
	<content type="html">Brian G. Peterson wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Ajay Shah wrote:
&lt;br&gt;&amp;gt;&amp;gt; I'm using this function to convert intra-day data into a grid with an
&lt;br&gt;&amp;gt;&amp;gt; observation each N seconds:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; # This function consumes &amp;quot;z&amp;quot; a zoo object where timestamps are 
&lt;br&gt;&amp;gt;&amp;gt; intraday
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; # and a period for discretisation Nseconds.
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; # The key ideas are from this thread:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; # &amp;nbsp; &amp;nbsp;&lt;a href=&quot;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; intraday.discretise &amp;lt;- function(z, Nseconds) {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; toNsec &amp;lt;- function(x) 
&lt;br&gt;&amp;gt;&amp;gt; as.POSIXct(Nseconds*ceiling(as.numeric(x)/Nseconds),
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;origin = &amp;quot;1970-01-01&amp;quot;)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; d &amp;lt;- aggregate(z, toNsec, tail, 1)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; # At this point there is one problem: NA records are not created
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; # for blocks of time in which there were no records.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; # To solve this:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; dreg &amp;lt;- as.zoo(as.ts(d))
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; class(time(dreg)) &amp;lt;- class(time(d))
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; dreg
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; This works correctly but it's incredibly memory-intensive. I'm running
&lt;br&gt;&amp;gt;&amp;gt; out of core in running this for some problems.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Is there a way to write this which would use less RAM?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt; Jeff Ryan, Abe Winter, and I came up with an align.time function a few 
&lt;br&gt;&amp;gt; months back:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; align.time &amp;lt;- function(x, n=30) {
&lt;br&gt;&amp;gt; &amp;nbsp;structure(unclass(x) + (n - unclass(x) %% n), 
&lt;br&gt;&amp;gt; class=c(&amp;quot;POSIXt&amp;quot;,&amp;quot;POSIXct&amp;quot;)) }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; x is xts data
&lt;br&gt;&amp;gt; n is seconds
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;- Brian
&lt;br&gt;&amp;gt;
&lt;/div&gt;Or, an earlier, slower version:
&lt;br&gt;&lt;br&gt;this works well enough to generate a new index on the output of to.period:
&lt;br&gt;&lt;br&gt;# stamp is POSIXct object, like index(x) of an xts object
&lt;br&gt;# n is number of seconds to round to, so n=k in to.period
&lt;br&gt;even_seconds = function(stamp,n=60)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; tzone = attr(stamp,&amp;quot;tzone&amp;quot;)
&lt;br&gt;&amp;nbsp; if (is.null(tzone)) { tzone = &amp;quot;&amp;quot; }
&lt;br&gt;&amp;nbsp; base = as.POSIXct(strptime( format(stamp,&amp;quot;%Y%m%d&amp;quot;), &amp;quot;%Y%m%d&amp;quot; ),tz=tzone)
&lt;br&gt;&amp;nbsp; i = as.numeric(stamp) - as.numeric(base)
&lt;br&gt;&amp;nbsp; i = base + n*ceiling(i/n)
&lt;br&gt;&amp;nbsp; i
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Brian G. Peterson
&lt;br&gt;&lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;Ph: 773-459-4973
&lt;br&gt;IM: bgpbraverock
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26542109&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26542109.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26541919</id>
	<title>Re: Discretising intra-day data -- how to get by with	less memory?</title>
	<published>2009-11-27T04:41:00Z</published>
	<updated>2009-11-27T04:41:00Z</updated>
	<author>
		<name>Brian G. Peterson</name>
	</author>
	<content type="html">Ajay Shah wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I'm using this function to convert intra-day data into a grid with an
&lt;br&gt;&amp;gt; observation each N seconds:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; # This function consumes &amp;quot;z&amp;quot; a zoo object where timestamps are intraday
&lt;br&gt;&amp;gt; &amp;nbsp; # and a period for discretisation Nseconds.
&lt;br&gt;&amp;gt; &amp;nbsp; # The key ideas are from this thread:
&lt;br&gt;&amp;gt; &amp;nbsp; # &amp;nbsp; &amp;nbsp;&lt;a href=&quot;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;nbsp; intraday.discretise &amp;lt;- function(z, Nseconds) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; toNsec &amp;lt;- function(x) as.POSIXct(Nseconds*ceiling(as.numeric(x)/Nseconds),
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;origin = &amp;quot;1970-01-01&amp;quot;)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; d &amp;lt;- aggregate(z, toNsec, tail, 1)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; # At this point there is one problem: NA records are not created
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; # for blocks of time in which there were no records.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; # To solve this:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; dreg &amp;lt;- as.zoo(as.ts(d))
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; class(time(dreg)) &amp;lt;- class(time(d))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; dreg
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This works correctly but it's incredibly memory-intensive. I'm running
&lt;br&gt;&amp;gt; out of core in running this for some problems.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is there a way to write this which would use less RAM?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;/div&gt;Jeff Ryan, Abe Winter, and I came up with an align.time function a few 
&lt;br&gt;months back:
&lt;br&gt;&lt;br&gt;align.time &amp;lt;- function(x, n=30) {
&lt;br&gt;&amp;nbsp; structure(unclass(x) + (n - unclass(x) %% n), class=c(&amp;quot;POSIXt&amp;quot;,&amp;quot;POSIXct&amp;quot;)) }
&lt;br&gt;&lt;br&gt;x is xts data
&lt;br&gt;n is seconds
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;&amp;nbsp; - Brian
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Brian G. Peterson
&lt;br&gt;&lt;a href=&quot;http://braverock.com/brian/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://braverock.com/brian/&lt;/a&gt;&lt;br&gt;Ph: 773-459-4973
&lt;br&gt;IM: bgpbraverock
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26541919&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26541919.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26541884</id>
	<title>Re: Discretising intra-day data -- how to get by with less memory?</title>
	<published>2009-11-27T04:37:03Z</published>
	<updated>2009-11-27T04:37:03Z</updated>
	<author>
		<name>Gabor Grothendieck</name>
	</author>
	<content type="html">What you are asking for has the potential to create huge data sets
&lt;br&gt;depending on the time range of the data and N. What are they? &amp;nbsp; If
&lt;br&gt;that is the problem then its not just a matter of how memory intensive
&lt;br&gt;the code is but just about any manipulation will fail. &amp;nbsp;Do the
&lt;br&gt;problems arise on the aggregate or moving back and forth between zoo
&lt;br&gt;and ts?
&lt;br&gt;&lt;br&gt;On Fri, Nov 27, 2009 at 6:56 AM, Ajay Shah &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26541884&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ajayshah@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I'm using this function to convert intra-day data into a grid with an
&lt;br&gt;&amp;gt; observation each N seconds:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  # This function consumes &amp;quot;z&amp;quot; a zoo object where timestamps are intraday
&lt;br&gt;&amp;gt;  # and a period for discretisation Nseconds.
&lt;br&gt;&amp;gt;  # The key ideas are from this thread:
&lt;br&gt;&amp;gt;  #    &lt;a href=&quot;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&lt;/a&gt;&lt;br&gt;&amp;gt;  intraday.discretise &amp;lt;- function(z, Nseconds) {
&lt;br&gt;&amp;gt;    toNsec &amp;lt;- function(x) as.POSIXct(Nseconds*ceiling(as.numeric(x)/Nseconds),
&lt;br&gt;&amp;gt;                                   origin = &amp;quot;1970-01-01&amp;quot;)
&lt;br&gt;&amp;gt;    d &amp;lt;- aggregate(z, toNsec, tail, 1)
&lt;br&gt;&amp;gt;    # At this point there is one problem: NA records are not created
&lt;br&gt;&amp;gt;    # for blocks of time in which there were no records.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;    # To solve this:
&lt;br&gt;&amp;gt;    dreg &amp;lt;- as.zoo(as.ts(d))
&lt;br&gt;&amp;gt;    class(time(dreg)) &amp;lt;- class(time(d))
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;    dreg
&lt;br&gt;&amp;gt;  }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This works correctly but it's incredibly memory-intensive. I'm running
&lt;br&gt;&amp;gt; out of core in running this for some problems.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is there a way to write this which would use less RAM?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Ajay Shah                                      &lt;a href=&quot;http://www.mayin.org/ajayshah&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mayin.org/ajayshah&lt;/a&gt;&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26541884&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ajayshah@...&lt;/a&gt;                             &lt;a href=&quot;http://ajayshahblog.blogspot.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://ajayshahblog.blogspot.com&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;lt;*(:-? - wizard who doesn't know the answer.
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26541884&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26541884.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26541474</id>
	<title>Discretising intra-day data -- how to get by with less memory?</title>
	<published>2009-11-27T03:56:52Z</published>
	<updated>2009-11-27T03:56:52Z</updated>
	<author>
		<name>Ajay Shah</name>
	</author>
	<content type="html">I'm using this function to convert intra-day data into a grid with an
&lt;br&gt;observation each N seconds:
&lt;br&gt;&lt;br&gt;&amp;nbsp; # This function consumes &amp;quot;z&amp;quot; a zoo object where timestamps are intraday
&lt;br&gt;&amp;nbsp; # and a period for discretisation Nseconds.
&lt;br&gt;&amp;nbsp; # The key ideas are from this thread:
&lt;br&gt;&amp;nbsp; # &amp;nbsp; &amp;nbsp;&lt;a href=&quot;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/pipermail/r-sig-finance/2009q4/005144.html&lt;/a&gt;&lt;br&gt;&amp;nbsp; intraday.discretise &amp;lt;- function(z, Nseconds) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; toNsec &amp;lt;- function(x) as.POSIXct(Nseconds*ceiling(as.numeric(x)/Nseconds),
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;origin = &amp;quot;1970-01-01&amp;quot;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; d &amp;lt;- aggregate(z, toNsec, tail, 1)
&lt;br&gt;&amp;nbsp; &amp;nbsp; # At this point there is one problem: NA records are not created
&lt;br&gt;&amp;nbsp; &amp;nbsp; # for blocks of time in which there were no records.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; # To solve this:
&lt;br&gt;&amp;nbsp; &amp;nbsp; dreg &amp;lt;- as.zoo(as.ts(d))
&lt;br&gt;&amp;nbsp; &amp;nbsp; class(time(dreg)) &amp;lt;- class(time(d))
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; dreg
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;This works correctly but it's incredibly memory-intensive. I'm running
&lt;br&gt;out of core in running this for some problems.
&lt;br&gt;&lt;br&gt;Is there a way to write this which would use less RAM?
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ajay Shah &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://www.mayin.org/ajayshah&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.mayin.org/ajayshah&lt;/a&gt;&amp;nbsp; 
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26541474&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ajayshah@...&lt;/a&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://ajayshahblog.blogspot.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://ajayshahblog.blogspot.com&lt;/a&gt;&lt;br&gt;&amp;lt;*(:-? - wizard who doesn't know the answer.
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26541474&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Discretising-intra-day-data----how-to-get-by-with-less-memory--tp26541474p26541474.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535989</id>
	<title>Re: [R-sig-finance] A VaR question</title>
	<published>2009-11-26T22:45:23Z</published>
	<updated>2009-11-26T22:45:23Z</updated>
	<author>
		<name>RON70</name>
	</author>
	<content type="html">I want to make another point here. My question is can I take &amp;quot;co&amp;quot; matrix as DGP for a VAR? Here I calculated the roots for the ch. equation :
&lt;br&gt;&lt;br&gt;A2 = A1 = co
&lt;br&gt;library(PolynomF) 
&lt;br&gt;&amp;nbsp; z = polynom() 
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;p11 &amp;lt;- 1 - A1[1,1]*z - A2[1,1]*z^2
&lt;br&gt;&amp;nbsp;p12 &amp;lt;- 0 - A1[1,2]*z - A2[1,2]*z^2
&lt;br&gt;&amp;nbsp;p13 &amp;lt;- 0 - A1[1,3]*z - A2[1,3]*z^2
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;p21 &amp;lt;- 0 - A1[2,1]*z - A2[2,1]*z^2
&lt;br&gt;&amp;nbsp;p22 &amp;lt;- 1 - A1[2,2]*z - A2[2,2]*z^2 
&lt;br&gt;&amp;nbsp;p23 &amp;lt;- 0 - A1[2,3]*z - A2[2,3]*z^2 
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;p31 &amp;lt;- 0 - A1[3,1]*z - A2[3,1]*z^2 
&lt;br&gt;&amp;nbsp;p32 &amp;lt;- 0 - A1[3,2]*z - A2[3,2]*z^2 
&lt;br&gt;&amp;nbsp;p33 &amp;lt;- 1 - A1[3,3]*z - A2[3,3]*z^2 
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;p &amp;lt;- p11*(p22*p33 - p23*p32) - p12*(p21*p33 - p23*p31) + p13*(p21*p32 - p22*p31) 
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;&amp;gt; &amp;nbsp;abs(solve(p)) 
&lt;br&gt;[1] 1.6920982 1.5520308 1.4688865 0.4688865 0.5520308 0.6920982
&lt;br&gt;&lt;br&gt;You see there is no unit root, which is one of the fandamental properties for a co-integrated VAR DGP.
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;&lt;quote author=&quot;RON70&quot;&gt;&lt;br&gt;Thanks Matifou for your reply. Yes I want to simulate VAR with those parameters. However here my problem is those parameters are estimated parameters not actual one. Therefore I dont think I can apply TVAR.simin() directly on those parameters. You see, ch equation for those estimated parameters doesnt give one unit root, which is the fundamental property for a co-integrated VAR DGP. 
&lt;br&gt;&lt;br&gt;Therefore I want to do some some tweaks so that I can get a revised parameter set from those estimated parameters such that ch. equation (based on revised parameters) gives exactly one unit root. Then I can use TVAR.simin() to generate data.
&lt;br&gt;&lt;br&gt;Therefore my question is : How can I tweak those estimated parameters?
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;matifou wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hi RON70
&lt;br&gt;&lt;br&gt;Not sure about what you want to do... So you want to simulate a VAR with 
&lt;br&gt;those parameters? There is the function TVAR.simin package tsDyn that 
&lt;br&gt;allow you to simulate a VAR, see:
&lt;br&gt;&lt;br&gt;co&amp;lt;-matrix(c(0.985, &amp;nbsp;0.283, -1.714, &amp;nbsp;0.125, &amp;nbsp;1.100, -1.491,0.071, 
&lt;br&gt;-0.089, &amp;nbsp;1.388), ncol=3, byrow=TRUE)
&lt;br&gt;library(tsDyn)
&lt;br&gt;&lt;br&gt;TVAR.sim(B=cbind(co,co),nthresh=0, inc=&amp;quot;none&amp;quot;, lag=2)
&lt;br&gt;&lt;br&gt;Hope this is what you wanted?
&lt;br&gt;&lt;br&gt;MAT2009
&lt;br&gt;&lt;br&gt;RON70 a écrit :
&lt;br&gt;&amp;gt; I think I should be more clear on what I would like to do. From that
&lt;br&gt;&amp;gt; estimated model I would like to get a &amp;quot;Real&amp;quot; VAR DGP, perhaps by tweaking
&lt;br&gt;&amp;gt; some of the coeficients. Which I would use to simulate artrificial data, for
&lt;br&gt;&amp;gt; some study. If somebody shows me some lihgt on how I can achive that, I
&lt;br&gt;&amp;gt; would be truly grateful.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Best,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; RON70 wrote:
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Hi all,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; My problem seems to be bizzare, however I want to do like that. Here I
&lt;br&gt;&amp;gt;&amp;gt; have estimated a VECM model from my dataset (seems not stationary) and
&lt;br&gt;&amp;gt;&amp;gt; once I converted those into a VAR representation I have following
&lt;br&gt;&amp;gt;&amp;gt; estimates :
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; A1; A2; A3; A4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 0.985 &amp;nbsp;0.283 -1.714
&lt;br&gt;&amp;gt;&amp;gt; 2 0.125 &amp;nbsp;1.100 -1.491
&lt;br&gt;&amp;gt;&amp;gt; 3 0.071 -0.089 &amp;nbsp;1.388
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 &amp;nbsp;0.258 -0.493 &amp;nbsp;1.459
&lt;br&gt;&amp;gt;&amp;gt; 2 &amp;nbsp;0.252 -0.387 &amp;nbsp;1.165
&lt;br&gt;&amp;gt;&amp;gt; 3 -0.057 &amp;nbsp;0.076 -0.536
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp;V3
&lt;br&gt;&amp;gt;&amp;gt; 1 0.332 -0.459 0.251
&lt;br&gt;&amp;gt;&amp;gt; 2 0.482 -0.686 0.313
&lt;br&gt;&amp;gt;&amp;gt; 3 0.112 -0.104 0.218
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp;V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 -0.532 0.624 -0.006
&lt;br&gt;&amp;gt;&amp;gt; 2 -0.619 0.714 -0.044
&lt;br&gt;&amp;gt;&amp;gt; 3 -0.129 0.121 -0.069
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Now I took them as an original DGP process and checked the solution of
&lt;br&gt;&amp;gt;&amp;gt; it's ch. equation. I got following :
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;library(PolynomF)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;z = polynom()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p11 &amp;lt;- 1 - A1[1,1]*z - A2[1,1]*z^2 - A3[1,1]*z^3 - A4[1,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p12 &amp;lt;- 0 - A1[1,2]*z - A2[1,2]*z^2 - A3[1,2]*z^3 - A4[1,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p13 &amp;lt;- 0 - A1[1,3]*z - A2[1,3]*z^2 - A3[1,3]*z^3 - A4[1,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p21 &amp;lt;- 0 - A1[2,1]*z - A2[2,1]*z^2 - A3[2,1]*z^3 - A4[2,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p22 &amp;lt;- 1 - A1[2,2]*z - A2[2,2]*z^2 - A3[2,2]*z^3 - A4[2,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p23 &amp;lt;- 0 - A1[2,3]*z - A2[2,3]*z^2 - A3[2,3]*z^3 - A4[2,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p31 &amp;lt;- 0 - A1[3,1]*z - A2[3,1]*z^2 - A3[3,1]*z^3 - A4[3,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p32 &amp;lt;- 0 - A1[3,2]*z - A2[3,2]*z^2 - A3[3,2]*z^3 - A4[3,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p33 &amp;lt;- 1 - A1[3,3]*z - A2[3,3]*z^2 - A3[3,3]*z^3 - A4[3,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p &amp;lt;- p11*(p22*p33 - p23*p32) - p12*(p21*p33 - p23*p31) + p13*(p21*p32 -
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p22*p31)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; abs(solve(p))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;[1] 1.521516 2.102119 2.102119 4.912478 4.912478 1.000233 1.000233
&lt;br&gt;&amp;gt;&amp;gt; 1.502034 1.502034 1.228100 2.536582 5.342635
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Now if I assume (upto a few significant digits) &amp;quot;1.000233 1.000233 &amp;quot; both
&lt;br&gt;&amp;gt;&amp;gt; equal to &amp;quot;1&amp;quot; then, I am actually getting two unit roots here. Therefore I
&lt;br&gt;&amp;gt;&amp;gt; am wondering how to tackle it as VAR is defined on max one unit root
&lt;br&gt;&amp;gt;&amp;gt; process. 
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Am I missing anything? Can anyone please help me?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Best
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;R-SIG-Finance@stat.math.ethz.ch mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
&lt;/quote&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/A-VaR-question-tp26508077p26535989.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535884</id>
	<title>Re: [R-sig-finance] A VaR question</title>
	<published>2009-11-26T22:24:19Z</published>
	<updated>2009-11-26T22:24:19Z</updated>
	<author>
		<name>RON70</name>
	</author>
	<content type="html">Thanks Matifou for your reply. Yes I want to simulate VAR with those parameters. However here my problem is those parameters are estimated parameters not actual one. Therefore I dont think I can apply TVAR.simin() directly on those parameters. You see, ch equation for those estimated parameters doesnt give one unit root, which is the fundamental property for a co-integrated VAR DGP. 
&lt;br&gt;&lt;br&gt;Therefore I want to do some some tweaks so that I can get a revised parameter set from those estimated parameters such that ch. equation (based on revised parameters) gives exactly one unit root. Then I can use TVAR.simin() to generate data.
&lt;br&gt;&lt;br&gt;Therefore my question is : How can I tweak those estimated parameters?
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;matifou wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hi RON70
&lt;br&gt;&lt;br&gt;Not sure about what you want to do... So you want to simulate a VAR with 
&lt;br&gt;those parameters? There is the function TVAR.simin package tsDyn that 
&lt;br&gt;allow you to simulate a VAR, see:
&lt;br&gt;&lt;br&gt;co&amp;lt;-matrix(c(0.985, &amp;nbsp;0.283, -1.714, &amp;nbsp;0.125, &amp;nbsp;1.100, -1.491,0.071, 
&lt;br&gt;-0.089, &amp;nbsp;1.388), ncol=3, byrow=TRUE)
&lt;br&gt;library(tsDyn)
&lt;br&gt;&lt;br&gt;TVAR.sim(B=cbind(co,co),nthresh=0, inc=&amp;quot;none&amp;quot;, lag=2)
&lt;br&gt;&lt;br&gt;Hope this is what you wanted?
&lt;br&gt;&lt;br&gt;MAT2009
&lt;br&gt;&lt;br&gt;RON70 a écrit :
&lt;br&gt;&amp;gt; I think I should be more clear on what I would like to do. From that
&lt;br&gt;&amp;gt; estimated model I would like to get a &amp;quot;Real&amp;quot; VAR DGP, perhaps by tweaking
&lt;br&gt;&amp;gt; some of the coeficients. Which I would use to simulate artrificial data, for
&lt;br&gt;&amp;gt; some study. If somebody shows me some lihgt on how I can achive that, I
&lt;br&gt;&amp;gt; would be truly grateful.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Best,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; RON70 wrote:
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Hi all,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; My problem seems to be bizzare, however I want to do like that. Here I
&lt;br&gt;&amp;gt;&amp;gt; have estimated a VECM model from my dataset (seems not stationary) and
&lt;br&gt;&amp;gt;&amp;gt; once I converted those into a VAR representation I have following
&lt;br&gt;&amp;gt;&amp;gt; estimates :
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; A1; A2; A3; A4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 0.985 &amp;nbsp;0.283 -1.714
&lt;br&gt;&amp;gt;&amp;gt; 2 0.125 &amp;nbsp;1.100 -1.491
&lt;br&gt;&amp;gt;&amp;gt; 3 0.071 -0.089 &amp;nbsp;1.388
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 &amp;nbsp;0.258 -0.493 &amp;nbsp;1.459
&lt;br&gt;&amp;gt;&amp;gt; 2 &amp;nbsp;0.252 -0.387 &amp;nbsp;1.165
&lt;br&gt;&amp;gt;&amp;gt; 3 -0.057 &amp;nbsp;0.076 -0.536
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp;V3
&lt;br&gt;&amp;gt;&amp;gt; 1 0.332 -0.459 0.251
&lt;br&gt;&amp;gt;&amp;gt; 2 0.482 -0.686 0.313
&lt;br&gt;&amp;gt;&amp;gt; 3 0.112 -0.104 0.218
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp;V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 -0.532 0.624 -0.006
&lt;br&gt;&amp;gt;&amp;gt; 2 -0.619 0.714 -0.044
&lt;br&gt;&amp;gt;&amp;gt; 3 -0.129 0.121 -0.069
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Now I took them as an original DGP process and checked the solution of
&lt;br&gt;&amp;gt;&amp;gt; it's ch. equation. I got following :
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;library(PolynomF)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;z = polynom()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p11 &amp;lt;- 1 - A1[1,1]*z - A2[1,1]*z^2 - A3[1,1]*z^3 - A4[1,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p12 &amp;lt;- 0 - A1[1,2]*z - A2[1,2]*z^2 - A3[1,2]*z^3 - A4[1,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p13 &amp;lt;- 0 - A1[1,3]*z - A2[1,3]*z^2 - A3[1,3]*z^3 - A4[1,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p21 &amp;lt;- 0 - A1[2,1]*z - A2[2,1]*z^2 - A3[2,1]*z^3 - A4[2,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p22 &amp;lt;- 1 - A1[2,2]*z - A2[2,2]*z^2 - A3[2,2]*z^3 - A4[2,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p23 &amp;lt;- 0 - A1[2,3]*z - A2[2,3]*z^2 - A3[2,3]*z^3 - A4[2,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p31 &amp;lt;- 0 - A1[3,1]*z - A2[3,1]*z^2 - A3[3,1]*z^3 - A4[3,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p32 &amp;lt;- 0 - A1[3,2]*z - A2[3,2]*z^2 - A3[3,2]*z^3 - A4[3,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p33 &amp;lt;- 1 - A1[3,3]*z - A2[3,3]*z^2 - A3[3,3]*z^3 - A4[3,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p &amp;lt;- p11*(p22*p33 - p23*p32) - p12*(p21*p33 - p23*p31) + p13*(p21*p32 -
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p22*p31)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; abs(solve(p))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;[1] 1.521516 2.102119 2.102119 4.912478 4.912478 1.000233 1.000233
&lt;br&gt;&amp;gt;&amp;gt; 1.502034 1.502034 1.228100 2.536582 5.342635
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Now if I assume (upto a few significant digits) &amp;quot;1.000233 1.000233 &amp;quot; both
&lt;br&gt;&amp;gt;&amp;gt; equal to &amp;quot;1&amp;quot; then, I am actually getting two unit roots here. Therefore I
&lt;br&gt;&amp;gt;&amp;gt; am wondering how to tackle it as VAR is defined on max one unit root
&lt;br&gt;&amp;gt;&amp;gt; process. 
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Am I missing anything? Can anyone please help me?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Best
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;R-SIG-Finance@stat.math.ethz.ch mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/A-VaR-question-tp26508077p26535884.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534771</id>
	<title>Re: [R-sig-finance] A VaR question</title>
	<published>2009-11-26T12:52:56Z</published>
	<updated>2009-11-26T12:52:56Z</updated>
	<author>
		<name>matifou</name>
	</author>
	<content type="html">Hi RON70
&lt;br&gt;&lt;br&gt;Not sure about what you want to do... So you want to simulate a VAR with 
&lt;br&gt;those parameters? There is the function TVAR.simin package tsDyn that 
&lt;br&gt;allow you to simulate a VAR, see:
&lt;br&gt;&lt;br&gt;co&amp;lt;-matrix(c(0.985, &amp;nbsp;0.283, -1.714, &amp;nbsp;0.125, &amp;nbsp;1.100, -1.491,0.071, 
&lt;br&gt;-0.089, &amp;nbsp;1.388), ncol=3, byrow=TRUE)
&lt;br&gt;library(tsDyn)
&lt;br&gt;&lt;br&gt;TVAR.sim(B=cbind(co,co),nthresh=0, inc=&amp;quot;none&amp;quot;, lag=2)
&lt;br&gt;&lt;br&gt;Hope this is what you wanted?
&lt;br&gt;&lt;br&gt;MAT2009
&lt;br&gt;&lt;br&gt;RON70 a écrit :
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I think I should be more clear on what I would like to do. From that
&lt;br&gt;&amp;gt; estimated model I would like to get a &amp;quot;Real&amp;quot; VAR DGP, perhaps by tweaking
&lt;br&gt;&amp;gt; some of the coeficients. Which I would use to simulate artrificial data, for
&lt;br&gt;&amp;gt; some study. If somebody shows me some lihgt on how I can achive that, I
&lt;br&gt;&amp;gt; would be truly grateful.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Best,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; RON70 wrote:
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Hi all,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; My problem seems to be bizzare, however I want to do like that. Here I
&lt;br&gt;&amp;gt;&amp;gt; have estimated a VECM model from my dataset (seems not stationary) and
&lt;br&gt;&amp;gt;&amp;gt; once I converted those into a VAR representation I have following
&lt;br&gt;&amp;gt;&amp;gt; estimates :
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; A1; A2; A3; A4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 0.985 &amp;nbsp;0.283 -1.714
&lt;br&gt;&amp;gt;&amp;gt; 2 0.125 &amp;nbsp;1.100 -1.491
&lt;br&gt;&amp;gt;&amp;gt; 3 0.071 -0.089 &amp;nbsp;1.388
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 &amp;nbsp;0.258 -0.493 &amp;nbsp;1.459
&lt;br&gt;&amp;gt;&amp;gt; 2 &amp;nbsp;0.252 -0.387 &amp;nbsp;1.165
&lt;br&gt;&amp;gt;&amp;gt; 3 -0.057 &amp;nbsp;0.076 -0.536
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp;V3
&lt;br&gt;&amp;gt;&amp;gt; 1 0.332 -0.459 0.251
&lt;br&gt;&amp;gt;&amp;gt; 2 0.482 -0.686 0.313
&lt;br&gt;&amp;gt;&amp;gt; 3 0.112 -0.104 0.218
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp;V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;&amp;gt;&amp;gt; 1 -0.532 0.624 -0.006
&lt;br&gt;&amp;gt;&amp;gt; 2 -0.619 0.714 -0.044
&lt;br&gt;&amp;gt;&amp;gt; 3 -0.129 0.121 -0.069
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Now I took them as an original DGP process and checked the solution of
&lt;br&gt;&amp;gt;&amp;gt; it's ch. equation. I got following :
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;library(PolynomF)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;z = polynom()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p11 &amp;lt;- 1 - A1[1,1]*z - A2[1,1]*z^2 - A3[1,1]*z^3 - A4[1,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p12 &amp;lt;- 0 - A1[1,2]*z - A2[1,2]*z^2 - A3[1,2]*z^3 - A4[1,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p13 &amp;lt;- 0 - A1[1,3]*z - A2[1,3]*z^2 - A3[1,3]*z^3 - A4[1,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p21 &amp;lt;- 0 - A1[2,1]*z - A2[2,1]*z^2 - A3[2,1]*z^3 - A4[2,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p22 &amp;lt;- 1 - A1[2,2]*z - A2[2,2]*z^2 - A3[2,2]*z^3 - A4[2,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p23 &amp;lt;- 0 - A1[2,3]*z - A2[2,3]*z^2 - A3[2,3]*z^3 - A4[2,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p31 &amp;lt;- 0 - A1[3,1]*z - A2[3,1]*z^2 - A3[3,1]*z^3 - A4[3,1]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p32 &amp;lt;- 0 - A1[3,2]*z - A2[3,2]*z^2 - A3[3,2]*z^3 - A4[3,2]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p33 &amp;lt;- 1 - A1[3,3]*z - A2[3,3]*z^2 - A3[3,3]*z^3 - A4[3,3]*z^4
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p &amp;lt;- p11*(p22*p33 - p23*p32) - p12*(p21*p33 - p23*p31) + p13*(p21*p32 -
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; p22*p31)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; abs(solve(p))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;[1] 1.521516 2.102119 2.102119 4.912478 4.912478 1.000233 1.000233
&lt;br&gt;&amp;gt;&amp;gt; 1.502034 1.502034 1.228100 2.536582 5.342635
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Now if I assume (upto a few significant digits) &amp;quot;1.000233 1.000233 &amp;quot; both
&lt;br&gt;&amp;gt;&amp;gt; equal to &amp;quot;1&amp;quot; then, I am actually getting two unit roots here. Therefore I
&lt;br&gt;&amp;gt;&amp;gt; am wondering how to tackle it as VAR is defined on max one unit root
&lt;br&gt;&amp;gt;&amp;gt; process. 
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Am I missing anything? Can anyone please help me?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Best
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26534771&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/A-VaR-question-tp26508077p26534771.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26512049</id>
	<title>Re: how use the results of rollapply in the previous row to the next row...</title>
	<published>2009-11-25T04:36:39Z</published>
	<updated>2009-11-25T04:36:39Z</updated>
	<author>
		<name>Gabor Grothendieck</name>
	</author>
	<content type="html">Your example has an index not supported by xts so I will assume your
&lt;br&gt;object is a zoo object. &amp;nbsp;All xts objects are zoo objects anyways. &amp;nbsp;If
&lt;br&gt;your actual data has a different class of index than shown here then
&lt;br&gt;the code below should also work with xts.
&lt;br&gt;&lt;br&gt;Try Reduce. &amp;nbsp;Note that if your real data is large this might not be very fast.
&lt;br&gt;&lt;br&gt;&amp;gt; library(zoo)
&lt;br&gt;&amp;gt; x &amp;lt;- zoo(cbind(c1 = 1:5, c2 = 1:5))
&lt;br&gt;&amp;gt; f &amp;lt;- function(acc, x) sum(x) / acc
&lt;br&gt;&amp;gt; x$c3 &amp;lt;- Reduce(f, split(coredata(x), time(x)), 1, acc = TRUE)[-1]
&lt;br&gt;&amp;gt; x
&lt;br&gt;&amp;nbsp; c1 c2 &amp;nbsp; &amp;nbsp; &amp;nbsp; c3
&lt;br&gt;1 &amp;nbsp;1 &amp;nbsp;1 2.000000
&lt;br&gt;2 &amp;nbsp;2 &amp;nbsp;2 2.000000
&lt;br&gt;3 &amp;nbsp;3 &amp;nbsp;3 3.000000
&lt;br&gt;4 &amp;nbsp;4 &amp;nbsp;4 2.666667
&lt;br&gt;5 &amp;nbsp;5 &amp;nbsp;5 3.750000
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Tue, Nov 24, 2009 at 11:38 PM, Jiri Hoogland &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26512049&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jiri.hoogland@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; say I have a xts object x with data I want to apply a function f over row by
&lt;br&gt;&amp;gt; row (by.column=F)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; x =
&lt;br&gt;&amp;gt; index c1 c2  c3
&lt;br&gt;&amp;gt; 1       1   1    0
&lt;br&gt;&amp;gt; 2       2   2    0
&lt;br&gt;&amp;gt; 3       3   3    0
&lt;br&gt;&amp;gt; 4       4   4    0
&lt;br&gt;&amp;gt; 5       5   5    0
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; what i would like to do and i am not sure that that is possible is the
&lt;br&gt;&amp;gt; following
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; the result of operating on one row is put in the last column of x of that
&lt;br&gt;&amp;gt; same row
&lt;br&gt;&amp;gt; and is used in the operation on the next row, where f is some non-trivial
&lt;br&gt;&amp;gt; function of the columns
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So for example the simple function summing over the row
&lt;br&gt;&amp;gt; and normalizing by the previous value of the last columns value in the
&lt;br&gt;&amp;gt; previous row
&lt;br&gt;&amp;gt; (first row does not normalize here)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; x =
&lt;br&gt;&amp;gt; index c1 c2   c3
&lt;br&gt;&amp;gt; 1       1   1    2      = 1+1
&lt;br&gt;&amp;gt; 2       2   2    2      = 2/2+2/2 = 2
&lt;br&gt;&amp;gt; 3       3   3    3      = 3/2+3/2 = 3
&lt;br&gt;&amp;gt; 4       4   4    8/3   = 4/3+4/3
&lt;br&gt;&amp;gt; 5       5   5    15/4 = 5/8*3+5/8*3
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is there some way to sneak this into rollapply?
&lt;br&gt;&amp;gt; Maybe I am asking too much, but if somebody
&lt;br&gt;&amp;gt; can enlighten it would be greatly appreciated
&lt;br&gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt; Jiri
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;        [[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26512049&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26512049&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/how-use-the-results-of-rollapply-in-the-previous-row-to-the-next-row...-tp26507465p26512049.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26511532</id>
	<title>Re: how use the results of rollapply in the	previousrow to the next row...</title>
	<published>2009-11-25T03:59:52Z</published>
	<updated>2009-11-25T03:59:52Z</updated>
	<author>
		<name>Sandor Benczik</name>
	</author>
	<content type="html">Hi Jiri,
&lt;br&gt;&lt;br&gt;I found that problems with recursive definitions involving multiple
&lt;br&gt;vectors/columns are usually next to impossible to tackle without for
&lt;br&gt;loops, or without rewriting the formula in a non-recursive way. For your
&lt;br&gt;case here is a kludge:
&lt;br&gt;&lt;br&gt;&amp;gt; a &amp;lt;- data.frame(c1 = 1:5, c2 = 1:5)
&lt;br&gt;&amp;gt; sum.col &amp;lt;- apply(a, 1, sum)
&lt;br&gt;&amp;gt; norms &amp;lt;- exp(c(1,-1) * cumsum(c(1,-1)*log(sum.col)))
&lt;br&gt;Warning messages:
&lt;br&gt;1: In c(1, -1) * log(sum.col) :
&lt;br&gt;&amp;nbsp; longer object length is not a multiple of shorter object length
&lt;br&gt;2: In c(1, -1) * cumsum(c(1, -1) * log(sum.col)) :
&lt;br&gt;&amp;nbsp; longer object length is not a multiple of shorter object length
&lt;br&gt;&amp;gt; sum.col / c(1, norms[-length(norms)])
&lt;br&gt;[1] 2.000000 2.000000 3.000000 2.666667 3.750000
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;Sandor
&lt;br&gt;&lt;br&gt;PS. I think the generally accepted view is that such questions belong to
&lt;br&gt;the general R-help list, not being related to finance.
&lt;br&gt;&lt;br&gt;On Wed, 2009-11-25 at 06:38 +0200, Jiri Hoogland wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; say I have a xts object x with data I want to apply a function f over
&lt;br&gt;&amp;gt; row by
&lt;br&gt;&amp;gt; row (by.column=F)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; x =
&lt;br&gt;&amp;gt; index c1 c2 &amp;nbsp;c3
&lt;br&gt;&amp;gt; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;&amp;gt; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;&amp;gt; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;&amp;gt; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;&amp;gt; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; what i would like to do and i am not sure that that is possible is the
&lt;br&gt;&amp;gt; following
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; the result of operating on one row is put in the last column of x of
&lt;br&gt;&amp;gt; that
&lt;br&gt;&amp;gt; same row
&lt;br&gt;&amp;gt; and is used in the operation on the next row, where f is some
&lt;br&gt;&amp;gt; non-trivial
&lt;br&gt;&amp;gt; function of the columns
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; So for example the simple function summing over the row
&lt;br&gt;&amp;gt; and normalizing by the previous value of the last columns value in the
&lt;br&gt;&amp;gt; previous row
&lt;br&gt;&amp;gt; (first row does not normalize here)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; x =
&lt;br&gt;&amp;gt; index c1 c2 &amp;nbsp; c3
&lt;br&gt;&amp;gt; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;= 1+1
&lt;br&gt;&amp;gt; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;= 2/2+2/2 = 2
&lt;br&gt;&amp;gt; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;= 3/2+3/2 = 3
&lt;br&gt;&amp;gt; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp;8/3 &amp;nbsp; = 4/3+4/3
&lt;br&gt;&amp;gt; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;15/4 = 5/8*3+5/8*3
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Is there some way to sneak this into rollapply?
&lt;br&gt;&amp;gt; Maybe I am asking too much, but if somebody
&lt;br&gt;&amp;gt; can enlighten it would be greatly appreciated
&lt;br&gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt; Jiri
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26511532&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26511532&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/how-use-the-results-of-rollapply-in-the-previous-row-to-the-next-row...-tp26507465p26511532.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26509688</id>
	<title>Re: A VaR question</title>
	<published>2009-11-25T01:29:15Z</published>
	<updated>2009-11-25T01:29:15Z</updated>
	<author>
		<name>RON70</name>
	</author>
	<content type="html">I think I should be more clear on what I would like to do. From that estimated model I would like to get a &amp;quot;Real&amp;quot; VAR DGP, perhaps by tweaking some of the coeficients. Which I would use to simulate artrificial data, for some study. If somebody shows me some lihgt on how I can achive that, I would be truly grateful.
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;RON70 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hi all,
&lt;br&gt;&lt;br&gt;My problem seems to be bizzare, however I want to do like that. Here I have estimated a VECM model from my dataset (seems not stationary) and once I converted those into a VAR representation I have following estimates :
&lt;br&gt;&lt;br&gt;&amp;gt; A1; A2; A3; A4
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;1 0.985 &amp;nbsp;0.283 -1.714
&lt;br&gt;2 0.125 &amp;nbsp;1.100 -1.491
&lt;br&gt;3 0.071 -0.089 &amp;nbsp;1.388
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;1 &amp;nbsp;0.258 -0.493 &amp;nbsp;1.459
&lt;br&gt;2 &amp;nbsp;0.252 -0.387 &amp;nbsp;1.165
&lt;br&gt;3 -0.057 &amp;nbsp;0.076 -0.536
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp;V3
&lt;br&gt;1 0.332 -0.459 0.251
&lt;br&gt;2 0.482 -0.686 0.313
&lt;br&gt;3 0.112 -0.104 0.218
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp;V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;1 -0.532 0.624 -0.006
&lt;br&gt;2 -0.619 0.714 -0.044
&lt;br&gt;3 -0.129 0.121 -0.069
&lt;br&gt;&lt;br&gt;Now I took them as an original DGP process and checked the solution of it's ch. equation. I got following :
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp;library(PolynomF)
&lt;br&gt;&amp;gt; &amp;nbsp;z = polynom()
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p11 &amp;lt;- 1 - A1[1,1]*z - A2[1,1]*z^2 - A3[1,1]*z^3 - A4[1,1]*z^4
&lt;br&gt;&amp;gt; p12 &amp;lt;- 0 - A1[1,2]*z - A2[1,2]*z^2 - A3[1,2]*z^3 - A4[1,2]*z^4
&lt;br&gt;&amp;gt; p13 &amp;lt;- 0 - A1[1,3]*z - A2[1,3]*z^2 - A3[1,3]*z^3 - A4[1,3]*z^4
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p21 &amp;lt;- 0 - A1[2,1]*z - A2[2,1]*z^2 - A3[2,1]*z^3 - A4[2,1]*z^4
&lt;br&gt;&amp;gt; p22 &amp;lt;- 1 - A1[2,2]*z - A2[2,2]*z^2 - A3[2,2]*z^3 - A4[2,2]*z^4
&lt;br&gt;&amp;gt; p23 &amp;lt;- 0 - A1[2,3]*z - A2[2,3]*z^2 - A3[2,3]*z^3 - A4[2,3]*z^4
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p31 &amp;lt;- 0 - A1[3,1]*z - A2[3,1]*z^2 - A3[3,1]*z^3 - A4[3,1]*z^4
&lt;br&gt;&amp;gt; p32 &amp;lt;- 0 - A1[3,2]*z - A2[3,2]*z^2 - A3[3,2]*z^3 - A4[3,2]*z^4
&lt;br&gt;&amp;gt; p33 &amp;lt;- 1 - A1[3,3]*z - A2[3,3]*z^2 - A3[3,3]*z^3 - A4[3,3]*z^4
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p &amp;lt;- p11*(p22*p33 - p23*p32) - p12*(p21*p33 - p23*p31) + p13*(p21*p32 - p22*p31)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; abs(solve(p))
&lt;br&gt;&amp;nbsp;[1] 1.521516 2.102119 2.102119 4.912478 4.912478 1.000233 1.000233 1.502034 1.502034 1.228100 2.536582 5.342635
&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;Now if I assume (upto a few significant digits) &amp;quot;1.000233 1.000233 &amp;quot; both equal to &amp;quot;1&amp;quot; then, I am actually getting two unit roots here. Therefore I am wondering how to tackle it as VAR is defined on max one unit root process. 
&lt;br&gt;&lt;br&gt;Am I missing anything? Can anyone please help me?
&lt;br&gt;&lt;br&gt;Best
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/A-VaR-question-tp26508077p26509688.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26508077</id>
	<title>A VaR question</title>
	<published>2009-11-24T22:21:37Z</published>
	<updated>2009-11-24T22:21:37Z</updated>
	<author>
		<name>RON70</name>
	</author>
	<content type="html">Hi all,
&lt;br&gt;&lt;br&gt;My problem seems to be bizzare, however I want to do like that. Here I have estimated a VECM model from my dataset (seems not stationary) and once I converted those into a VAR representation I have following estimates :
&lt;br&gt;&lt;br&gt;&amp;gt; A1; A2; A3; A4
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;1 0.985 &amp;nbsp;0.283 -1.714
&lt;br&gt;2 0.125 &amp;nbsp;1.100 -1.491
&lt;br&gt;3 0.071 -0.089 &amp;nbsp;1.388
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;1 &amp;nbsp;0.258 -0.493 &amp;nbsp;1.459
&lt;br&gt;2 &amp;nbsp;0.252 -0.387 &amp;nbsp;1.165
&lt;br&gt;3 -0.057 &amp;nbsp;0.076 -0.536
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;V1 &amp;nbsp; &amp;nbsp; V2 &amp;nbsp; &amp;nbsp;V3
&lt;br&gt;1 0.332 -0.459 0.251
&lt;br&gt;2 0.482 -0.686 0.313
&lt;br&gt;3 0.112 -0.104 0.218
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; V1 &amp;nbsp; &amp;nbsp;V2 &amp;nbsp; &amp;nbsp; V3
&lt;br&gt;1 -0.532 0.624 -0.006
&lt;br&gt;2 -0.619 0.714 -0.044
&lt;br&gt;3 -0.129 0.121 -0.069
&lt;br&gt;&lt;br&gt;Now I took them as an original DGP process and checked the solution of it's ch. equation. I got following :
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp;library(PolynomF)
&lt;br&gt;&amp;gt; &amp;nbsp;z = polynom()
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p11 &amp;lt;- 1 - A1[1,1]*z - A2[1,1]*z^2 - A3[1,1]*z^3 - A4[1,1]*z^4
&lt;br&gt;&amp;gt; p12 &amp;lt;- 0 - A1[1,2]*z - A2[1,2]*z^2 - A3[1,2]*z^3 - A4[1,2]*z^4
&lt;br&gt;&amp;gt; p13 &amp;lt;- 0 - A1[1,3]*z - A2[1,3]*z^2 - A3[1,3]*z^3 - A4[1,3]*z^4
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p21 &amp;lt;- 0 - A1[2,1]*z - A2[2,1]*z^2 - A3[2,1]*z^3 - A4[2,1]*z^4
&lt;br&gt;&amp;gt; p22 &amp;lt;- 1 - A1[2,2]*z - A2[2,2]*z^2 - A3[2,2]*z^3 - A4[2,2]*z^4
&lt;br&gt;&amp;gt; p23 &amp;lt;- 0 - A1[2,3]*z - A2[2,3]*z^2 - A3[2,3]*z^3 - A4[2,3]*z^4
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p31 &amp;lt;- 0 - A1[3,1]*z - A2[3,1]*z^2 - A3[3,1]*z^3 - A4[3,1]*z^4
&lt;br&gt;&amp;gt; p32 &amp;lt;- 0 - A1[3,2]*z - A2[3,2]*z^2 - A3[3,2]*z^3 - A4[3,2]*z^4
&lt;br&gt;&amp;gt; p33 &amp;lt;- 1 - A1[3,3]*z - A2[3,3]*z^2 - A3[3,3]*z^3 - A4[3,3]*z^4
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; p &amp;lt;- p11*(p22*p33 - p23*p32) - p12*(p21*p33 - p23*p31) + p13*(p21*p32 - p22*p31)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; abs(solve(p))
&lt;br&gt;&amp;nbsp;[1] 1.521516 2.102119 2.102119 4.912478 4.912478 1.000233 1.000233 1.502034 1.502034 1.228100 2.536582 5.342635
&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;Now if I assume (upto a few significant digits) &amp;quot;1.000233 1.000233 &amp;quot; both equal to &amp;quot;1&amp;quot; then, I am actually getting two unit roots here. Therefore I am wondering how to tackle it as VAR is defined on max one unit root process. 
&lt;br&gt;&lt;br&gt;Am I missing anything? Can anyone please help me?
&lt;br&gt;&lt;br&gt;Best</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/A-VaR-question-tp26508077p26508077.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26507465</id>
	<title>how use the results of rollapply in the previous row to the next row...</title>
	<published>2009-11-24T20:38:34Z</published>
	<updated>2009-11-24T20:38:34Z</updated>
	<author>
		<name>Jiri Hoogland</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;say I have a xts object x with data I want to apply a function f over row by
&lt;br&gt;row (by.column=F)
&lt;br&gt;&lt;br&gt;x =
&lt;br&gt;index c1 c2 &amp;nbsp;c3
&lt;br&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;0
&lt;br&gt;&lt;br&gt;what i would like to do and i am not sure that that is possible is the
&lt;br&gt;following
&lt;br&gt;&lt;br&gt;the result of operating on one row is put in the last column of x of that
&lt;br&gt;same row
&lt;br&gt;and is used in the operation on the next row, where f is some non-trivial
&lt;br&gt;function of the columns
&lt;br&gt;&lt;br&gt;So for example the simple function summing over the row
&lt;br&gt;and normalizing by the previous value of the last columns value in the
&lt;br&gt;previous row
&lt;br&gt;(first row does not normalize here)
&lt;br&gt;&lt;br&gt;x =
&lt;br&gt;index c1 c2 &amp;nbsp; c3
&lt;br&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; 1 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;= 1+1
&lt;br&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; 2 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;= 2/2+2/2 = 2
&lt;br&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp;= 3/2+3/2 = 3
&lt;br&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; 4 &amp;nbsp; &amp;nbsp;8/3 &amp;nbsp; = 4/3+4/3
&lt;br&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; 5 &amp;nbsp; &amp;nbsp;15/4 = 5/8*3+5/8*3
&lt;br&gt;&lt;br&gt;Is there some way to sneak this into rollapply?
&lt;br&gt;Maybe I am asking too much, but if somebody
&lt;br&gt;can enlighten it would be greatly appreciated
&lt;br&gt;Thanks!
&lt;br&gt;Jiri
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26507465&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/how-use-the-results-of-rollapply-in-the-previous-row-to-the-next-row...-tp26507465p26507465.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26495360</id>
	<title>Re: R: Use VAR model to predict response to change in values of certain variables</title>
	<published>2009-11-24T04:53:17Z</published>
	<updated>2009-11-24T04:53:17Z</updated>
	<author>
		<name>Karl Schriek</name>
	</author>
	<content type="html">Mat
&lt;br&gt;&lt;br&gt;Thanks a lot, that is exactly what I am looking for!
&lt;br&gt;&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;Karl
&lt;br&gt;&lt;br&gt;On Tue, Nov 24, 2009 at 2:23 PM, Matthieu Stigler &amp;lt;
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;matthieu.stigler@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Same remark as before, please provide reproducible code!!
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Ok, sorry, showed only the case for var, not vec2var. Well it is more
&lt;br&gt;&amp;gt; complicated as there is no corresponding lm object.
&lt;br&gt;&amp;gt; (reason is the var in level you obtain is estimated under constraint
&lt;br&gt;&amp;gt; of cointegration, so estimating yourself with usual lm won't lead to
&lt;br&gt;&amp;gt; same results).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So what you do is simply extract the coef and mutliply with your
&lt;br&gt;&amp;gt; predicted values, something like (using again last value, so can see
&lt;br&gt;&amp;gt; it's same as using predict):
&lt;br&gt;&amp;gt; data(Canada)
&lt;br&gt;&amp;gt; sjf.vecm &amp;lt;- ca.jo(Canada, ecdet = &amp;quot;none&amp;quot;, type = &amp;quot;eigen&amp;quot;, K = 2,spec =
&lt;br&gt;&amp;gt; &amp;quot;longrun&amp;quot;)
&lt;br&gt;&amp;gt; converted&amp;lt;- &amp;nbsp; vec2var(sjf.vecm, r = 1)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; coefe&amp;lt;-c( converted$A$A1[1,],
&lt;br&gt;&amp;gt; converted$deterministic[1],converted$A$A2[1,])
&lt;br&gt;&amp;gt; predval&amp;lt;-converted$datamat[nrow(converted$datamat),c(1:9)]
&lt;br&gt;&amp;gt; coefe%*%predval
&lt;br&gt;&amp;gt; predict(converted, n.ahead=1)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Hope this helps
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Mat
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 2009/11/24 Karl Schriek &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;kschriek@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; &amp;gt; Hi Mat
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Yes, this is exactly what I would like to do. Only problem this that I
&lt;br&gt;&amp;gt; &amp;gt; generate the model using VECM and and then convert to VAR form using
&lt;br&gt;&amp;gt; &amp;gt; vec2var. (i.e. the object is of type vec2var, not varest)
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; I am not sure how to extract the lm from vec2var.
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Karl
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; On Mon, Nov 23, 2009 at 3:46 PM, Matthieu Stigler &amp;lt;
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;matthieu.stigler@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Hi Karl
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Please provide reproducible code when you ask questions, we don't have
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; access to your local drive!!
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; So use rather datasets in R, as for example:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; data(Canada)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; colnames(Canada)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;nbsp;var.2c &amp;lt;- VAR(Canada, p = 1, type = &amp;quot;none&amp;quot;)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; You will note that there is a predict.varest function which does
&lt;br&gt;&amp;gt; forecasts:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; pred&amp;lt;-predict(var.2c, n.ahead = 8, ci = 0.95)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; This is not exactly what you want... you want to change some
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; forecasted values, and see the influence, right? This is not available
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; i the predict.varest. You will need to do some manipulations,
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; basically extracting the lm object and using predict(lm, newdata)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Construct data frame with forecasted values. It should include all
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; variables you see when in the output of var.2c. To keep simple, I used
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; the simplest model (1 lag, no intercept), so need only to give 4
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; values (the lag-1). For the example, I took last dat of data Canada,
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; change as you want:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; :
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; yourPred&amp;lt;-as.data.frame(matrix(Canada[nrow(Canada),], nrow=1))
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; colnames(yourPred)&amp;lt;-colnames(model.frame(var.2c$varresult$e))[-1] #you
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; need to give same names as in var result!
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; predict(var.2c$varresult$e, newdata=yourPred)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Note that this is exactly the same as what does forecast.varest,
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; except you can now change it manually!
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; pred$fcst$e[1,1]
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; And now you can change the values in yourPred as you want.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Hope this helps
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Mat
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; 2009/11/23 Karl Schriek &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;kschriek@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; Hi
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; I've fitted a VECM model in R, and converted in to a VAR
&lt;br&gt;&amp;gt; representation.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; I
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; would like to use this model to predict the future value of a response
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; variable based on different scenarios for the explanatory variables.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; Here is the code for the model:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; library(urca)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; library(vars)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; input &amp;lt;-read.csv(&amp;quot;data.csv&amp;quot;)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; ts &amp;lt;- ts(input[16:52,],c(2000,1),frequency=4)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; dat1 &amp;lt;- cbind(ts[,&amp;quot;dx&amp;quot;], ts[,&amp;quot;u&amp;quot;],
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; ts[,&amp;quot;cci&amp;quot;],ts[,&amp;quot;bci&amp;quot;],ts[,&amp;quot;cpi&amp;quot;],ts[,&amp;quot;gdp&amp;quot;])
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; args('ca.jo')
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; vecm &amp;lt;- ca.jo(dat1, type = 'trace', K = 2, season =
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; NULL,spec=&amp;quot;longrun&amp;quot;,dumvar=NULL)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; vecm.var &amp;lt;- vec2var(vecm,r=2)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; Now what I would like do is to predict &amp;quot;dx&amp;quot; into the future by varying
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; the
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; others. I am not sure if something like &amp;quot;predict dx if
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; u=30,cpi=15,bci=50,gdp=...&amp;quot; in the next period would work. So what I
&lt;br&gt;&amp;gt; have
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; in
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; mind is something along the lines of: increase &amp;quot;u&amp;quot; by 15% in the next
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; period
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; (which would obviously impact on all the other variables as well,
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; including
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; &amp;quot;dx&amp;quot;) and predict the impact into the future.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; Also, I am not sure if the &amp;quot;vec2var&amp;quot; step is necessary, so please
&lt;br&gt;&amp;gt; ignore
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; it
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; if you think it is redundant.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; Thanks
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; Karl
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[[alternative HTML version deleted]]
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[[alternative HTML version deleted]]
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; &amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [[alternative HTML version deleted]]
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495360&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/R%3A-Use-VAR-model-to-predict-response-to-change-in-values-of-certain-variables-tp26477723p26495360.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26495006</id>
	<title>Re: R: Use VAR model to predict response to change in values of certain variables</title>
	<published>2009-11-24T04:23:44Z</published>
	<updated>2009-11-24T04:23:44Z</updated>
	<author>
		<name>matifou</name>
	</author>
	<content type="html">Same remark as before, please provide reproducible code!!
&lt;br&gt;&lt;br&gt;Ok, sorry, showed only the case for var, not vec2var. Well it is more
&lt;br&gt;complicated as there is no corresponding lm object.
&lt;br&gt;(reason is the var in level you obtain is estimated under constraint
&lt;br&gt;of cointegration, so estimating yourself with usual lm won't lead to
&lt;br&gt;same results).
&lt;br&gt;&lt;br&gt;So what you do is simply extract the coef and mutliply with your
&lt;br&gt;predicted values, something like (using again last value, so can see
&lt;br&gt;it's same as using predict):
&lt;br&gt;data(Canada)
&lt;br&gt;sjf.vecm &amp;lt;- ca.jo(Canada, ecdet = &amp;quot;none&amp;quot;, type = &amp;quot;eigen&amp;quot;, K = 2,spec =
&lt;br&gt;&amp;quot;longrun&amp;quot;)
&lt;br&gt;converted&amp;lt;- &amp;nbsp; vec2var(sjf.vecm, r = 1)
&lt;br&gt;&lt;br&gt;coefe&amp;lt;-c( converted$A$A1[1,], converted$deterministic[1],converted$A$A2[1,])
&lt;br&gt;predval&amp;lt;-converted$datamat[nrow(converted$datamat),c(1:9)]
&lt;br&gt;coefe%*%predval
&lt;br&gt;predict(converted, n.ahead=1)
&lt;br&gt;&lt;br&gt;Hope this helps
&lt;br&gt;&lt;br&gt;Mat
&lt;br&gt;&lt;br&gt;&lt;br&gt;2009/11/24 Karl Schriek &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495006&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;kschriek@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi Mat
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Yes, this is exactly what I would like to do. Only problem this that I
&lt;br&gt;&amp;gt; generate the model using VECM and and then convert to VAR form using
&lt;br&gt;&amp;gt; vec2var. (i.e. the object is of type vec2var, not varest)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I am not sure how to extract the lm from vec2var.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Karl
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Mon, Nov 23, 2009 at 3:46 PM, Matthieu Stigler &amp;lt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495006&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;matthieu.stigler@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hi Karl
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Please provide reproducible code when you ask questions, we don't have
&lt;br&gt;&amp;gt;&amp;gt; access to your local drive!!
&lt;br&gt;&amp;gt;&amp;gt; So use rather datasets in R, as for example:
&lt;br&gt;&amp;gt;&amp;gt; data(Canada)
&lt;br&gt;&amp;gt;&amp;gt; colnames(Canada)
&lt;br&gt;&amp;gt;&amp;gt;  var.2c &amp;lt;- VAR(Canada, p = 1, type = &amp;quot;none&amp;quot;)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; You will note that there is a predict.varest function which does forecasts:
&lt;br&gt;&amp;gt;&amp;gt;     pred&amp;lt;-predict(var.2c, n.ahead = 8, ci = 0.95)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; This is not exactly what you want... you want to change some
&lt;br&gt;&amp;gt;&amp;gt; forecasted values, and see the influence, right? This is not available
&lt;br&gt;&amp;gt;&amp;gt; i the predict.varest. You will need to do some manipulations,
&lt;br&gt;&amp;gt;&amp;gt; basically extracting the lm object and using predict(lm, newdata)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Construct data frame with forecasted values. It should include all
&lt;br&gt;&amp;gt;&amp;gt; variables you see when in the output of var.2c. To keep simple, I used
&lt;br&gt;&amp;gt;&amp;gt; the simplest model (1 lag, no intercept), so need only to give 4
&lt;br&gt;&amp;gt;&amp;gt; values (the lag-1). For the example, I took last dat of data Canada,
&lt;br&gt;&amp;gt;&amp;gt; change as you want:
&lt;br&gt;&amp;gt;&amp;gt; :
&lt;br&gt;&amp;gt;&amp;gt; yourPred&amp;lt;-as.data.frame(matrix(Canada[nrow(Canada),], nrow=1))
&lt;br&gt;&amp;gt;&amp;gt; colnames(yourPred)&amp;lt;-colnames(model.frame(var.2c$varresult$e))[-1] #you
&lt;br&gt;&amp;gt;&amp;gt; need to give same names as in var result!
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; predict(var.2c$varresult$e, newdata=yourPred)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Note that this is exactly the same as what does forecast.varest,
&lt;br&gt;&amp;gt;&amp;gt; except you can now change it manually!
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; pred$fcst$e[1,1]
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; And now you can change the values in yourPred as you want.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hope this helps
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Mat
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 2009/11/23 Karl Schriek &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495006&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;kschriek@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Hi
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; I've fitted a VECM model in R, and converted in to a VAR representation.
&lt;br&gt;&amp;gt;&amp;gt; I
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; would like to use this model to predict the future value of a response
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; variable based on different scenarios for the explanatory variables.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Here is the code for the model:
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; library(urca)
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; library(vars)
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; input &amp;lt;-read.csv(&amp;quot;data.csv&amp;quot;)
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; ts &amp;lt;- ts(input[16:52,],c(2000,1),frequency=4)
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; dat1 &amp;lt;- cbind(ts[,&amp;quot;dx&amp;quot;], ts[,&amp;quot;u&amp;quot;],
&lt;br&gt;&amp;gt;&amp;gt; ts[,&amp;quot;cci&amp;quot;],ts[,&amp;quot;bci&amp;quot;],ts[,&amp;quot;cpi&amp;quot;],ts[,&amp;quot;gdp&amp;quot;])
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; args('ca.jo')
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; vecm &amp;lt;- ca.jo(dat1, type = 'trace', K = 2, season =
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; NULL,spec=&amp;quot;longrun&amp;quot;,dumvar=NULL)
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; vecm.var &amp;lt;- vec2var(vecm,r=2)
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Now what I would like do is to predict &amp;quot;dx&amp;quot; into the future by varying
&lt;br&gt;&amp;gt;&amp;gt; the
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; others. I am not sure if something like &amp;quot;predict dx if
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; u=30,cpi=15,bci=50,gdp=...&amp;quot; in the next period would work. So what I have
&lt;br&gt;&amp;gt;&amp;gt; in
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; mind is something along the lines of: increase &amp;quot;u&amp;quot; by 15% in the next
&lt;br&gt;&amp;gt;&amp;gt; period
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; (which would obviously impact on all the other variables as well,
&lt;br&gt;&amp;gt;&amp;gt; including
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &amp;quot;dx&amp;quot;) and predict the impact into the future.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Also, I am not sure if the &amp;quot;vec2var&amp;quot; step is necessary, so please ignore
&lt;br&gt;&amp;gt;&amp;gt; it
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; if you think it is redundant.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Thanks
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Karl
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;        [[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495006&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;        [[alternative HTML version deleted]]
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495006&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;&amp;gt; -- Subscriber-posting only.
&lt;br&gt;&amp;gt; -- If you want to post, subscribe first.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495006&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;R-SIG-Finance@...&lt;/a&gt; mailing list
&lt;br&gt;&lt;a href=&quot;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://stat.ethz.ch/mailman/listinfo/r-sig-finance&lt;/a&gt;&lt;br&gt;-- Subscriber-posting only.
&lt;br&gt;-- If you want to post, subscribe first.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/R%3A-Use-VAR-model-to-predict-response-to-change-in-values-of-certain-variables-tp26477723p26495006.html" />
</entry>

</feed>
