Last data update: 2014.03.03

R: Student's t Distribution
StudentR Documentation

Student's t Distribution

Description

Functions for evaluating density, fitting and random variates of multivaraite Student's t distribution and routines for quantiles and fitting of univariate distribution.

Usage

dmt(x, df, mu, Sigma, log = FALSE)
rmt(n, df = 4, mu = 0, Sigma)
qst(p, mu = 0, sd = 1, df, scale = FALSE)
fit.st(data, ...)
fit.mst(data, nit = 2000, tol = 1e-10, ...)

Arguments

x

matrix, dimension n \times d; density is evaluated for each row.

df

numeric, degrees of freedom.

mu

numeric, location parameters.

Sigma

matrix, dispersion matrix.

log

logical, returning log density values.

data

numeric, data used for uni- and multivariate fitting.

nit

integer, number of iterations of EM-type algorithm.

tol

numeric, tolerance of improvement for stopping iteration.

p

numeric, probability.

sd

numeric, scale parameters.

scale

logical, scaling Student's t distribution.

n

integer, count of random variates.

...

ellipsis, arguments are passed down to optim() in fit.st() and to MCECMupdate() in fit.mst().

See Also

link{EMupdate}, link{MCECMupdate}, and link{MCECM.Qfunc}

Examples

BiDensPlot(func = dmt, xpts = c(-4, 4), ypts = c(-4, 4), mu = c(0, 0),
           Sigma = equicorr(2, -0.7), df = 4)
## Quantiles of univariate Student's t
p <- c(0.90,0.95)
s <- 0.2 * 10000/sqrt(250)
qst(p, sd = s, df = 4, scale = TRUE)
## Fitting multivariate Student's t
Sigma <- diag(c(3, 4, 5)) %*% equicorr(3, 0.6) %*% diag(c(3, 4, 5)) 
mu <- c(1, 2 ,3) 
tdata <- rmt(1000, 4, mu = mu, Sigma = Sigma) 
mod1 <- fit.mst(tdata, method = "BFGS")
## DJ data
data(DJ)
r <- returns(DJ)
s <- window(r[, "MSFT"], "1993-01-01", "2000-12-31")
mod.t1 <- fit.st(100 * s)
stocks <- c("AXP","EK","BA","C","KO","MSFT",
            "HWP","INTC","JPM","DIS")
ss <- window(r[, stocks], "1993-01-01", "2000-12-31")
fridays <- time(ss)[isWeekday(time(ss), wday = 5)]
ssw <- aggregate(ss, by = fridays, FUN = sum)
mod.t2 <- fit.mst(ssw, method = "BFGS") 

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(QRM)
Loading required package: gsl
Loading required package: Matrix
Loading required package: mvtnorm
Loading required package: numDeriv
Loading required package: timeSeries
Loading required package: timeDate

Attaching package: 'QRM'

The following object is masked from 'package:base':

    lbeta

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/QRM/Student.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Student
> ### Title: Student's t Distribution
> ### Aliases: Student dmt rmt qst fit.st fit.mst
> ### Keywords: distribution
> 
> ### ** Examples
> 
> BiDensPlot(func = dmt, xpts = c(-4, 4), ypts = c(-4, 4), mu = c(0, 0),
+            Sigma = equicorr(2, -0.7), df = 4)
> ## Quantiles of univariate Student's t
> p <- c(0.90,0.95)
> s <- 0.2 * 10000/sqrt(250)
> qst(p, sd = s, df = 4, scale = TRUE)
[1] 137.1341 190.6782
> ## Fitting multivariate Student's t
> Sigma <- diag(c(3, 4, 5)) %*% equicorr(3, 0.6) %*% diag(c(3, 4, 5)) 
> mu <- c(1, 2 ,3) 
> tdata <- rmt(1000, 4, mu = mu, Sigma = Sigma) 
> mod1 <- fit.mst(tdata, method = "BFGS")
> ## DJ data
> data(DJ)
> r <- returns(DJ)
> s <- window(r[, "MSFT"], "1993-01-01", "2000-12-31")
> mod.t1 <- fit.st(100 * s)
> stocks <- c("AXP","EK","BA","C","KO","MSFT",
+             "HWP","INTC","JPM","DIS")
> ss <- window(r[, stocks], "1993-01-01", "2000-12-31")
> fridays <- time(ss)[isWeekday(time(ss), wday = 5)]
> ssw <- aggregate(ss, by = fridays, FUN = sum)
> mod.t2 <- fit.mst(ssw, method = "BFGS") 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>