Description Details Value Methods Note Author(s) See Also Examples

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"`

.

`distribution` |
a character string indicating the name of the
assumed distribution (see |

`dist.abb` |
a character string containing the abbreviated name
of the distribution (see |

`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 |

`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 |

`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 |

`z.value` |
(except when |

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

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

*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.obs` |
numeric scalar indicating the number of missing ( |

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

Generic functions that have methods for objects of class
`"gof"`

include:

`print`

, `plot`

.

Since objects of class `"gof"`

are lists, you may extract
their components with the `$`

and `[[`

operators.

Steven P. Millard ([email protected])

`gofTest`

, `print.gof`

, `plot.gof`

,
Goodness-of-Fit Tests,
`Distribution.df`

, `gofCensored.object`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ```
# 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()
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.