Teradata Package for R Function Reference | 17.00 - td_binomial_test_valib - 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

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
Product Category
Teradata Vantage
Binomial Tests

Description

In a binomial test, there are assumed to be N independent trials, each with two possible outcomes, each of equal probability. You can choose to perform a binomial test, in which the sign of the difference between a first and second column is analyzed, or a sign test, in which the sign of a single column is analyzed. In a binomial test, user can choose to use a probability different from the default value, whereas in a sign test, the binomial probability is fixed at 0.5.
Detailed information about each test can be found in 'Statistical Tests offered' section.

Usage

td_binomial_test_valib(data, first.column, ...)

Arguments

data

Required Argument.
Specifies the input data to run statistical tests.
Types: tbl_teradata

first.column

Required Argument.
Specifies the name of the column to analyze.
Types: character

...

Specifies other arguments supported by the function as described in the 'Other Arguments' section.

Value

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

Other Arguments

binomial.prob

Optional Argument.
Specifies the binomial probability to use for Binomial Test.
Note:

  • This is not available to use with sign test.

Default Value: 0.5
Types: numeric

exact.matches

Optional Argument.
Specifies the category to place exact matches in.
Note:

  • This is not allowed with sign test.

Permitted Values:

  1. 'zero' - exact match is discarded.

  2. 'positive' - match is placed with values greater than or equal to zero.

  3. 'negative' - match is placed with values less than or equal to zero.

Default Value: 'negative'
Types: character

fallback

Optional Argument.
Specifies whether the FALLBACK is requested as in the output result or not.
Default Value: FALSE (Not requested)
Types: logical

group.columns

Optional Argument.
Specifies the name(s) of the column(s) for grouping so that a separate result is produced for each value or combination of values in the specified column or columns.
Types: character OR vector of Strings (character)

allow.duplicates

Optional Argument.
Specifies whether duplicates are allowed in the output or not.
Default Value: FALSE
Types: logical

second.column

Required argument for binomial test.
Specifies the name of the column representing the second variable to analyze.
Note:

  • This is not allowed with sign test.

Types: character

single.tail

Optional Argument.
Specifies whether to request single-tailed test or not. When set to TRUE, a single-tailed test is requested. Otherwise, a two-tailed test is requested.
Note:

  • If the binomial probability is not 0.5, "single.tail" must be set to TRUE.

Default Value: FALSE
Types: logical

stats.database

Optional Argument.
Specifies the database where the statistical test metadata tables are installed. If not specified, the source database is searched for these metadata tables.
Types: character

style

Optional Argument.
Specifies the test style.
Permitted Values: 'binomial', 'sign'
Default Value: 'binomial'
Types: character

probability.threshold

Optional Argument.
Specifies the threshold probability, i.e., alpha probability, below which the null hypothesis is rejected.
Default Value: 0.05
Types: numeric

Statistical Tests offered

Binomial/Ztests

Output for each unique set of values of the group by variables (GBVs) is a p-value which when compared to the user's choice of alpha, the probability threshold, determines whether the null hypothesis (p=p*, p<=p*, or p>p*) should be rejected for the GBV set. Though both binomial and Ztest results are provided for all N, for the approximate value obtained from the Z-test (nP) is appropriate when N is large. For values of N over 100, only the Ztest is performed. Otherwise, the value bP returned is the p_value of the one-tailed or two-tailed test, depending on the user's choice.

Binomial Sign Test

For the sign test, one column is selected and the test is whether the value is positive or not positive.

Examples


# Notes:
#   1. To execute Vantage Analytic Library functions, set option 
#      'val.install.location' to the database name where Vantage analytic 
#      library functions are installed.
#   2. Datasets used in these examples can be loaded using Vantage Analytic 
#      Library installer.
#   3. The Statistical Test metadata tables must be loaded into the database 
#      where Analytics Library is installed.

# Set the option 'val.install.location'.
options(val.install.location = "SYSLIB")

# Get remote data source connection.
con <- td_get_context()$connection

# Create an object of class "tbl_teradata".
custanly <- tbl(con, "customer_analysis")
print(custanly)

# Example 1: A binomial test without any grouping.
obj <- td_binomial_test_valib(data=custanly,
                              first.column="avg_sv_bal", 
                              second.column="avg_ck_bal")
# Print the results.
print(obj$result)

# Example 2: A binomial test with grouping done by gender.
obj <- td_binomial_test_valib(data=custanly,
                              first.column="avg_sv_bal", 
                              second.column="avg_ck_bal",
                              group.columns="gender")

# Print the results.
print(obj$result)

# Example 3: A sign test without any grouping.
obj <- td_binomial_test_valib(data=custanly,
                              first.column="avg_sv_bal",
                              style="sign")

# Print the results.
print(obj$result)

# Example 4: A sign test with grouping done by gender.
obj <- td_binomial_test_valib(data=custanly,
                              first.column="avg_sv_bal",
                              style="sign",
                              group.columns="gender")

# Print the results.
print(obj$result)