A Regression Start and Likelihood Setup for CIR Parameter Estimation
Summary
The document concerns estimating parameters for a stochastic volatility model in which variance follows a Cox–Ingersoll–Ross (CIR) square-root process. The question asks for estimation from time-series data rather than option prices, with quasi-maximum likelihood or generalized method of moments as possible approaches. The response provides a MATLAB routine for CIR estimation and describes inputs such as observations, time step, and choices for evaluating the likelihood.
The routine first transforms changes in the observed series and uses a linear regression to form initial estimates of mean-reversion speed, long-run level, and volatility. It then passes those starting values to a numerical optimizer, with alternative objective functions associated with a noncentral chi-square density or a Bessel-function approach. The example is only a scaffold: the objective functions are not included, and the stated input describes interest-rate observations, so it does not fully explain applying the routine to the correlated stochastic-volatility model in the question. No estimation results or validation are reported.
Key ideas
- The example estimates CIR mean reversion, long-run level, and volatility from a time series.
- A regression on transformed observations supplies starting values for numerical likelihood optimization.
- The routine offers alternative likelihood calculations based on a noncentral chi-square density or a Bessel function.
- The response omits the objective-function implementations and does not demonstrate validation on the requested stochastic-volatility model.
Tags
Full text
# Stochastic Volatility CIR estimation
# Stochastic Volatility CIR estimation
Would anyone have a code (pref. Matlab or R) for any type of estimation (QML, GMM) not using option prices of a stochastic volatility model driven by a CIR process described below?
\begin{equation} dS_t = \mu dt + \sqrt{v_t} dW_t^1 \end{equation} \begin{equation} dv_t = \kappa (\theta - v_t) dt + \sigma \sqrt{v_t} dW^2_t \end{equation} such that $dW_{t}^{1}\,dW_{t}^{2}=\rho dt$
I just need to cross-check my results.
Thanks!
## Answer by user16891 (score 1)
https://quant.stackexchange.com/a/19233
- Input Model.Data = Time series of interest rates observations. Model.TimeStep = Delta t; recommended: 1/250 for daily data and 1/12 for monthly data. Model.Disp = 'y' | 'n', (default: 'n'). Model.Method = 'ncx2pdf' | 'besseli' (default: 'besseli'). Model.MatlabDisp = 'off' | 'iter' | 'notify' |' final' (default: 'off').
```
function Results = CIRestimation(Model)
Nobs = length(Model.Data);
r = Model.Data(1:end-1);
dr = diff(Model.Data);
dr = dr./r.^0.5;
regressors = [Model.TimeStep./r.^0.5, Model.TimeStep*r.^0.5];
drift = regressors\dr;
res = regressors*drift - dr;
alpha = -drift(2);
theta = -drift(1)/drift(2);
sigma = sqrt(var(res, 1)/Model.TimeStep);
InitialParams = [kappa theta sigma];
if ~isfield(Model, 'Disp'), Model.Disp = 'y';
end;
if strcmp(Model.Disp, 'y')
fprintf('\n initial kappa=...%+3.6f\n initial theta=...%+3.6f\n initial sigma = %+3.6f\n',kappa, theta, sigma);
end
if ~isfield(Model, 'MatlabDisp'), Model.MatlabDisp = 'off';
end;
options = optimset('LargeScale', 'off', 'MaxIter', 300, 'MaxFunEvals',300, 'Display', Model.MatlabDisp, 'TolFun', 1e-4, 'TolX', 1e-4, 'TolCon', 1e-4);
if ~isfield(Model, 'Method'), Model.Method = 'besseli';
end;
if strcmp(Model.Method, 'ncx2pdf')
[Params, Fval, Exitflag] = fminsearch(@(Params) CIRobjective2(Params, Model),InitialParams, options);
else
[Params, Fval, Exitflag] = fminsearch(@(Params) CIRobjective1(Params, Model),InitialParams, options);
end
Results.Params = Params;
Results.Fval = -Fval/Nobs;
Results.Exitflag = Exitflag;
if strcmp(Model.Disp, 'y')
fprintf('\n kappa = %+3.6f\n theta = %+3.6f\n sigma = %+3.6f\n',...
Params(1), Params(2), Params(3));
fprintf(' log-likelihood = %+3.6f\n', -Fval/Nobs);
end
```
endShown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.