ffp_moments: Moments with Flexible Probabilities

View source: R/ffp_moments.R

ffp_momentsR Documentation

Moments with Flexible Probabilities

Description

Computes the location and dispersion statistics under flexible probabilities.

Usage

ffp_moments(x, p = NULL)

## Default S3 method:
ffp_moments(x, p = NULL)

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

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

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

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

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

Arguments

x

A tabular (non-tidy) data structure.

p

An object of the ffp class.

Value

A list with 2 elements: mu and sigma.

Examples

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)

ffp documentation built on Sept. 29, 2022, 5:10 p.m.