EnvStats (version 2.1.0)

gof.object: S3 Class "gof"

Description

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

Arguments

Value

  • Required Components The following components must be included in a legitimate list of class "gof".
  • distributiona character string indicating the name of the assumed distribution (see Distribution.df).
  • dist.abba character string containing the abbreviated name of the distribution (see Distribution.df).
  • distribution.parametersa 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.esta 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.methoda 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.
  • statistica numeric scalar with a names attribute containing the name and value of the goodness-of-fit statistic.
  • sample.sizea numeric scalar containing the number of non-missing observations in the sample used for the goodness-of-fit test.
  • parametersnumeric 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.valuenumeric scalar containing the p-value associated with the goodness-of-fit statistic.
  • alternativecharacter string indicating the alternative hypothesis.
  • methodcharacter string indicating the name of the goodness-of-fit test (e.g., "Shapiro-Wilk GOF").
  • datanumeric vector containing the data actually used for the goodness-of-fit test (i.e., the original data without any missing or infinite values).
  • data.namecharacter string indicating the name of the data object used for 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 component is included when the data object contains missing (NA), undefined (NaN) and/or infinite (Inf, -Inf) values.
  • bad.obsnumeric 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.
  • 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.pointsnumeric vector containing the cutpoints used to define the cells.
  • countsnumeric vector containing the observed number of counts for each cell.
  • expectednumeric vector containing the expected number of counts for each cell.
  • X2.componentsnumeric vector containing the contribution of each cell to the chi-square statistic.

Methods

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

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.

See Also

gofTest, print.gof, plot.gof, Goodness-of-Fit Tests, Distribution.df, gofCensored.object.

Examples

Run this code
# 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" 

  class(gof.obj) 
  #[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" 

  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.

  #==========

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

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

  #==========

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

  dev.new()
  plot(gof.obj)

  #==========

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

Run the code above in your browser using DataLab