Learn R Programming

HDShOP (version 0.1.5)

Sigma_sample_estimator: Sample covariance matrix

Description

It computes the sample covariance of matrix \(S\) as follows: $$S = \frac{1}{n-1} \sum_{j=1}^n (x_j - \bar x)(x_j - \bar x)' ,\quad \bar x = \frac{1}{n} \sum_{j=1}^n x_j ,$$ where \(x_j\) is the \(j\)-th column of the data matrix \(x\).

Usage

Sigma_sample_estimator(x)

Value

Sample covariance estimation

Arguments

x

a p by n matrix or a data frame of asset returns. Rows represent different assets, columns -- observations.

Examples

Run this code
p<-5 # number of assets
n<-1e1 # number of realizations

x <-matrix(data = rnorm(n*p), nrow = p, ncol = n)
Sigma_sample_estimator(x)

Run the code above in your browser using DataLab