i don't know exactly what you're code is doing but I can tell that you are building the kalman filter from scratch in the first part.<br />By from scratch I mean that you are doing the recursions using  R  and fundamental matrix operations.  This is almost surely what makes it slow and you don't want to go that route.  You should get Giovanni's DLM book and pour through it and then call his DLM functions because those are mostly likely written in C and therefore much faster. <br /><br /><br /><br /><br /><br /><br /><br /><p>On Dec 23, 2009, <strong>qqjwl</strong> &lt;qqjwl@163.com&gt; wrote: </p><div class="replyBody"><blockquote style="border-left: 2px solid #267fdb; margin: 0pt 0pt 0pt 1.8ex; padding-left: 1ex"><div><br /> </div> <div>I have attached the code what have made to deal with two factor SV model.</div> <div>It takes me about 87 minites to finish 2000 interations with 1000 data which is too slow compare with other people who have done this kind of model with other language. I don't know why and very confused about it. Looking forward to get your help. Thank you very much! </div> <div> </div> <div>Yours,</div> <div>Liya<br /></div> <br /><pre>在2009-12-23,"Brian G. Peterson" &lt;brian@braverock.com&gt; 写道: &gt;qqjwl wrote: &gt;&gt; Hello everyone, &gt;&gt;     It seems that the estimation of the stochastic volatility model is inefficient in R.  &gt; &gt; Is there a function in R to estimate these kind of model such as the paper &gt; &gt; of Kim and Shephard(1998) "Stochastic volatility: likelihood inference and  &gt;comparison with ARCH models" ? &gt; &gt; Thank you for your attention. &gt; &gt;Liya, &gt; &gt;What, specifically, have you tried that seems to you to be inefficient? &gt; &gt;Please provide references to code and packages that you have tried.  That makes  &gt;it much easier for someone else to help you out. &gt; &gt;I do not immediately recall the paper you reference, but I have estimated many  &gt;different kinds of volatility models in R, and have usually been able to  &gt;accomplish what I needed to.  There are a multitude of [G/AP]ARCH models  &gt;available in R, which ones have you tried? What specific problems did you  &gt;encounter? &gt; &gt;Regards, &gt; &gt;     - Brian &gt; &gt;--  &gt;Brian G. Peterson &gt;http://braverock.com/brian/ &gt;Ph: 773-459-4973 &gt;IM: bgpbraverock </pre><br /><br /><br /><hr /><br />_______________________________________________<br />R-SIG-Finance@stat.math.ethz.ch mailing list<br />https://stat.ethz.ch/mailman/listinfo/r-sig-finance<br />-- Subscriber-posting only.<br />-- If you want to post, subscribe first.</blockquote></div>