[R-SIG-Finance] Cox, Ingersoll, Ross/Vasicek parameter estimation viaKalman-Filter (SSPIR)

stefano iacus stefano.iacus at unimi.it
Sat Apr 28 08:09:29 CEST 2007


as for the sde package (never finished, me culpa) I suggest to use a  
smarter simulation scheme then default method which is Euler+Error  
Prediction. In particular for CIR you might want to use the exact law  
of the increments (i.e. the exact transition density). To speed up MC  
analysis, you can use parameter "M" which generates for the same  
model, M independent trajectories returning  a mts object (instead of  
a simple ts one)

I don't know if this is useful for your problem though.

stefano

On 27/apr/07, at 08:14, gyadav at ccilindia.co.in wrote:

>
> Hi
>
> According to my little understanding of finance. I tried to implement
> vasicek model for the term structure taking help of some paper  
> which had
> mathematica code. I can only help with the code which wrote in R.  
> Please
> have a look at it and the library was 'sde' which Mr. Brian has also
> reflected :-) cheers
> ###################VASICEK MODEL##############################
> alpha2<-0.03
> gamma2<-0.06
> sigma2<--0.02
> delta1<-0.0001
> Lambda2<-0.667 # comes from Sharpe's Ratio
> T2<-10
> ls()
>
>
> #
> Years<-read.csv("C:\\input_VAS.csv") #data containing 301 lines  
> starting
> from 0 to 10 with an constant increment
>
> set.seed(2)
> for ( i in 1:100){
>         for (j in 1:100) {
>                 d<-expression(alpha2*(gamma2 - x))
>                 s<-expression(sigma2)
>  sde.sim(X0=0.03,t0=0,N=300,delta=0.0001,sigma=s,drift=d)->SpotRates #
> having 301 entries
> #               length(SpotRates)
>                 RInfinity1<- (gamma1 + ((sigma1*Lambda)/alpha1) -
> ((sigma1*sigma1)/(alpha1*alpha1)))
>                 RInfinity<-rep(RInfinity1,length(SpotRates))
>                 alpha1<-rep(alpha2,length(SpotRates))
>                 gamma1<-rep(gamma2,length(SpotRates))
>                 sigma1<-rep(sigma2,length(SpotRates))
>                 Lambda1<-rep(Lambda2,length(SpotRates))
>                 T1<-rep(T2,length(SpotRates))
>                 #ls()
>                 X1<-((1/alpha1)*(1 - exp(-1*alpha1*(T1 -
> Years)))*(RInfinity - SpotRates))
>                 X2<- ((T1 - Years)*RInfinity)
>                 X3<-((sigma1*sigma1)*(1 - exp(-1*alpha1*(T1 -  
> Years)))*(1
> - exp(-1*alpha1*(T1 - years)))/(4*alpha1*alpha1*alpha1)  )
>                 Price <-  exp( X1 - X2 - X3)
>                 #####
>                 #Rates<-if(Years=0.0) SpotRates else -log(Price,exp 
> (1))/T
>                 #plot(x=Years,y=Rates)
>                 #plot(SpotRates,main="VAS Process")
>         }#j
>         sigma2<-sigma2 + 0.0006
> }#i stdev
> write.csv(SpotRates,"C:\\vas.csv")
> help("log")
>
> HTH
> -gaurav
>
>
>
> "Arne Krombach" <arne.krombach at web.de>
> Sent by: r-sig-finance-bounces at stat.math.ethz.ch
> 27-04-07 03:32 AM
>
> To
> <r-sig-finance at stat.math.ethz.ch>
> cc
>
> Subject
> [R-SIG-Finance] Cox, Ingersoll,Ross/Vasicek parameter estimation via
> Kalman-Filter (SSPIR)
>
>
>
>
>
>
> Dear R-Users,
>
>
>
> I am trying to estimate the parameters for a CIR 1-/2-/3-Factor  
> model via
> Kalman filtering. The idea was to do it via the package SSPIR, but  
> I have
> problems to transform the CIR state space form into the SSPIR syntax.
> Actually, I am not quite sure if this is possible at all.
>
>
>
> Did anybody already realise a CIR/Vasicek -parameter estimation via R?
>
>
>
> To get an idea how a CIR-1-factor state space form looks like (Y=  
> vector
> of
> zerobond-yields with the maturities tau at month t):
>
>
>
> Y(t,tau)= ( -1/tau * log A(tau) ) + (1/tau * B(tau) * x(t) + e
>
>
>
> Where :
>
>
>
> A(tau) = [(2 * h * e^( a + lambda + h) * tau/2) / (2 * h + (a +  
> lambda +
> h)
> * (e^(tau * h) - 1)] ^(2 * b/ sigma^2)
>
> B(tau) = [(2 * (e^(tau * h)  -1)) / 2 * h + (a + lambda + h) * (e^ 
> (tau *
> h)
> - 1)]
>
> h = sqrt[(a + lambda)^2 + 2*sigma^2]
>
>
>
> which means that, besides the time varying factor x, the parameters  
> a, b,
> sigma, and lambda have to be estimated via Kalman filtering.
>
>
>
> Is it possible to implement this in SSPIR? If you have any other  
> suggests
> or
> if you already implement comparable models in R, I would be very  
> grateful
> for your help.
>
>
>
> Kind Regards,
>
>
>
> Arne Krombach
>
>
>                  [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. 
> -- If you want to post, subscribe first.
>
>
>
> ====================================================================== 
> ======================
> DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ... 
> {{dropped}}
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. 
> -- If you want to post, subscribe first.



More information about the R-SIG-Finance mailing list