vartestClust {htestClust}R Documentation

Reweighted Test to Compare Two Variances in Clustered Data

Description

Performs a reweighted test to compare marginal variances of intra-cluster groups in clustered data. Appropriate for clustered data with cluster- or group-size informativeness.

Usage

vartestClust(x, ...)

## Default S3 method:
vartestClust(
  x,
  y,
  idx,
  idy,
  difference = 0,
  alternative = c("two.sided", "less", "greater"),
  conf.level = 0.95,
  ...
)

## S3 method for class 'formula'
vartestClust(formula, id, data, subset, na.action, ...)

Arguments

x, y

numeric vectors of data values.

...

further arguments to be passed to or from methods.

idx

vector or factor object denoting cluster membership for x observations. Length must be equal to length of x.

idy

vector or factor object denoting cluster membership for y observations. Length must be equal to length of y

difference

the hypothesized difference of the marginal population variances of x and y.

alternative

indicates the alternative hypothesis and must be one of "two.sided", "greater", or "less".You can specify just the initial letter.

conf.level

confidence level of the interval.

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.

id

a vector or factor giving the corresponding cluster membership.

data

an optional matrix or data frame containing variables in the formula formula and id. By default the variables are taken from environment(formula).

subset

an optional vector specifying a subset of observations to be used.

na.action

a function which indicates what should happen when data contain NAs. Defaults to getOption("na.action").

Details

The null hypothesis is that the difference of the marginal variances of the populations of intra-cluster groups from which x and y were drawn is equal to difference.

Using the default method, difference is the difference of the reweighted sample variances of x and y. When using the formula method, the order of the difference is determined by the order of the factor levels of rhs.

Value

A list with class "htest" containing the following components:

statistic

the value of the test statistic.

p.value

the p-value of the test.

conf.int

a confidence interval for the difference of the population marginal variances.

estimate

the difference in reweighted sample variances of x and y.

null.value

the difference of population marginal variances under the null.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating the test performed.

data.name

a character string giving the name of the data and the total number of clusters.

M

the number of clusters.

References

Gregg, M., Marginal methods and software for clustered data with cluster- and group-size informativeness. PhD dissertation, University of Louisville, 2020.

Examples

data(screen8)
boys <- subset(screen8, gender=='M')
girls <- subset(screen8, gender=='F')

## Do boys and girls have the same variability in math scores?
## Test using vectors
vartestClust(x=boys$math, y=girls$math, idx=boys$sch.id, idy=girls$sch.id)

## Test using formula method.
vartestClust(math~gender, id=sch.id, data=screen8)

## Note that in this example, the sign of the estimate returned when using the formula
## method is opposite to that when the test was performed using vectors. This is due to
## the order of the gender factor levels


[Package htestClust version 0.2.2 Index]