Learn R Programming

fBasics (version 240.10067)

BasicStatistics: Basic Statistics Summary

Description

A collection and description of functions to compute basic statistical properties of financial and economic time series data. Missing functions in R to calculate skewness and kurtosis are added, a function which creates a summary statistics, and functions to calculate column and row statistics. The functions are: ll{ skewness returns value of skewness, kurtosis returns value of kurtosis, basicStats computes an overview of basic statistical values, rowStats calculates row statistics, colStats calculates column statistics, rowAvgs calculates row means, colAvgs calculates column means, rowVars calculates row variances, colVars calculates column variances, rowStdevs calculates row standard deviations, colStdevs calculates column standard deviations, rowSkewness calculates row skewness, colSkewness calculates column skewness, rowKurtosis calculates row kurtosis, colKurtosis calculates column kurtosis, rowCumsums calculates row cumulated Sums, colCumsums calculates column cumulated Sums. } For SPLUS Compatibility: ll{ stdev Returns the standard deviation of a vector or matrix. }

Usage

stdev(x, na.rm = FALSE)

skewness(x, ...) ## S3 method for class 'default': skewness(x, na.rm = FALSE, method = c("moment", "fisher"), ...) ## S3 method for class 'data.frame': skewness(x, \dots) ## S3 method for class 'POSIXct': skewness(x, \dots) ## S3 method for class 'POSIXlt': skewness(x, \dots)

kurtosis(x, ...) ## S3 method for class 'default': kurtosis(x, na.rm = FALSE, method = c("excess", "moment", "fisher"), ...) ## S3 method for class 'data.frame': kurtosis(x, \dots) ## S3 method for class 'POSIXct': kurtosis(x, \dots) ## S3 method for class 'POSIXlt': kurtosis(x, \dots)

basicStats(x, ci = 0.95)

rowStats(x, FUN, na.rm = FALSE, ...) rowAvgs(x, na.rm = FALSE, ...) rowVars(x, na.rm = FALSE, ...) rowStdevs(x, na.rm = FALSE, ...) rowSkewness(x, na.rm = FALSE, ...) rowKurtosis(x, na.rm = FALSE, ...) rowCumsums(x, na.rm = FALSE, ...)

colStats(x, FUN, na.rm = FALSE, ...) colAvgs(x, na.rm = FALSE, ...) colVars(x, na.rm = FALSE, ...) colStdevs(x, na.rm = FALSE, ...) colSkewness(x, na.rm = FALSE, ...) colKurtosis(x, na.rm = FALSE, ...) colCumsums(x, na.rm = FALSE, ...)

Arguments

ci
confidence interval, a numeric value, by default 0.95, i.e. 95 percent.
FUN
[colStats][rowStats - the statistical function to be applied.
na.rm
a logical. Should missing values be removed?
method
[kurtosis][skewness] - a character string which specifies the method of computation. These are either "moment" or "fisher", kurtosis allows in addition for "excess". If "excess" is
x
a numeric vector, or a matrix for column statistics. [basicStats] - allows also a matrix, data.frame or timeSeries as input. In this case only the first column of data will be considered and a a warning will be printed.
...
arguments to be passed.

Value

  • skewness kurtosis return the value of the statistics, a numeric value. An attribute which reports the used method is added. basicsStats returns data frame with the following entries and row names: nobs, NAs, Minimum, Maximum , 1. Quartile, 3. Quartile, Mean, Median, Sum, SE Mean, LCL Mean, UCL Mean, Variance, Stdev, Skewness, Kurtosis. rowStats rowAvgs rowVars rowStdevs rowSkewness rowKurtosis rowCumsum compute sample statistics by column. Missing values can be handled. colStats colAvgs colVars colStdevs, colSkewness colKurtosis colCumsum compute sample statistics by column. Missing values can be handled.

Examples

Run this code
## SOURCE("fBasics.3A-BasicStatistics")

## basicStats -
   # Simulated Monthly Return Data:
   tS = timeSeries(matrix(rnorm(12)), timeCalendar())
   # ... must be univariate:
   basicStats(tS)  
     
## mean -
## var -
## skewness -
## kurtosis -
   # Mean, Variance:
   mean(tS)
   var(tS)
   # Skewness, Kurtosis:
   class(tS)
   skewness(tS)
   kurtosis(tS)

Run the code above in your browser using DataLab