Learn R Programming

ffp (version 0.2.2)

ffp_moments: Moments with Flexible Probabilities

Description

Computes the location and dispersion statistics under flexible probabilities.

Usage

ffp_moments(x, p = NULL)

# S3 method for default ffp_moments(x, p = NULL)

# S3 method for numeric ffp_moments(x, p = NULL)

# S3 method for matrix ffp_moments(x, p = NULL)

# S3 method for xts ffp_moments(x, p = NULL)

# S3 method for data.frame ffp_moments(x, p = NULL)

# S3 method for tbl_df ffp_moments(x, p = NULL)

Value

A list with 2 elements: mu and sigma.

Arguments

x

A tabular (non-tidy) data structure.

p

An object of the ffp class.

Examples

Run this code
x <- matrix(diff(log(EuStockMarkets)), ncol = 4)
colnames(x) <- colnames(EuStockMarkets)
p <- stats::runif(nrow(x))
p <- p / sum(p)

ffp_moments(x = x, p = p)

# compare with the standard approach
colMeans(x)
cov(x)

Run the code above in your browser using DataLab