gofTwoSample.object {EnvStats} | R Documentation |

Objects of S3 class `"gofTwoSample"`

are returned by the EnvStats function
`gofTest`

when both the `x`

and `y`

arguments are supplied.

Objects of S3 class `"gofTwoSample"`

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

.

`distribution` |
a character string with the value |

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

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

`data` |
a list of length 2 containing the numeric vectors actually used for the goodness-of-fit test (i.e., the original data but with any missing or infinite values removed). |

`data.name` |
a character vector of length 2 indicating the name of the data
object used for the |

**Optional Component**

The following component is included when the arguments `x`

and/or `y`

contain missing (`NA`

), undefined (`NaN`

) and/or infinite
(`Inf`

, `-Inf`

) values.

`bad.obs` |
numeric vector of length 2 indicating the number of missing ( |

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

include:

`print`

, `plot`

.

Since objects of class `"gofTwoSample"`

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

and `[[`

operators.

Steven P. Millard (EnvStats@ProbStatInfo.com)

`print.gofTwoSample`

, `plot.gofTwoSample`

,
Goodness-of-Fit Tests.

```
# Create an object of class "gofTwoSample", then print it out.
# Generate 20 observations from a normal distribution with mean=3 and sd=2, and
# generate 10 observaions from a normal distribution with mean=2 and sd=2 then
# test whether these sets of observations come from the same distribution.
# (Note: the call to set.seed simply allows you to reproduce this example.)
set.seed(300)
dat1 <- rnorm(20, mean = 3, sd = 2)
dat2 <- rnorm(10, mean = 1, sd = 2)
gofTest(x = dat1, y = dat2, test = "ks")
#Results of Goodness-of-Fit Test
#-------------------------------
#
#Test Method: 2-Sample K-S GOF
#
#Hypothesized Distribution: Equal
#
#Data: x = dat1
# y = dat2
#
#Sample Sizes: n.x = 20
# n.y = 10
#
#Test Statistic: ks = 0.7
#
#Test Statistic Parameters: n = 20
# m = 10
#
#P-value: 0.001669561
#
#Alternative Hypothesis: The cdf of 'dat1' does not equal
# the cdf of 'dat2'.
#----------
# Clean up
rm(dat1, dat2)
```

[Package *EnvStats* version 2.8.1 Index]