title: CAPM.beta rollapply
body: <p>I have already successfully calculated my rolling correlations in my <code>xts</code> object with</p>
  
  <pre class="lang-r prettyprint-override"><code>x &lt;- cbind(market_return,stock_returns)
  rollcor_3year &lt;- rollapplyr(
      x, width=width_cor,function(x) cor(x[,1],x[,-1],
      use="pairwise.complete.obs"),by.column=FALSE)
  </code></pre>
  
  <p>The correlation was later used to calculate rolling Betas.</p>
  
  <p>Now I found the function <code>CAPM.beta</code> from the <code>PerformanceAnalytics</code> package and I wonder why I cannot use</p>
  
  <pre><code>beta &lt;- rollapplyr(x,width=width_cor,function(x) CAPM.beta(x[,1],x[,-1]),by.column=FALSE)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>beta &lt;- rollapplyr(stock_returns,width=width_cor,CAPM.beta,Rb=market_return,by.column=FALSE)
  </code></pre>
  
  <p>directly. </p>
  
  <p><strong>With both functions it starts to calculate but doesnt stop...</strong></p>
  
  <p>It would be nice to see if I get the same betas out of the predefined function, but apparently it does not work like that. What did I do wrong?</p>