I would like to minimize the mean squared error (the mse()
in the hydroGOF
Package might be used) between modeled and observed spreads. The function is defined as:
KV_CDS <- function(Lambda, s, sigma_S){
KV_CDS = (Lambda * (1 + s)) / exp(-s * sigma_S) - Lambda^2)
}
The goal is to minimize mse
between KV_CDS and C by leaving Lambda a free parameter in the KV_CDS function.
df <- data.frame(C=c(1,1,1,2,2,3,4),
Lambda=c(0.5),s=c(1:7),
sigma_S=c(0.5,0.4,0.3,0.7,0.4,0.5,0.8),
d=c(20,30,40,50,60,70,80),
sigma_B=0.3, t=5, Rec=0.5, r=0.05)