Teradata Package for R Function Reference | 17.20 - ZTest - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
Language
English (United States)
Last Update
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
Product Category
Teradata Vantage

ZTest

Description

td_ztest_sqle() function tests the equality of two means under the assumption that the population variances are known. For large samples, sample variances approximate population variances, so it uses sample variances instead of population variances in the test statistic.

Usage

  td_ztest_sqle (
      data = NULL,
      alpha = 0.5,
      first.sample.column = NULL,
      second.sample.column = NULL,
      alternate.hypothesis = "two-tailed",
      first.sample.variance = NULL,
      second.sample.variance = NULL,
      mean.under.h0 = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

alpha

Optional Argument.
Specifies the value of alpha in hypothesis test function.
Default Value: 0.5
Types: float

first.sample.column

Required Argument.
Specifies the first sample column in z test.
Types: character

second.sample.column

Optional Argument.
Specifies the second sample column in z test.
Types: character

alternate.hypothesis

Optional Argument.
Specifies the alternate hypothesis.
Permitted Values:

  • lower-tailed - Alternate hypothesis (H 1): μ < μ0.

  • upper-tailed - Alternate hypothesis (H 1): μ > μ0.

  • two-tailed - Rejection region is on two sides of sampling distribution of test statistic.
    Two-tailed test considers both lower and upper tails of distribution of test statistic.
    Alternate hypothesis (H 1): μ ≠ μ0

Default Value: "two-tailed"
Types: character

first.sample.variance

Required Argument.
Specifies the first sample variance.
Types: float

second.sample.variance

Optional Argument.
Specifies the second sample variance.
Types: float

mean.under.h0

Optional Argument.
Specifies the mean under the null hypothesis.
Types: float

...

Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments:

persist:
Optional Argument.
Specifies whether to persist the results of the function in a table or not.
When set to TRUE, results are persisted in a table; otherwise, results are garbage collected at the end of the session.
Default Value: FALSE
Types: logical

volatile:
Optional Argument.
Specifies whether to put the results of the function in a volatile table or not.
When set to TRUE, results are stored in a volatile table, otherwise not.
Default Value: FALSE
Types: logical

Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:

  • "<input.data.arg.name>.partition.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.hash.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.order.column" accepts character OR vector of Strings (character) (Strings)

  • "local.order.<input.data.arg.name>" accepts logical

Note:
These generic arguments are supported by tdplyr if the underlying SQL Engine function supports, else an exception is raised.

Value

Function returns an object of class "td_ztest_sqle" which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator using the name(s):result

Examples

  
    
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load the example data.
    loadExampleData("tdplyr_example", "titanic")
    
    # Create tbl_teradata object.
    titanic_data <- tbl(con, "titanic")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Perform Ztest analysis on input data column that
    #            contains data for the first sample population and
    #            variance of the first sample population.
    obj <- td_ztest_sqle(data=titanic_data,
                         first.sample.column='age',
                         first.sample.variance=5)
    
    # Print the result.
    print(obj$result)
    
    # Example 2: Perform Ztest analysis on input data column that
    #            contains data for the first and second sample
    #            population and variance of the first and second sample
    #            population by specifying data.partition.column as ANY.
    
    # To partition data using ANY, one must import 'PartitionKind' module first,
    # then pass PartitionKind$ANY as input to "data.partition.column" argument.
    obj <- td_ztest_sqle(data=titanic_data,
                         alpha=0.5,
                         data.partition.column=PartitionKind$new("ANY"),
                         data.order.column='pclass',
                         first.sample.column='age',
                         second.sample.column='parch',
                         alternate.hypothesis='two-tailed',
                         first.sample.variance=5,
                         second.sample.variance=8,
                         mean.under.h0=0)
    
    # Print the result.
    print(obj$result)