title: How to forecast the parameters of Nelson Siegel with a constant lambda in R?
body: <p>I want to calculate the beta parameters of the Nelson Siegel model, with a fixed lambda. The lambda should be set at 0.609. I have an excel file that contains 54 yield curves. For each yield curve I want to estimate the beta parameters from the Nelson Siegel model.</p>
  
  <p>At first, I tried to use the Nelson.Siegel function from the "YieldCurve" package. However, the function only has two arguments so that I can't get the lambda constant.</p>
  
  <p>Second, I created a function myself to calculate the Nelson Siegel model. I want to minimize the squared difference between the Nelson Siegel yield and the actual yield by changing the beta parameters of the function. I did this in excel by using solver. </p>
  
  <p>The code that I have so far: </p>
  
  <pre><code>RTS54_list &lt;- read_xlsx("YieldCurves.xlsx")
  
  nelson_siegel_calculate&lt;-function(theta,lambda,beta0,beta1,beta2){
    beta0 + beta1*(1-exp(-lambda * theta))/(lambda * theta) + beta2*((1-exp(-lambda * theta))/(lambda * theta) - exp(-lambda * theta))
  }
  
  ns_data &lt;-
    data.frame(maturity=1:100) %&gt;%
    mutate(NSS=nelson_siegel_calculate(theta=maturity,lambda=0.0609,beta0=0.02,beta1=-0.02,beta2=0.01))
  </code></pre>
  
  <p>How can I do the same thing in R? </p>
  
  <p>Or is there another way to get my result?</p>