Objects of S3 class "gof" are returned by the EnvStats function gofTest when just the x argument is supplied.

Details

Objects of S3 class "gof" are lists that contain information about the assumed distribution, the estimated or user-supplied distribution parameters, and the test statistic and p-value.

Methods

Generic functions that have methods for objects of class "gof" include:
print, plot.

Value

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

distribution

a character string indicating the name of the assumed distribution (see
Distribution.df).

dist.abb

a character string containing the abbreviated name of the distribution (see
Distribution.df).

distribution.parameters

a numeric vector with a names attribute containing the names and values of the estimated or user-supplied distribution parameters associated with the assumed distribution.

n.param.est

a scalar indicating the number of distribution parameters estimated prior to performing the goodness-of-fit test. The value of this component will be 0 if the parameters were supplied by the user.

estimation.method

a character string indicating the method used to compute the estimated parameters. The value of this component will depend on the available estimation methods (see Distribution.df). The value of this component will be NULL if the parameters were supplied by the user.

statistic

a numeric scalar with a names attribute containing the name and value of the goodness-of-fit statistic.

sample.size

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

parameters

numeric vector with a names attribute containing the name(s) and value(s) of the parameter(s) associated with the test statistic given in the statistic component.

z.value

(except when test="chisq" or test="ks") numeric scalar containing the z-value associated with the goodness-of-fit statistic.

p.value

numeric scalar containing the p-value associated with the goodness-of-fit statistic.

alternative

character string indicating the alternative hypothesis.

method

character string indicating the name of the goodness-of-fit test (e.g.,
"Shapiro-Wilk GOF").

data

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

data.name

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

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 performing the goodness-of-fit test.


NOTE: when the function gofTest is called with both arguments x and y and test="ks", it returns an object of class "gofTwoSample". No specific parametric distribution is assumed, so the value of the component distribution is "Equal" and the following components are omitted: dist.abb, distribution.parameters, n.param.est, estimation.method, and z.value.

Optional Components
The following components are included in the result of calling gofTest with the argument
test="chisq" and may be used by the function plot.gof:

cut.points

numeric vector containing the cutpoints used to define the cells.

counts

numeric vector containing the observed number of counts for each cell.

expected

numeric vector containing the expected number of counts for each cell.

X2.components

numeric vector containing the contribution of each cell to the chi-square statistic.

Note

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

Author

Steven P. Millard (EnvStats@ProbStatInfo.com)

Examples

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

  set.seed(250) 

  dat <- rnorm(20, mean = 3, sd = 2) 

  gof.obj <- gofTest(dat) 

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

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

  names(gof.obj) 
#>  [1] "distribution"            "dist.abb"               
#>  [3] "distribution.parameters" "n.param.est"            
#>  [5] "estimation.method"       "statistic"              
#>  [7] "sample.size"             "parameters"             
#>  [9] "z.value"                 "p.value"                
#> [11] "alternative"             "method"                 
#> [13] "data"                    "data.name"              
#> [15] "bad.obs"                
  # [1] "distribution"            "dist.abb"               
  # [3] "distribution.parameters" "n.param.est"            
  # [5] "estimation.method"       "statistic"              
  # [7] "sample.size"             "parameters"             
  # [9] "z.value"                 "p.value"                
  #[11] "alternative"             "method"                 
  #[13] "data"                    "data.name"              
  #[15] "bad.obs" 

  gof.obj 
#> 
#> Results of Goodness-of-Fit Test
#> -------------------------------
#> 
#> Test Method:                     Shapiro-Wilk GOF
#> 
#> Hypothesized Distribution:       Normal
#> 
#> Estimated Parameter(s):          mean = 2.861160
#>                                  sd   = 1.180226
#> 
#> Estimation Method:               mvue
#> 
#> Data:                            dat
#> 
#> Sample Size:                     20
#> 
#> Test Statistic:                  W = 0.9640724
#> 
#> Test Statistic Parameter:        n = 20
#> 
#> P-value:                         0.6279872
#> 
#> Alternative Hypothesis:          True cdf does not equal the
#>                                  Normal Distribution.
  
  #Results of Goodness-of-Fit Test
  #-------------------------------
  #
  #Test Method:                     Shapiro-Wilk GOF
  #
  #Hypothesized Distribution:       Normal
  #
  #Estimated Parameter(s):          mean = 2.861160
  #                                 sd   = 1.180226
  #
  #Estimation Method:               mvue
  #
  #Data:                            dat
  #
  #Sample Size:                     20
  #
  #Test Statistic:                  W = 0.9640724
  #
  #Test Statistic Parameter:        n = 20
  #
  #P-value:                         0.6279872
  #
  #Alternative Hypothesis:          True cdf does not equal the
  #                                 Normal Distribution.

  #==========

  # Extract the p-value
  #--------------------

  gof.obj$p.value
#> [1] 0.6279872
  #[1] 0.6279872

  #==========

  # Plot the results of the test
  #-----------------------------

  dev.new()
  plot(gof.obj)

  #==========

  # Clean up
  #---------
  rm(dat, gof.obj)
  graphics.off()