Objects of S3 class "distChoose" are returned by the EnvStats function distChoose.

Details

Objects of S3 class "distChoose" are lists that contain information about the candidate distributions, the estimated distribution parameters for each candidate distribution, and the test statistics and p-values associated with each candidate distribution.

Methods

Generic functions that have methods for objects of class "distChoose" include:
print.

Value

Required Components
The following components must be included in a legitimate list of class "distChoose".

choices

a character vector containing the full names of the candidate distributions. (see Distribution.df).

method

a character string denoting which method was used.

decision

a character vector containing the full name of the chosen distribution.

alpha

a numeric scalar between 0 and 1 specifying the Type I error associated with each goodness-of-fit test.

distribution.parameters

a numeric vector containing the estimated parameters associated with the chosen distribution.

estimation.method

a character string indicating the method used to compute the estimated parameters associated with the chosen distribution. The value of this component will depend on the available estimation methods (see Distribution.df).

sample.size

a numeric scalar containing the number of non-missing observations in the sample used for the goodness-of-fit tests.

test.results

a list with the same number of components as the number of elements in the component choices. The names of the list are the distribution abbreviations of the candidate distributions. (See the help file for Distribution.df for a list of distributions and their abbreviations.) Each component is an object of class gof containing the results of the goodness-of-fit test for that particular hypothesized distribution.

data.name

character string indicating the name of the data object used for the goodness-of-fit tests.


Optional Components
The following component is included in the result of calling distChoose when the argument keep.data=TRUE:

data

numeric vector containing the data actually used for the goodness-of-fit tests (i.e., the original data without any missing or infinite values).


The following component is included in the result of calling distChoose when missing (NA), undefined (NaN) and/or infinite (Inf, -Inf) values are present:

bad.obs

numeric scalar indicating the number of missing (NA), undefined (NaN) and/or infinite (Inf, -Inf) values that were removed from the data object prior to choosing a distribution.

Note

Since objects of class "distChoose" are lists, you may extract their components with the $ and [[ operators.

Author

Steven P. Millard (EnvStats@ProbStatInfo.com)

Examples

  # Create an object of class "distChoose", then print it out. 
  # (Note: the call to set.seed simply allows you to reproduce 
  # this example.)

  set.seed(47)
  dat <- rgamma(20, shape = 2, scale = 3)

  distChoose.obj <- distChoose(dat) 

  mode(distChoose.obj) 
#> [1] "list"
  #[1] "list" 

  class(distChoose.obj) 
#> [1] "distChoose"
  #[1] "distChoose" 

  names(distChoose.obj) 
#>  [1] "choices"                 "method"                 
#>  [3] "decision"                "alpha"                  
#>  [5] "distribution.parameters" "estimation.method"      
#>  [7] "sample.size"             "test.results"           
#>  [9] "data"                    "data.name"              
  #[1] "choices"                 "method"                 
  #[3] "decision"                "alpha"                  
  #[5] "distribution.parameters" "estimation.method"      
  #[7] "sample.size"             "test.results"           
  #[9] "data"                    "data.name"  

  distChoose.obj 
#> 
#> Results of Choosing Distribution
#> --------------------------------
#> 
#> Candidate Distributions:         Normal
#>                                  Gamma
#>                                  Lognormal
#> 
#> Choice Method:                   Shapiro-Wilk
#> 
#> Type I Error per Test:           0.05
#> 
#> Decision:                        Gamma
#> 
#> Estimated Parameter(s):          shape = 1.909462
#>                                  scale = 4.056819
#> 
#> Estimation Method:               MLE
#> 
#> Data:                            dat
#> 
#> Sample Size:                     20
#> 
#> Test Results:
#> 
#>   Normal                         
#>     Test Statistic:              W = 0.9097488
#>     P-value:                     0.06303695
#> 
#>   Gamma                          
#>     Test Statistic:              W = 0.9834958
#>     P-value:                     0.970903
#> 
#>   Lognormal                      
#>     Test Statistic:              W = 0.9185006
#>     P-value:                     0.09271768
#> 
  
  #Results of Choosing Distribution
  #--------------------------------
  #
  #Candidate Distributions:         Normal
  #                                 Gamma
  #                                 Lognormal
  #
  #Choice Method:                   Shapiro-Wilk
  #
  #Type I Error per Test:           0.05
  #
  #Decision:                        Gamma
  #
  #Estimated Parameter(s):          shape = 1.909462
  #                                 scale = 4.056819
  #
  #Estimation Method:               MLE
  #
  #Data:                            dat
  #
  #Sample Size:                     20
  #
  #Test Results:
  #
  #  Normal                         
  #    Test Statistic:              W = 0.9097488
  #    P-value:                     0.06303695
  #
  #  Gamma                          
  #    Test Statistic:              W = 0.9834958
  #    P-value:                     0.970903
  #
  #  Lognormal                      
  #    Test Statistic:              W = 0.9185006
  #    P-value:                     0.09271768

  #==========

  # Extract the choices
  #--------------------

  distChoose.obj$choices
#> [1] "Normal"    "Gamma"     "Lognormal"
  #[1] "Normal"    "Gamma"     "Lognormal"

  #==========

  # Clean up
  #---------
  rm(dat, distChoose.obj)