pred_test {PredTest} | R Documentation |
Predictive Test Function
Description
This function performs statistical tests to determine the predictive power of a results set weighted by a corresponding vector of weights. It offers various methods to conduct the test, allowing flexibility depending on the data characteristics and analysis requirements.
Usage
pred_test(
weights_vector,
results_vector,
test_type = "exact",
phi_0 = 0.5,
sims = 5000
)
Arguments
weights_vector |
A numeric vector where each element represents the weight for a corresponding result in the results vector. Each value must be on the interval |
results_vector |
A numeric vector of test results where each element is in the set {0, 1}, representing the binary outcome of each prediction. |
test_type |
A character string specifying the type of statistical test to perform. The valid options are 'exact', 'approx', or 'bootstrap'. |
phi_0 |
A numeric value on the interval (0, 1) representing the null hypothesis value against which the test results are compared. |
sims |
A natural number that specifies the number of simulations to perform when the bootstrap method is chosen. This parameter allows control over the robustness of the bootstrap approximation. |
Details
This function performs error handling to ensure appropriate input values and types. It then calculates the test statistic and evaluates the p-value based on the specified test type.
Value
A list containing:
- num_correctly_predicted
The number of results correctly predicted as per the specified criteria.
- p_value
The p-value resulting from the test, indicating the probability of observing the test results under the null hypothesis.
- test_stat
The test statistic calculated based on the weights and results.
- p0
The estimated proportion derived from the weights and results.
- ci
A confidence interval for the estimated proportion derived from the weights and results using the Wilson score method.
Examples
# Example weights and results vectors
weights_vector <- c(1/3, 0.5, 1)
results_vector <- c(0, 1, 1)
# Exact test
result_exact <- pred_test(weights_vector, results_vector, test_type = 'exact')
result_exact
# Approximate test
result_approx <- pred_test(weights_vector, results_vector, test_type = 'approx')
result_approx
# Bootstrap test
result_bootstrap <- pred_test(weights_vector, results_vector, test_type = 'bootstrap')
result_bootstrap