Learn R Programming

fPortfolio (version 251.70)

AssetsModelling: Modelling of Multivariate Asset Sets

Description

A collection and description of functions which generate multivariate artificial data sets of assets, and fit the parameters to a multivariate normal, skew normal, or (skew) Student-t distribution and which compute some benchmark statistics. The functions are: ll{ assetsSim Simulates a data set of assets, assetsSelect Asset Selection from Portfolios, assetsFit Fits the parameter of a data set of assets, print S3 print method for an object of class 'fASSETS', plot S3 Plot method for an object of class 'fASSETS", summary S3 summary method for an object of class 'fASSETS'. }

Usage

assetsSim(n, dim = 2, model = list(mu = rep(0, dim), Omega = diag(dim), 
    alpha = rep(0, dim), df = Inf), assetNames = NULL) 
    
assetsFit(x, method = c("st", "snorm", "norm"), title = NULL, 
    description = NULL, fixed.df = NA, ...)

show.fASSETS(object) ## S3 method for class 'fASSETS': plot(x, which = "ask", \dots) ## S3 method for class 'fASSETS': summary(object, which = "all", \dots)

Arguments

assetNames
[assetsSim] - a vector of character strings of length dim allowing for modifying the names of the individual assets.
description
[assetsFit] - a character string, assigning a brief description to an "fASSETS" object.
fixed.df
[assetsFit] - either NA, the default, or a numeric value assigning the number of degrees of freedom to the model. In the case that fixed.df=NA the value of df will be included in the optimiz
method
[assetsFit] - a character string, which type of distribution should be fitted? method="st" denotes a multivariate skew-Student-t distribution, method="snorm" a multivariate skew-Normal distribution, and <
model
[assetsSim] - a list of model parameters: mu a vector of mean values, one for each asset series, Omega the covariance matrix of assets, alpha the skewness vector, and df the number of degrees of fre
n, dim
[assetsSim] - integer values giving the number of data records to be simulated, and the dimension of the assets set.
object
[show][summary] - An object of class fASSETS.
title
[assetsFit] - a character string, assigning a title to an "fASSETS" object.
which
which of the five plots should be displayed? which can be either a character string, "all" (displays all plots) or "ask" (interactively asks which one to display), or a vector of 5 logical
x
[assetsFit] - a numeric matrix of returns or any other rectangular object like a data.frame or a multivariate time series object which can be transformed by the function as.matrix to an object of class matrix<
...
optional arguments to be passed.

Value

  • assetsFit() returns a S4 object class of class "fASSETS", with the following slots:
  • @callthe matched function call.
  • @datathe input data in form of a data.frame.
  • @descriptionallows for a brief project description.
  • @fitthe results as a list returned from the underlying fitting function.
  • @methodthe selected method to fit the distribution, one of "norm", "snorm", "st".
  • @modelthe model parameters describing the fitted parameters in form of a list, model=list(mu, Omega, alpha, df.
  • @titlea title string.
  • The @fit slot is a list with the following compontents: (Note, not all are documented here).
  • @fit$dpa list containing the direct parameters beta, Omega, alpha. Here, beta is a matrix of regression coefficients with dim(beta)=c(nrow(X), ncol(y)), Omega is a covariance matrix of order dim, alpha is a vector of shape parameters of length dim.
  • @fit$sea list containing the components beta, alpha, info. Here, beta and alpha are the standard errors for the corresponding point estimates; info is the observed information matrix for the working parameter, as explained below.
  • fit@optimthe list returned by the optimizer optim; see the documentation of this function for explanation of its components.
  • Note that the @fit$model slot can be used as input to the function assetsSim for simulating a similar portfolio of assets compared with the original portfolio data, usually market assets. assetsSim() returns a matrix, the artifical data records represent the assets of the portfolio. Row names and column names are not created, they have to be added afterwards.

Details

Assets Objects: Data sets of assets x can be expressed as multivariate 'timeSeries' objects, as 'data.frame' objects, or any other rectangular object which can be transformed into an object of class 'matrix'. Parameter Estimation: The function assetsFit for the parameter estimation and assetsSim for the simulation of assets sets use code based on functions from the contributed packages "mtvnorm" and "sn". The required functionality for fitting data to a multivariate Normal, skew-Normal, or skew-Student-t is available from builtin functions, so it is not necessary to load the packages "mtvnorm" and "sn".

References

Azzalini A. (1985); A Class of Distributions Which Includes the Normal Ones, Scandinavian Journal of Statistics 12, 171--178.

Azzalini A. (1986); Further Results on a Class of Distributions Which Includes the Normal Ones, Statistica 46, 199--208.

Azzalini A., Dalla Valle A. (1996); The Multivariate Skew-normal Distribution, Biometrika 83, 715--726.

Azzalini A., Capitanio A. (1999); Statistical Applications of the Multivariate Skew-normal Distribution, Journal Roy. Statist. Soc. B61, 579--602.

Azzalini A., Capitanio A. (2003); Distributions Generated by Perturbation of Symmetry with Emphasis on a Multivariate Skew-t Distribution, Journal Roy. Statist. Soc. B65, 367--389. Genz A., Bretz F. (1999); Numerical Computation of Multivariate t-Probabilities with Application to Power Calculation of Multiple Contrasts, Journal of Statistical Computation and Simulation 63, 361--378.

Genz A. (1992); Numerical Computation of Multivariate Normal Probabilities, Journal of Computational and Graphical Statistics 1, 141--149. Genz A. (1993); Comparison of Methods for the Computation of Multivariate Normal Probabilities, Computing Science and Statistics 25, 400--405. Hothorn T., Bretz F., Genz A. (2001); On Multivariate t and Gauss Probabilities in R, R News 1/2, 27--29.

See Also

MultivariateDistribution.

Examples

Run this code
## berndtInvest -
   data(berndtInvest)
   # Select "CONTIL" "DATGEN" "TANDY" and "DEC" Stocks:
   select = c("CONTIL", "DATGEN", "TANDY", "DEC")
   # Convert into a timeSeries object:
   berndtAssets.tS = as.timeSeries(berndtInvest)[, select]
   head(berndtAssets.tS)
   # Plot Prices:
   prices = apply(berndtAssets.tS, 2, cumsum)
   ts.plot(prices, main = "Berndt Assets", 
     xlab = "Number of Months", ylab = "Price", col = 1:4)
   Legend = colnames(prices)
   legend(0, 3, legend = Legend, pch = "----", col = 1:4, cex = 1)
   
## assetsFit -
   # Fit a Skew-Student-t Distribution:
   fit = assetsFit(berndtAssets.tS)
   print(fit)
   # Show Model Slot:
   print(fit@model)
   
## assetsSim -
   # Simulate set with same statistical properties:
   set.seed(1953)
   berndtAssetsSim = assetsSim(n = 120, dim = 4, model = fit@model)
   colnames(berndtAssetsSim) = paste(select, "SIM", sep = ".")
   head(berndtAssetsSim)
   pricesSim = apply(berndtAssetsSim, 2, cumsum)
   ts.plot(pricesSim, main = "Berndt Assets Simulated", 
     xlab = "Number of Months", ylab = "Simulated Price", col = 1:4)
   Legend = colnames(pricesSim)
   legend(0, 6, legend = Legend, pch = "----", col = 1:4, cex = 1)

Run the code above in your browser using DataLab