fitnts: fitnts

Description Usage Arguments Value References Examples

View source: R/distNTS.R

Description

fitnts fit parameters (α, θ, β, γ, μ) of the NTS distribution. This function using the curvefit method between the empirical cdf and the NTS cdf.

Usage

1
2
3
4
5
fitnts(rawdat)
fitnts(rawdat), ksdensityflag = 1
fitnts(rawdat, initialparam = c(alpha, theta, beta, gamma, mu))
fitnts(rawdat, initialparam = c(alpha, theta, beta, gamma, mu)), ksdensityflag = 1
fitnts(rawdat, initialparam = c(alpha, theta, beta, gamma, mu)), maxeval = 100, ksdensityflag = 1

Arguments

rawdat

Raw data to fit the parameters.

initialparam

A vector of initial NTS parameters. This function uses the nloptr package. If it has a good initial parameter then estimation performs better. If users do not know a good initial parameters, then just set it as initialparam=NaN, that is default. The function cffitnts() may be helpful to find the initial parameters.

maxeval

Maximum evaluation number for nloptr. The iteration stops on this many function evaluations.

ksdensityflag

This function fit the parameters using the curvefit method between the empirical cdf and the NTS cdf. If ksdensityflag = 1 (default), then the empirical cdf is calculated by the kernel density estimation. If ksdensityflag = 0, then the empirical cdf is calculated by the empirical cdf.

Value

Estimated parameters

References

Kim, Y. S. (2020) Portfolio Optimization on the Dispersion Risk and the Asymmetric Tail Risk https://arxiv.org/pdf/2007.13972.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library("temStaR")
library("quantmod")
getSymbols("^GSPC", src="yahoo", from = "2010-1-1", to = "2020-12-31")
pr <- as.numeric(GSPC$GSPC.Adjusted)
ret <- diff(log(pr))
ntsparam <-  fitnts(ret)

Femp = ecdf(ret)
x = seq(from=min(ret), to = max(ret), length.out = 100)
cemp = Femp(x)
ncdf = pnts(x, c(ntsparam))
plot(x,ncdf,type = 'l', col = "red")
points(x,cemp, type = 'l', col = "blue")
a = density(ret)
p = dnts(x,ntsparam)
plot(x,p,type = 'l', col = "red")
lines(a,type = 'l', col = "blue")

aaron9011/temStaR-v0.814 documentation built on Dec. 24, 2021, 6:16 p.m.