# SABR calibration in R. How to estimate rho and nu so sum of squared errors is minimized

I start with predefined beta and alpha. Then I want to find rho and nu so the Sum of Squared Errors is minimized. By SSE I mean the difference between my model estimated volatilities and observed maarket volatilities. How can I do it in R? I have done following:

## difvol is a function of rho and nu, which is the sum of squared errors.
nlm(difvol,0.01,0.01)


difvol is designed like that:

(first observed volatility - Black implied volatility)^2 + (second observed volatility - Black implied volatility)^2 ...

Black implied volatility has no values in my setup because I have no estimates for rho and nu.

However, the nlm code only returns one estimate and both I need to estimate nu and rho. What to do from here? How do I use nlm properly.

I know my difvol function could have been better but I don't want to change that.

• I would say that this question belong to stackoverflow (for programming) – Sanjay Nov 18 '16 at 23:39

Try to redesign your object function, your difvol, so it's a function of a two dimensional vector
dilvol<-function(X){