# BS_fit

##### Fit Black-Scholes Parameters

Function to estimate the volatility, \(\sigma\), and drift, \(\mu\). See
`vignette("Distance-to-default", package = "DtD")`

for details. All
vectors with length greater than one needs to have the same length. The
Nelder-Mead method from `optim`

is used when
`method = "mle"`

. Either `time`

or `dt`

should be passed.

##### Usage

```
BS_fit(S, D, T., r, time, dt, vol_start, method = c("iterative", "mle"),
tol = 1e-12, eps = 1e-08)
```

##### Arguments

- S
numeric vector with observed stock prices.

- D
numeric vector or scalar with debt due in

`T.`

.- T.
numeric vector or scalar with time to maturity.

- r
numeric vector or scalar with risk free rates.

- time
numeric vector with the observation times.

- dt
numeric scalar with time increments between observations.

- vol_start
numeric scalar with starting value for \(\sigma\).

- method
string to specify which estimation method to use.

- tol
numeric scalar with tolerance to

`get_underlying`

. The difference is scaled if the absolute of`S`

is large than`tol`

as in the`tolerance`

argument to`all.equal.numeric`

.- eps
numeric scalar with convergence threshold.

##### Value

A list with the following components

estimates of \(\sigma\), and drift, \(\mu\).

number of iterations when `method = "iterative"`

and number of log likelihood evaluations when `method = "mle"`

.

logical for whether the estimation method converged.

##### Warning

Choosing `tol >= eps`

or roughly equal may make the method alternate
between two solutions for some data sets.

##### Examples

```
# NOT RUN {
library(DtD)
set.seed(83486778)
sims <- BS_sim(
vol = .1, mu = .05, dt = .1, V_0 = 100, T. = 1, D = rep(80, 20), r = .01)
with(sims,
BS_fit(S = S, D = D, T. = T, r = r, time = time, method = "mle"))
# }
```

*Documentation reproduced from package DtD, version 0.2.1, License: GPL-2*