R Under development (unstable) (2024-03-03 r86036 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(Sim.DiffProc) Package 'Sim.DiffProc', version 4.9 browseVignettes('Sim.DiffProc') for more informations. > > > ## Application to real data > ## CKLS modele vs CIR modele > ## CKLS (mod1): dX(t) = (theta1+theta2* X(t))* dt + theta3 * X(t)^theta4 * dW(t) > ## CIR (mod2): dX(t) = (theta1+theta2* X(t))* dt + theta3 * sqrt(X(t)) * dW(t) > set.seed(1234) > > data(Irates) > rates <- Irates[,"r1"] > rates <- window(rates, start=1964.471, end=1989.333) > > fx1 <- expression(theta[1]+theta[2]*x) > gx1 <- expression(theta[3]*x^theta[4]) > gx2 <- expression(theta[3]*sqrt(x)) > > fitmod1 <- fitsde(rates,drift=fx1,diffusion=gx1,pmle="euler",start = list(theta1=1,theta2=1, + theta3=1,theta4=1),optim.method = "L-BFGS-B") > fitmod2 <- fitsde(rates,drift=fx1,diffusion=gx2,pmle="euler",start = list(theta1=1,theta2=1, + theta3=1),optim.method = "L-BFGS-B") > summary(fitmod1) Pseudo maximum likelihood estimation Method: Euler Call: function (name, ...) .Primitive("call") Coefficients: Estimate Std. Error theta1 2.0769516 0.98838467 theta2 -0.2631871 0.19544290 theta3 0.1302158 0.02523105 theta4 1.4513173 0.10323740 -2 log L: 475.7572 > summary(fitmod2) Pseudo maximum likelihood estimation Method: Euler Call: function (name, ...) .Primitive("call") Coefficients: Estimate Std. Error theta1 2.6387593 1.18754723 theta2 -0.3606083 0.18896205 theta3 0.8650745 0.03549428 -2 log L: 563.7025 > coef(fitmod1) theta1 theta2 theta3 theta4 2.0769516 -0.2631871 0.1302158 1.4513173 > coef(fitmod2) theta1 theta2 theta3 2.6387593 -0.3606083 0.8650745 > confint(fitmod1,parm=c('theta2','theta3')) 2.5 % 97.5 % theta2 -0.64624812 0.1198740 theta3 0.08076388 0.1796678 > confint(fitmod2,parm=c('theta2','theta3')) 2.5 % 97.5 % theta2 -0.7309671 0.009750471 theta3 0.7955070 0.934642013 > AIC(fitmod1) [1] 483.7572 > AIC(fitmod2) [1] 569.7025 > > proc.time() user system elapsed 0.35 0.09 0.43