fitmnts: fitmnts

View source: R/distMultiNTS.R

fitmntsR Documentation

fitmnts

Description

fitmnts fit parameters of the n-dimensional NTS distribution.

r = \mu + diag(\sigma) X

where

X follows stdNTS_n(\alpha, \theta, \beta, \Sigma)

Usage

res <- fitmnts(returndata, n)
res <- fitmnts(returndata, n, alphaNtheta = c(alpha, theta))
res <- fitmnts(returndata, n, stdflag = TRUE ) 
res <- fitmnts(returndata, n, alphaNtheta = c(alpha, theta), stdflag = TRUE)

Arguments

returndata

Raw data to fit the parameters. The data must be given as a matrix form. Each column of the matrix contains a sequence of asset returns. The number of row of the matrix is the number of assets.

n

Dimension of the data. That is the number of assets.

alphaNtheta

If \alpha and \theta are given, then put those numbers in this parameter. The function fixes those parameters and fits other remaining parameters. If you set alphaNtheta = NULL, then the function fits all parameters including \alpha and \theta.

stdflag

If you want only standard NTS parameter fit, set this value be TRUE.

Value

Structure of parameters for the n-dimensional NTS distribution.

res$mu : \mu mean vector of the input data.

res$sigma : \sigma standard deviation vector of the input data.

res$alpha : \alpha of the std NTS distribution (X).

res$theta : \theta of the std NTS distribution (X).

res$beta : \beta vector of the std NTS distribution (X).

res$Rho : \rho matrix of the std NTS distribution (X), which is correlation matrix of epsilon.

res$CovMtx : Covariance matrix of return data r.

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)

getSymbols("^GSPC", src="yahoo", from = "2016-1-1", to = "2020-08-31")
pr1 <- as.numeric(GSPC$GSPC.Adjusted)
getSymbols("^DJI", src="yahoo", from = "2016-1-1", to = "2020-08-31")
pr2 <- as.numeric(DJI$DJI.Adjusted)

returndata <- matrix(data = c(diff(log(pr1)),diff(log(pr2))),
                     ncol = 2, nrow = (length(pr1)-1))
res <- fitmnts( returndata = returndata, n=2 )


#Fix alpha and theta.
#Estimate alpha dna theta from DJIA and use those parameter for IBM, INTC parameter fit.
getSymbols("^DJI", src="yahoo", from = "2016-1-1", to = "2020-08-31")
prDJ <- as.numeric(DJI$DJI.Adjusted)
ret <- diff(log(prDJ))
ntsparam <-  fitnts(ret)
getSymbols("IBM", src="yahoo", from = "2016-1-1", to = "2020-08-31")
pr1 <- as.numeric(IBM$IBM.Adjusted)
getSymbols("INTC", src="yahoo", from = "2016-1-1", to = "2020-08-31")
pr2 <- as.numeric(INTC$INTC.Adjusted)

returndata <- matrix(data = c(diff(log(pr1)),diff(log(pr2))),
                     ncol = 2, nrow = (length(pr1)-1))
res <- fitmnts( returndata = returndata,
                n = 2,
                alphaNtheta = c(ntsparam["alpha"], ntsparam["theta"])  )


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