Skip to contents

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)

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)
#> $mu
#>          DAX          SMI          CAC         FTSE 
#> 0.0006590193 0.0006674141 0.0004552631 0.0004186991 
#> 
#> $sigma
#>               DAX          SMI          CAC         FTSE
#> DAX  1.058414e-04 6.665733e-05 8.131371e-05 5.274301e-05
#> SMI  6.665733e-05 8.566093e-05 6.239321e-05 4.306845e-05
#> CAC  8.131371e-05 6.239321e-05 1.199025e-04 5.703934e-05
#> FTSE 5.274301e-05 4.306845e-05 5.703934e-05 6.243929e-05
#> 

# compare with the standard approach
colMeans(x)
#>          DAX          SMI          CAC         FTSE 
#> 0.0006520417 0.0008178997 0.0004370540 0.0004319851 
cov(x)
#>               DAX          SMI          CAC         FTSE
#> DAX  1.061072e-04 6.699564e-05 8.345130e-05 5.241794e-05
#> SMI  6.699564e-05 8.556317e-05 6.285881e-05 4.304517e-05
#> CAC  8.345130e-05 6.285881e-05 1.216802e-04 5.693174e-05
#> FTSE 5.241794e-05 4.304517e-05 5.693174e-05 6.332543e-05