fitstdnts: fitstdnts

View source: R/distNTS.R

fitstdntsR Documentation

fitstdnts

Description

fitstdnts fit parameters (\alpha, \theta, \beta) of the standard NTS distribution. This function using the curvefit method between the empirical cdf and the standard NTS cdf.

Usage

fitstdnts(rawdat)
fitstdnts(rawdat), ksdensityflag = 1
fitstdnts(rawdat, initialparam = c(alpha, theta, beta))
fitstdnts(rawdat, initialparam = c(alpha, theta, beta)), ksdensityflag = 1
fitstdnts(rawdat, initialparam = c(alpha, theta, beta)), maxeval = 100, ksdensityflag = 1

Arguments

rawdat

Raw data to fit the parameters.

initialparam

A vector of initial standard 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.

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 standard 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

library(functional)
library(nloptr)
library(pracma)
library(spatstat)
library(evmix)
library(Matrix)
library(quantmod)
library("temStaR")
library("quantmod")
getSymbols("^GSPC", src="yahoo", from = "2013-1-1", to = "2023-12-31")
pr <- as.numeric(GSPC$GSPC.Adjusted)
ret <- diff(log(pr))
stdret <- (ret-mean(ret))/sd(ret)
stdntsparam <-  fitstdnts(stdret)

Femp = ecdf(stdret)
x = seq(from=min(stdret), to = max(stdret), length.out = 100)
cemp = Femp(x)
ncdf = pnts(x, c(stdntsparam))
plot(x,ncdf,type = 'l', col = "red")
lines(x,cemp, type = 'l', col = "blue")
a = density(stdret)
p = dnts(x,stdntsparam)
plot(x,p,type = 'l', col = "red", ylim = c(0, max(a$y, p)))
lines(a,type = 'l', col = "blue")


aaron9011/temStaR-v0.90 documentation built on June 1, 2025, 4:15 p.m.