BasicStatistics           package:fBasics           R Documentation

_B_a_s_i_c _S_t_a_t_i_s_t_i_c_s _S_u_m_m_a_r_y

_D_e_s_c_r_i_p_t_i_o_n:

     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:

       '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:

       'stdev'  Returns the standard deviation of a vector or matrix.

_U_s_a_g_e:

     stdev(x, na.rm = FALSE)

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

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

     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, ...)

_A_r_g_u_m_e_n_t_s:

      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
           selected, then the value of the kurtosis is computed  by the
          '"moment"' method and a value of 3 will be subtracted. The
          '"moment"' method is based on the definitions of  skewness
          and kurtosis for distributions; these forms should  be used
          when resampling (bootstrap or jackknife). The  '"fisher"'
          method correspond to the usual "unbiased"  definition of
          sample variance, although in the case of skewness  and
          kurtosis exact unbiasedness is not possible.  

       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. 

_V_a_l_u_e:

     '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.

_N_o_t_e:

     R's-base package contains a function 'colMeans' with an additional
     argument 'dim=1'. Therefore, the function used  here to compute
     column means (averages) is named 'colAvgs'. 

     The function 'stdev' computes the standard deviation for a vector
     or matrix and was introduced for SPlus compatibility. Under R use
     the function 'sd'.

_A_u_t_h_o_r(_s):

     Diethelm Wuertz for the Rmetrics R-port.

_E_x_a_m_p_l_e_s:

     ## 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)   

