dataFrame.columns.stat — zTest()

Description

The zTest() method of the stat object performs a two-proportion z-test between selected binary columns.

Signature

dataFrame.columns(...columnNames).stat.zTest({ mode: 'twoSided', pooled: false })
Scope
columns
Family
stat
Returns
object

Arguments

...columnNames ( string[] )
The name of the columns from which to compute the Z-test.
  • Column 1: A binary grouping variable identifying the reference and test groups.
  • Column 2: A binary outcome variable containing success and failure values.
options (object)
Z-test options.

Options

mode (string)
The alternative hypothesis used for the test.
  • oneSided
  • twoSided (default)
pooled (boolean)
Indicates whether a pooled proportion should be used when estimating the standard error.
  • true: pooled version used
  • false: pooled version not used (default)

Returns

stat (object)
A statistic object containing the z-test results.
Z_score (number)
The computed z-test statistic.
p_value (number)
The p-value associated with the test statistic.
confidence (number)
A confidence score computed as 1 - p_value.

Notes

  • The method compares the proportions observed in two groups.
  • The null hypothesis states that both proportions are equal.
  • The pooled option controls whether a pooled estimate of the proportion is used when computing the standard error.
  • Small p-values indicate evidence against the null hypothesis.
  • Positive z-scores indicate that the first proportion is greater than the reference proportion.
  • Negative z-scores indicate that the first proportion is lower than the reference proportion.
  • The confidence score is calculated as 1 - p_value.
  • The test assumes sufficiently large sample sizes for the normal approximation to be valid.

Example

// computes a z-test for 2 binary columns from a dataFrame
var stat = dataFrame.columns('total', 'success').stat.zTest();

// log the stat details
notebook.log(stat);