I would like to minimize the standard error ( mse() in the hydroGOF package can be used) between the simulated 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, leaving the lambda 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)
New2r source share