簡體   English   中英

R / BlackScholesMerton模型中的非線性方程組的求解

[英]Solve systems of nonlinear equations in R / BlackScholesMerton Model

我正在編寫Masters最終項目,其中使用Black Scholes Merton模型推導了違約概率,但我陷入了R代碼中。 在數學上,我想使用nleqslv軟件包解決此非線性方程組:

library(nleqslv)
T <- 1
D1 <- 20010.75
R <- 0.8516
sigmaS <- .11
SO1 <- 1311.74
fnewton <- function(x){
  y <- numeric(2)
  d1 <- (log(x[1]/D1)+(R+x[2]^2/2)*T)/x[2]*sqrt(T)
  d2 <- d1 - x[2]*sqrt(T)
  y[1] <- SO1 - (x[1]*pnorm(d1) - exp(-R*T)*D1*pnorm(d2))
  y[2] <- sigmaS*SO1 - pnorm(d1)*x[2]*x[1]
  y
}

xstart <- c(1311.74,0.11)
nleqslv(xstart, fnewton, method="Broyden")
# $x
# [1] 1311.74    0.11

# $fvec
# [1] 1311.7400  144.2914

# $termcd
# [1] 6

# $message
# [1] "Jacobian is singular (see allowSingular option)"

# $scalex
# [1] 1 1

# $nfcnt
# [1] 0

# $njcnt
# [1] 1

# $iter
# [1] 1

我已經嘗試使用5個輸入的許多值來進行此操作(如上所述,我已經為2家公司計算了不同的年份),但是我沒有得到S0和sigma V的最終值。我收到的消息是"Jacobian is singular (see allowSingular option)"如果我使用” control = list(trace = 1,allowSingular = TRUE)“允許使用奇異的Jacobean,則也不會顯示任何答案。 我現在不知道如何獲得這兩個變量的解決方案。

我真的不知道,當我將模型定位於Teterevas幻燈片時(在第5張幻燈片上是她的模型代碼),我做錯了什么,誰演示的是googeling https://www.google.de/的第一個結果搜索?q = moodys + KMV + in + R&rlz = 1C1SVED_enDE401DE401&aq = f&oq = moodys + KMV + in + R&aqs = chrome.0.57.1​​3309j0&sourceid = chrome&ie = UTF-8#q = distance + to + default + in + R + q = distance + to + default + in + R和我一樣,盡管成功得多,她還是通過Black Scholes Merton方法計算了“違約距離”風險度量。 在此模型中,權益價值(通常由市值表示,> SO1)可以寫為歐洲看漲期權。

其他變量是:

x[1]: the variable I want to derive, value of total assets   
x[2]: the variable I want to derive, volatility of total assets    
D1: the book value of debt (19982009)    
R: a riskfree interest rate   
T: is set to 1 year (time)    
sigmaS: estimated (historical) equity volatility

您應該能夠將SO1sigmaS初始值用作nleqslv的初始值。

首先,Tetereva給出的R代碼似乎不太正確(變量Z應該像您所命名的那樣為D1 ;對她的S0D進行類似的更改)。 我已經將Tetereva修改為:

library(nleqslv)
T <- 1
D1 <- 33404048
R <- 2.32
sigmaS <- .02396919
SO1 <- 4740291  # Ve?
fnewton <- function(x){
  y <- numeric(2)
  d1 <- (log(x[1]/D1)+(R+x[2]^2/2)*T)/x[2]*sqrt(T)
  d2 <- d1 - x[2]*sqrt(T)
  y[1] <- SO1 - (x[1]*pnorm(d1) - exp(-R*T)*D1*pnorm(d2))
  y[2] <- sigmaS*SO1 - pnorm(d1)*x[2]*x[1]
  y
}

xstart <- c(SO1,sigmaS)

nleqslv(xstart, fnewton, method="Broyden",control=list(trace=1)) 
nleqslv(xstart, fnewton, method="Newton",control=list(trace=1))

這將提供Tetereva提供的解決方案。 (我在這里使用trace=1只是為了檢查迭代步驟。)

我相信您給R的值應該是8.516,而不是其他。 使用您的值作為參數

T <- 1
D1 <- 20010.75
R <- 8.516  # modified
sigmaS <- .11
SO1 <- 1311.74

像這樣

xstart <- c(1311.74,0.11)
nleqslv(xstart, fnewton, method="Broyden")
nleqslv(xstart, fnewton, method="Newton")

然后,使用這些值運行nleqslv很快收斂。 如果使用R <- 2.32 -2.32(例如Tetereva), nleqslv也將收斂,盡管迭代次數更多。

我不能幫助您確定R應該是多少,但是根據Tetereva的介紹,我認為R是百分比。 由於我對Black-Scholes模型沒有足夠的了解,因此對於找出各種參數的正確值沒有任何幫助。 由你決定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM