gof.object.Rd
Objects of S3 class "gof"
are returned by the EnvStats function
gofTest
when just the x
argument is supplied.
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.
Required Components
The following components must be included in a legitimate list of
class "gof"
.
a character string indicating the name of the
assumed distribution (see Distribution.df
).
a character string containing the abbreviated name
of the distribution (see Distribution.df
).
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.
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.
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.
a numeric scalar with a names attribute containing the name and value of the goodness-of-fit statistic.
a numeric scalar containing the number of non-missing observations in the sample used for the goodness-of-fit test.
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.
(except when test="chisq"
or test="ks"
)
numeric scalar containing the z-value associated with the
goodness-of-fit statistic.
numeric scalar containing the p-value associated with the goodness-of-fit statistic.
character string indicating the alternative hypothesis.
character string indicating the name of the
goodness-of-fit test (e.g., "Shapiro-Wilk GOF"
).
numeric vector containing the data actually used for the goodness-of-fit test (i.e., the original data without any missing or infinite values).
character string indicating the name of the data object used for the goodness-of-fit test.
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
:
numeric vector containing the cutpoints used to define the cells.
numeric vector containing the observed number of counts for each cell.
numeric vector containing the expected number of counts for each cell.
numeric vector containing the contribution of each cell to the chi-square statistic.
Since objects of class "gof"
are lists, you may extract
their components with the $
and [[
operators.
# 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()