Title: | Succinct and Correct Statistical Summaries for Reports |
---|---|
Description: | Succinctly and correctly format statistical summaries of various models and tests (F-test, Chi-Sq-test, Fisher-test, T-test, and rank-significance). This package also includes empirical tests, such as Monte Carlo and bootstrap distribution estimates. |
Authors: | John Mount [aut, cre], Nina Zumel [aut], Win-Vector LLC [cph] |
Maintainer: | John Mount <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.1.5 |
Built: | 2025-02-09 05:00:09 UTC |
Source: | https://github.com/winvector/sigr |
Succinctly format significance summaries of various models and tests (F-test, Chi-Sq-test, Fisher-test, T-test, and rank-significance). The main purpose is unified reporting and planning of experimental results, working around issue such as the difficulty of extracting model summary facts (such as with 'lm'/'glm'). This package also includes empirical tests, such as bootstrap estimates.
To learn more about sigr, please start with the vignette:
vignette('sigrFormatting','sigr')
Maintainer: John Mount [email protected]
Authors:
Nina Zumel [email protected]
Other contributors:
Win-Vector LLC [copyright holder]
Useful links:
Report bugs at https://github.com/WinVector/sigr/issues
Add ROC columns derived from sensitivity and specificity.
add_ROC_derived_columns(d, positive_prevalence)
add_ROC_derived_columns(d, positive_prevalence)
d |
input data frame, must at lest of columns Sensitivity and Specificity |
positive_prevalence |
scalar, the prevalence of the positive class or prior odds |
extended data frame with more columns
d <- data.frame(pred = 1:4, truth = c(TRUE,FALSE,TRUE,TRUE)) roc <- build_ROC_curve(d$pred, d$truth) add_ROC_derived_columns(roc, mean(d$truth))
d <- data.frame(pred = 1:4, truth = c(TRUE,FALSE,TRUE,TRUE)) roc <- build_ROC_curve(d$pred, d$truth) add_ROC_derived_columns(roc, mean(d$truth))
as.character
## S3 method for class 'sigr_statistic' as.character(x, ...)
## S3 method for class 'sigr_statistic' as.character(x, ...)
x |
sigr wrapper to print |
... |
extra arguments for sigr::render |
formatted string
as.character(wrapSignificance(1/300))
as.character(wrapSignificance(1/300))
Assuming max(nA, nB) %% min(nA, nB) == 0
:
compute the distribution of differences of weighted sums between
max(1, nB/nA)*sum(a)
and max(1, nA/nB)*sum(b)
where a
is a 0/1 vector of length nA
with each item 1 with independent probability (kA+kB)/(nA+nB)
,
and b
is a 0/1 vector of length nB
with each item 1 with independent probability (kA+kB)/(nA+nB)
.
Then return the significance of a direct two-sided test that the absolute value of this difference is at least as large
as the test_rate_difference (if supplied) or the empirically observed rate difference abs(nB*kA - nA*kB)/(nA*nB)
.
The idea is: under this scaling differences in success rates between the two processes are easily observed as differences
in counts returned by the scaled processes.
The method can be used to get the exact probability of a given difference under the null hypothesis that
both the A
and B
processes have the same success rate (kA+kB)/(nA+nB)
.
When nA
and nB
don't divide evenly into to each
other two calculations are run with the larger process is alternately padded and truncated to look like a larger or smaller
experiment that meets the above conditions. This gives us a good range of significances.
Bernoulli_diff_stat(kA, nA, kB, nB, test_rate_difference, common_rate)
Bernoulli_diff_stat(kA, nA, kB, nB, test_rate_difference, common_rate)
kA |
number of A successes observed. |
nA |
number of A experiments. |
kB |
number of B successes observed. |
nB |
number of B experiments. |
test_rate_difference |
numeric, difference in rate of A-B to test. Note: it is best to specify this prior to looking at the data. |
common_rate |
rate numeric, assumed null-rate. |
Note the intent is that we are measuring the results of an A/B test with max(nA, nB) %% min(nA, nB) == 0
(no padding needed), or max(nA,nB) >> min(nA,nB)
(padding is small effect).
The idea of converting a rate problem into a counting problem follows from reading Wald's Sequential Analysis.
For very small p-values the calculation is sensitive to rounding in the observed ratio-difference, as an arbitrarily small change in test-rate can move an entire set of observed differences in or out of the significance calculation.
Bernoulli difference test statistic.
Bernoulli_diff_stat(2000, 5000, 100, 200) Bernoulli_diff_stat(2000, 5000, 100, 200, 0.1) Bernoulli_diff_stat(2000, 5000, 100, 199) Bernoulli_diff_stat(2000, 5000, 100, 199, 0.1) Bernoulli_diff_stat(100, 200, 2000, 5000) # sigr adjusts experiment sizes when lengths # don't divide into each other. Bernoulli_diff_stat(100, 199, 2000, 5000) Bernoulli_diff_stat(100, 199, 2000, 5000)$pValue
Bernoulli_diff_stat(2000, 5000, 100, 200) Bernoulli_diff_stat(2000, 5000, 100, 200, 0.1) Bernoulli_diff_stat(2000, 5000, 100, 199) Bernoulli_diff_stat(2000, 5000, 100, 199, 0.1) Bernoulli_diff_stat(100, 200, 2000, 5000) # sigr adjusts experiment sizes when lengths # don't divide into each other. Bernoulli_diff_stat(100, 199, 2000, 5000) Bernoulli_diff_stat(100, 199, 2000, 5000)$pValue
Based on: https://blog.revolutionanalytics.com/2016/08/roc-curves-in-two-lines-of-code.html
build_ROC_curve(modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE)
build_ROC_curve(modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE)
modelPredictions |
numeric predictions (not empty) |
yValues |
truth values (not empty, same length as model predictions) |
... |
force later arguments to bind by name. |
na.rm |
logical, if TRUE remove NA values. |
yTarget |
value considered to be positive. |
the ROC graph of Score (model score), Sensitivity, and Specificity. Guaranteed to have the (0, 0) and (1, 1) (1-Specificity,Sensitivity) endpoints.
sigr::build_ROC_curve(1:4, c(TRUE,FALSE,TRUE,TRUE))
sigr::build_ROC_curve(1:4, c(TRUE,FALSE,TRUE,TRUE))
Based on: https://blog.revolutionanalytics.com/2016/08/roc-curves-in-two-lines-of-code.html
calcAUC(modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE)
calcAUC(modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE)
modelPredictions |
numeric predictions (not empty), ordered (either increasing or decreasing) |
yValues |
truth values (not empty, same length as model predictions) |
... |
force later arguments to bind by name. |
na.rm |
logical, if TRUE remove NA values. |
yTarget |
value considered to be positive. |
area under curve
sigr::calcAUC(1:4, c(TRUE,FALSE,TRUE,TRUE)) # should be 2/3
sigr::calcAUC(1:4, c(TRUE,FALSE,TRUE,TRUE)) # should be 2/3
Calculate deviance.
calcDeviance(pred, y, na.rm = FALSE, eps = 1e-06)
calcDeviance(pred, y, na.rm = FALSE, eps = 1e-06)
pred |
numeric predictions |
y |
logical truth |
na.rm |
logical, if TRUE remove NA values |
eps |
numeric, smoothing term |
deviance
sigr::calcDeviance(1:4,c(TRUE,FALSE,TRUE,TRUE))
sigr::calcDeviance(1:4,c(TRUE,FALSE,TRUE,TRUE))
Calculate sum of squared error.
calcSSE(pred, y, na.rm = FALSE)
calcSSE(pred, y, na.rm = FALSE)
pred |
numeric predictions |
y |
numeric truth |
na.rm |
logical, if TRUE remove NA values |
sum of squared error
sigr::calcSSE(1:4,c(1,0,1,1))
sigr::calcSSE(1:4,c(1,0,1,1))
Studentized estimate of how often a difference is below zero.
estimateDifferenceZeroCrossing(resampledDiffs, na.rm = FALSE)
estimateDifferenceZeroCrossing(resampledDiffs, na.rm = FALSE)
resampledDiffs |
numeric vector resampled observations |
na.rm |
logical, if TRUE remove NA values |
estimated probability of seeing a re-sampled difference below zero.
set.seed(2352) resampledDiffs <- rnorm(10)+1 estimateDifferenceZeroCrossing(resampledDiffs)
set.seed(2352) resampledDiffs <- rnorm(10)+1 estimateDifferenceZeroCrossing(resampledDiffs)
Based on https://win-vector.com/2020/09/13/why-working-with-auc-is-more-powerful-than-one-might-think/
find_area_q(area, ..., n_points = 101)
find_area_q(area, ..., n_points = 101)
area |
area to match |
... |
not used, force later arguments to bind by name |
n_points |
how many points to use to estimte area. |
q that such that curve 1 - (1 - (1-Specificity)^q)^(1/q)
matches area
find_area_q(0.75)
find_area_q(0.75)
Based on https://win-vector.com/2020/09/13/why-working-with-auc-is-more-powerful-than-one-might-think/
find_AUC_q( modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE, n_points = 101 )
find_AUC_q( modelPredictions, yValues, ..., na.rm = FALSE, yTarget = TRUE, n_points = 101 )
modelPredictions |
numeric predictions (not empty), ordered (either increasing or decreasing) |
yValues |
truth values (not empty, same length as model predictions) |
... |
force later arguments to bind by name. |
na.rm |
logical, if TRUE remove NA values. |
yTarget |
value considered to be positive. |
n_points |
number of points to use in estimates. |
q that such that curve 1 - (1 - (1-ideal_roc$Specificity)^q)^(1/q) matches area
d <- data.frame(pred = 1:4, truth = c(TRUE,FALSE,TRUE,TRUE)) q <- find_AUC_q(d$pred, d$truth) roc <- build_ROC_curve(d$pred, d$truth) ideal_roc <- data.frame(Specificity = seq(0, 1, length.out = 101)) ideal_roc$Sensitivity <- sensitivity_from_specificity_q(ideal_roc$Specificity, q) # library(ggplot2) # ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) + # geom_line(data = roc, color = "DarkBlue") + # geom_line(data = ideal_roc, color = "Orange") + # theme(aspect.ratio=1) + # ggtitle("example actual and ideal curve")
d <- data.frame(pred = 1:4, truth = c(TRUE,FALSE,TRUE,TRUE)) q <- find_AUC_q(d$pred, d$truth) roc <- build_ROC_curve(d$pred, d$truth) ideal_roc <- data.frame(Specificity = seq(0, 1, length.out = 101)) ideal_roc$Sensitivity <- sensitivity_from_specificity_q(ideal_roc$Specificity, q) # library(ggplot2) # ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) + # geom_line(data = roc, color = "DarkBlue") + # geom_line(data = ideal_roc, color = "Orange") + # theme(aspect.ratio=1) + # ggtitle("example actual and ideal curve")
Based on doi:10.1177/0272989X15582210. Fits a Beta(a, 1) distribuiton on positive examples and an Beta(1, b) distribution on negative examples.
find_matching_a1_1b( modelPredictions, yValues, ..., yTarget = TRUE, step_size = 0.001 ) find_ROC_matching_ab1( modelPredictions, yValues, ..., yTarget = TRUE, step_size = 0.001 )
find_matching_a1_1b( modelPredictions, yValues, ..., yTarget = TRUE, step_size = 0.001 ) find_ROC_matching_ab1( modelPredictions, yValues, ..., yTarget = TRUE, step_size = 0.001 )
modelPredictions |
numeric predictions (not empty), ordered (either increasing or decreasing) |
yValues |
truth values (not empty, same length as model predictions) |
... |
force later arguments to bind by name. |
yTarget |
value considered to be positive. |
step_size |
size of steps in curve drawing |
beta curve shape parameters
d <- rbind( data.frame(x = rbeta(1000, shape1 = 6, shape2 = 4), y = TRUE), data.frame(x = rbeta(1000, shape1 = 2, shape2 = 5), y = FALSE) ) find_ROC_matching_ab1(modelPredictions = d$x, yValues = d$y) # should be near # shape1_pos shape2_pos shape1_neg shape2_neg a b # 3.985017 1.000000 1.000000 1.746613 3.985017 1.746613 # # # How to land what you want as variables # unpack[a, b] <- # find_matching_a1_1b(modelPredictions = d$x, yValues = d$y)
d <- rbind( data.frame(x = rbeta(1000, shape1 = 6, shape2 = 4), y = TRUE), data.frame(x = rbeta(1000, shape1 = 2, shape2 = 5), y = FALSE) ) find_ROC_matching_ab1(modelPredictions = d$x, yValues = d$y) # should be near # shape1_pos shape2_pos shape1_neg shape2_neg a b # 3.985017 1.000000 1.000000 1.746613 3.985017 1.746613 # # # How to land what you want as variables # unpack[a, b] <- # find_matching_a1_1b(modelPredictions = d$x, yValues = d$y)
Based on https://win-vector.com/2020/09/13/why-working-with-auc-is-more-powerful-than-one-might-think/. Used to find one beta distribution on positive examples, and another on negative examples.
find_matching_conditional_betas(modelPredictions, yValues, ..., yTarget = TRUE) find_ROC_matching_ab(modelPredictions, yValues, ..., yTarget = TRUE)
find_matching_conditional_betas(modelPredictions, yValues, ..., yTarget = TRUE) find_ROC_matching_ab(modelPredictions, yValues, ..., yTarget = TRUE)
modelPredictions |
numeric predictions (not empty), ordered (either increasing or decreasing) |
yValues |
truth values (not empty, same length as model predictions) |
... |
force later arguments to bind by name. |
yTarget |
value considered to be positive. |
beta curve shape parameters
d <- rbind( data.frame(x = rbeta(1000, shape1 = 6, shape2 = 4), y = TRUE), data.frame(x = rbeta(1000, shape1 = 2, shape2 = 3), y = FALSE) ) find_matching_conditional_betas(modelPredictions = d$x, yValues = d$y) # should be near # shape1_pos shape2_pos shape1_neg shape2_neg # 6 4 2 3 # # # How to land all as variables # unpack[shape1_pos, shape2_pos, shape1_neg, shape2_neg] <- # find_ROC_matching_ab(modelPredictions = d$x, yValues = d$y)
d <- rbind( data.frame(x = rbeta(1000, shape1 = 6, shape2 = 4), y = TRUE), data.frame(x = rbeta(1000, shape1 = 2, shape2 = 3), y = FALSE) ) find_matching_conditional_betas(modelPredictions = d$x, yValues = d$y) # should be near # shape1_pos shape2_pos shape1_neg shape2_neg # 6 4 2 3 # # # How to land all as variables # unpack[shape1_pos, shape2_pos, shape1_neg, shape2_neg] <- # find_ROC_matching_ab(modelPredictions = d$x, yValues = d$y)
Fit shape1, shape2 using the method of moments.
fit_beta_shapes(x)
fit_beta_shapes(x)
x |
numeric predictions |
beta shape1, shape2 parameters in a named list
x <- rbeta(1000, shape1 = 3, shape2 = 5.5) fit_beta_shapes(x) # should often be near [3, 5.5]
x <- rbeta(1000, shape1 = 3, shape2 = 5.5) fit_beta_shapes(x) # should often be near [3, 5.5]
Format
## S3 method for class 'sigr_statistic' format(x, ...)
## S3 method for class 'sigr_statistic' format(x, ...)
x |
sigr wrapper to print |
... |
extra arguments for sigr::render |
formatted string
format(wrapSignificance(1/300))
format(wrapSignificance(1/300))
Detect rendering format (using knitr).
getRenderingFormat()
getRenderingFormat()
rendering format
getRenderingFormat()
getRenderingFormat()
Compute the utility of a model score on a classification data set. For each threshold of interest we compute the utility of the classification rule of taking all items with model score greater than or equal to the threshold. The user specifies the outcome (a binary classification target), a model score (numeric), and the utility values (positive, negative, or zero) of each case: true positives, false positives, true negatives, and false negatives. What is returned is a table of model thresholds and the total value of using this model score plus the given threshold as a classification rule. NA is used to mark a threshold where no rows are selected.
model_utility( d, model_name, outcome_name, ..., outcome_target = TRUE, true_positive_value_column_name = "true_positive_value", false_positive_value_column_name = "false_positive_value", true_negative_value_column_name = "true_negative_value", false_negative_value_column_name = "false_negative_value" )
model_utility( d, model_name, outcome_name, ..., outcome_target = TRUE, true_positive_value_column_name = "true_positive_value", false_positive_value_column_name = "false_positive_value", true_negative_value_column_name = "true_negative_value", false_negative_value_column_name = "false_negative_value" )
d |
A data.frame containing all data and outcome values. |
model_name |
Name of the column containing model predictions. |
outcome_name |
Name of the column containing the truth values. |
... |
Not used, forces later argument to be specified by name. |
outcome_target |
truth value considered to be TRUE. |
true_positive_value_column_name |
column name of per-row values of true positive cases. Only used on positive instances. |
false_positive_value_column_name |
column name of per-row values of false positive cases. Only used on negative instances. |
true_negative_value_column_name |
column name of per-row values of true negative cases. Only used on negative instances. |
false_negative_value_column_name |
column name of per-row values of false negative cases. Only used on positive instances. |
A worked example can be found here: https://github.com/WinVector/sigr/blob/main/extras/UtilityExample.md.
data.frame of all threshold values.
d <- data.frame( predicted_probability = c(0, 0.5, 0.5, 0.5), made_purchase = c(FALSE, TRUE, FALSE, FALSE), false_positive_value = -5, # acting on any predicted positive costs $5 true_positive_value = 95, # revenue on a true positive is $100 minus action cost true_negative_value = 0.001, # true negatives have no value in our application # but just give ourselves a small reward for being right false_negative_value = -0.01 # adding a small notional tax for false negatives, # don't want our competitor getting these accounts. ) values <- model_utility(d, 'predicted_probability', 'made_purchase') best_strategy <- values[values$total_value >= max(values$total_value), ][1, ] t(best_strategy) # a bigger example d <- data.frame( predicted_probability = stats::runif(100), made_purchase = sample(c(FALSE, TRUE), replace = TRUE, size = 100), false_positive_value = -5, # acting on any predicted positive costs $5 true_positive_value = 95, # revenue on a true positive is $100 minus action cost true_negative_value = 0.001, # true negatives have no value in our application # but just give ourselves a small reward for being right false_negative_value = -0.01 # adding a small notional tax for false negatives, # don't want our competitor getting these accounts. ) values <- model_utility(d, 'predicted_probability', 'made_purchase') # plot the estimated total utility as a function of threshold plot(values$threshold, values$total_value) best_strategy <- values[values$total_value >= max(values$total_value), ][1, ] t(best_strategy) # without utilities example d <- data.frame( predicted_probability = c(0, 0.5, 0.5, 0.5), made_purchase = c(FALSE, TRUE, FALSE, FALSE)) model_utility(d, 'predicted_probability', 'made_purchase')
d <- data.frame( predicted_probability = c(0, 0.5, 0.5, 0.5), made_purchase = c(FALSE, TRUE, FALSE, FALSE), false_positive_value = -5, # acting on any predicted positive costs $5 true_positive_value = 95, # revenue on a true positive is $100 minus action cost true_negative_value = 0.001, # true negatives have no value in our application # but just give ourselves a small reward for being right false_negative_value = -0.01 # adding a small notional tax for false negatives, # don't want our competitor getting these accounts. ) values <- model_utility(d, 'predicted_probability', 'made_purchase') best_strategy <- values[values$total_value >= max(values$total_value), ][1, ] t(best_strategy) # a bigger example d <- data.frame( predicted_probability = stats::runif(100), made_purchase = sample(c(FALSE, TRUE), replace = TRUE, size = 100), false_positive_value = -5, # acting on any predicted positive costs $5 true_positive_value = 95, # revenue on a true positive is $100 minus action cost true_negative_value = 0.001, # true negatives have no value in our application # but just give ourselves a small reward for being right false_negative_value = -0.01 # adding a small notional tax for false negatives, # don't want our competitor getting these accounts. ) values <- model_utility(d, 'predicted_probability', 'made_purchase') # plot the estimated total utility as a function of threshold plot(values$threshold, values$total_value) best_strategy <- values[values$total_value >= max(values$total_value), ][1, ] t(best_strategy) # without utilities example d <- data.frame( predicted_probability = c(0, 0.5, 0.5, 0.5), made_purchase = c(FALSE, TRUE, FALSE, FALSE)) model_utility(d, 'predicted_probability', 'made_purchase')
Estimate significance of AUC by permutation test.
permTestAUC( d, modelName, yName, yTarget = TRUE, ..., na.rm = FALSE, returnScores = FALSE, nrep = 100, parallelCluster = NULL )
permTestAUC( d, modelName, yName, yTarget = TRUE, ..., na.rm = FALSE, returnScores = FALSE, nrep = 100, parallelCluster = NULL )
d |
data.frame |
modelName |
character model column name |
yName |
character outcome column name |
yTarget |
target to match to y |
... |
extra arguments (not used) |
na.rm |
logical, if TRUE remove NA values |
returnScores |
logical if TRUE return detailed permutedScores |
nrep |
number of permutation repetitions to estimate p values. |
parallelCluster |
(optional) a cluster object created by package parallel or package snow |
AUC statistic
set.seed(25325) d <- data.frame(x1=c(1,2,3,4,5,6,7,7), y=c(FALSE,TRUE,FALSE,FALSE, TRUE,TRUE,FALSE,TRUE)) permTestAUC(d,'x1','y',TRUE)
set.seed(25325) d <- data.frame(x1=c(1,2,3,4,5,6,7,7), y=c(FALSE,TRUE,FALSE,FALSE, TRUE,TRUE,FALSE,TRUE)) permTestAUC(d,'x1','y',TRUE)
Treat permutation re-samples as similar to bootstrap replications.
permutationScoreModel( modelValues, yValues, scoreFn, ..., na.rm = FALSE, returnScores = FALSE, nRep = 100, parallelCluster = NULL )
permutationScoreModel( modelValues, yValues, scoreFn, ..., na.rm = FALSE, returnScores = FALSE, nRep = 100, parallelCluster = NULL )
modelValues |
numeric array of predictions. |
yValues |
numeric/logical array of outcomes, dependent, or truth values |
scoreFn |
function with signature scoreFn(modelValues,yValues) returning scalar numeric score. |
... |
not used, forces later arguments to be bound by name |
na.rm |
logical, if TRUE remove NA values |
returnScores |
logical if TRUE return detailed permutedScores |
nRep |
integer number of repititions to perform |
parallelCluster |
optional snow-style parallel cluster. |
summaries
set.seed(25325) y <- 1:5 m <- c(1,1,2,2,2) cor.test(m,y,alternative='greater') f <- function(modelValues,yValues) cor(modelValues,yValues) permutationScoreModel(m,y,f)
set.seed(25325) y <- 1:5 m <- c(1,1,2,2,2) cor.test(m,y,alternative='greater') f <- function(modelValues,yValues) cor(modelValues,yValues) permutationScoreModel(m,y,f)
## S3 method for class 'sigr_statistic' print(x, ...)
## S3 method for class 'sigr_statistic' print(x, ...)
x |
sigr wrapper to print |
... |
extra arguments for sigr::render and print |
formatted string
print(wrapSignificance(1/300))
print(wrapSignificance(1/300))
Format summary roughly in "APA Style" ( American Psychological Association ).
render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
sigr summary statistic |
... |
extra arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
render.sigr_significance
, render.sigr_ftest
Format an AUC-test (quality of a probability score)
## S3 method for class 'sigr_aucpairtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_aucpairtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped AUC test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format an AUC-test (quality of a probability score)
## S3 method for class 'sigr_aucpermtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_aucpermtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped AUC test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format an AUC-test (quality of a probability score)
## S3 method for class 'sigr_aucresamptest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_aucresamptest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped AUC test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format sigr_Bernoulli_diff_test (test of difference of Bernoulli processes).
## S3 method for class 'sigr_Bernoulli_diff_test' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_Bernoulli_diff_test' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped cor.test. |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Bernoulli_diff_stat(2000, 5000, 100, 200) Bernoulli_diff_stat(2000, 5000, 100, 200, 0.1) Bernoulli_diff_stat(2000, 5000, 100, 199) Bernoulli_diff_stat(2000, 5000, 100, 199, 0.1)
Bernoulli_diff_stat(2000, 5000, 100, 200) Bernoulli_diff_stat(2000, 5000, 100, 200, 0.1) Bernoulli_diff_stat(2000, 5000, 100, 199) Bernoulli_diff_stat(2000, 5000, 100, 199, 0.1)
Format binom.test (test of rate of a Binomial/Bernoulli experiment).
## S3 method for class 'sigr_binomtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_binomtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped binom.test. |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
bt <- binom.test(7, 10, 0.5) wrapBinomTest(bt)
bt <- binom.test(7, 10, 0.5) wrapBinomTest(bt)
Format a chi-square test (quality of categorical prediction)
## S3 method for class 'sigr_chisqtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_chisqtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped T-test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format Cohen-D (effect size between groups)
## S3 method for class 'sigr_cohend' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 1, pSmallCutoff = 0 )
## S3 method for class 'sigr_cohend' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 1, pSmallCutoff = 0 )
statistic |
CohenD-approximation |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format cor.test (test of liner correlation).
## S3 method for class 'sigr_cortest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_cortest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped cor.test. |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) ct <- cor.test(d$x,d$y) wrapCorTest(ct)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) ct <- cor.test(d$x,d$y) wrapCorTest(ct)
Format an empirical test (quality of categorical prediction)
## S3 method for class 'sigr_emptest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_emptest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped T-test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format fisher.test (test of categorical independence).
## S3 method for class 'sigr_fishertest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_fishertest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped Fisher test |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string and fields
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) ft <- fisher.test(table(d)) wrapFisherTest(ft)
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) ft <- fisher.test(table(d)) wrapFisherTest(ft)
Format an F-test
## S3 method for class 'sigr_ftest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_ftest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format an empirical test (quality of categorical prediction)
## S3 method for class 'sigr_permtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_permtest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped T-test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summary. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format a pwr-test
## S3 method for class 'sigr_pwr_htest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 1, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_pwr_htest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 1, pSmallCutoff = 1e-05 )
statistic |
wrapped test from pwr package |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Format a significance
## S3 method for class 'sigr_significance' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_significance' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped significance |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries (not used in significance reports). |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
cat(render(wrapSignificance(1/300),format='html'))
cat(render(wrapSignificance(1/300),format='html'))
Report sample size (n), sample mean, bias-corrected standard deviation estimate (assuming normality, using a chi-square distribution correction from https://en.wikipedia.org/wiki/Unbiased_estimation_of_standard_deviation#Bias_correction), and a Student t-test tolerance-style confidence interval.
## S3 method for class 'sigr_tinterval' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_tinterval' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped TInterval. |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
set.seed(2018) d <- rnorm(100) + 3.2 TInterval(d)
set.seed(2018) d <- rnorm(100) + 3.2 TInterval(d)
Format a T-test (difference in means by group)
## S3 method for class 'sigr_ttest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
## S3 method for class 'sigr_ttest' render( statistic, ..., format, statDigits = 4, sigDigits = 4, pLargeCutoff = 0.05, pSmallCutoff = 1e-05 )
statistic |
wrapped T-test |
... |
not used, force use of named binding for later arguments |
format |
if set the format to return ("html", "latex", "markdown", "ascii") |
statDigits |
integer number of digits to show in summaries. |
sigDigits |
integer number of digits to show in significances. |
pLargeCutoff |
value to declare non-significance at or above. |
pSmallCutoff |
smallest value to print |
formatted string
Studentized bootstrap variance estimate for scoreFn(yValues,modelValues).
resampleScoreModel( modelValues, yValues, scoreFn, ..., na.rm = FALSE, returnScores = FALSE, nRep = 100, parallelCluster = NULL )
resampleScoreModel( modelValues, yValues, scoreFn, ..., na.rm = FALSE, returnScores = FALSE, nRep = 100, parallelCluster = NULL )
modelValues |
numeric array of predictions (model to test). |
yValues |
numeric/logical array of outcomes, dependent, or truth values |
scoreFn |
function with signature scoreFn(modelValues,yValues) returning scalar numeric score. |
... |
not used, forces later arguments to be bound by name |
na.rm |
logical, if TRUE remove NA values |
returnScores |
logical if TRUE return detailed resampledScores |
nRep |
integer number of repititions to perform |
parallelCluster |
optional snow-style parallel cluster. |
summaries
set.seed(25325) y <- 1:5 m1 <- c(1,1,2,2,2) cor.test(m1,y,alternative='greater') f <- function(modelValues,yValues) { if((sd(modelValues)<=0)||(sd(yValues)<=0)) { return(0) } cor(modelValues,yValues) } s <- sigr::resampleScoreModel(m1,y,f) print(s) z <- (s$observedScore-0)/s$sd # should check size of z relative to bias! pValue <- pt(z,df=length(y)-2,lower.tail=FALSE) pValue
set.seed(25325) y <- 1:5 m1 <- c(1,1,2,2,2) cor.test(m1,y,alternative='greater') f <- function(modelValues,yValues) { if((sd(modelValues)<=0)||(sd(yValues)<=0)) { return(0) } cor(modelValues,yValues) } s <- sigr::resampleScoreModel(m1,y,f) print(s) z <- (s$observedScore-0)/s$sd # should check size of z relative to bias! pValue <- pt(z,df=length(y)-2,lower.tail=FALSE) pValue
Studentized bootstrap test of strength of scoreFn(yValues,model1Values) > scoreFn(yValues,model1Values) sampled with replacement.
resampleScoreModelPair( model1Values, model2Values, yValues, scoreFn, ..., na.rm = FALSE, returnScores = FALSE, nRep = 100, parallelCluster = NULL, sameSample = FALSE )
resampleScoreModelPair( model1Values, model2Values, yValues, scoreFn, ..., na.rm = FALSE, returnScores = FALSE, nRep = 100, parallelCluster = NULL, sameSample = FALSE )
model1Values |
numeric array of predictions (model to test). |
model2Values |
numeric array of predictions (reference model). |
yValues |
numeric/logical array of outcomes, dependent, or truth values |
scoreFn |
function with signature scoreFn(modelValues,yValues) returning scalar numeric score. |
... |
not used, forces later arguments to be bound by name. |
na.rm |
logical, if TRUE remove NA values |
returnScores |
logical if TRUE return detailed resampledScores. |
nRep |
integer number of repititions to perform. |
parallelCluster |
optional snow-style parallel cluster. |
sameSample |
logical if TRUE use the same sample in computing both scores during bootstrap replication (else use independent samples). |
True confidence intervals are harder to get right (see "An Introduction to the Bootstrap", Bradely Efron, and Robert J. Tibshirani, Chapman & Hall/CRC, 1993.), but we will settle for simple p-value estimates.
summaries
set.seed(25325) y <- 1:5 m1 <- c(1,1,2,2,2) m2 <- c(1,1,1,1,2) cor(m1,y) cor(m2,y) f <- function(modelValues,yValues) { if((sd(modelValues)<=0)||(sd(yValues)<=0)) { return(0) } cor(modelValues,yValues) } resampleScoreModelPair(m1,m2,y,f)
set.seed(25325) y <- 1:5 m1 <- c(1,1,2,2,2) m2 <- c(1,1,1,1,2) cor(m1,y) cor(m2,y) f <- function(modelValues,yValues) { if((sd(modelValues)<=0)||(sd(yValues)<=0)) { return(0) } cor(modelValues,yValues) } resampleScoreModelPair(m1,m2,y,f)
Estimate significance of AUC by resampling test.
resampleTestAUC( d, modelName, yName, yTarget = TRUE, ..., na.rm = FALSE, returnScores = FALSE, nrep = 100, parallelCluster = NULL )
resampleTestAUC( d, modelName, yName, yTarget = TRUE, ..., na.rm = FALSE, returnScores = FALSE, nrep = 100, parallelCluster = NULL )
d |
data.frame |
modelName |
character model column name |
yName |
character outcome column name |
yTarget |
target to match to y |
... |
extra arguments (not used) |
na.rm |
logical, if TRUE remove NA values |
returnScores |
logical if TRUE return detailed resampledScores. |
nrep |
number of permutation repetitions to estimate p values. |
parallelCluster |
(optional) a cluster object created by package parallel or package snow. |
AUC statistic
set.seed(25325) d <- data.frame(x1=c(1,2,3,4,5,6,7,7), y=c(FALSE,TRUE,FALSE,FALSE, TRUE,TRUE,FALSE,TRUE)) resampleTestAUC(d,'x1','y',TRUE)
set.seed(25325) d <- data.frame(x1=c(1,2,3,4,5,6,7,7), y=c(FALSE,TRUE,FALSE,FALSE, TRUE,TRUE,FALSE,TRUE)) resampleTestAUC(d,'x1','y',TRUE)
Compute specificity and sensitivity given specificity and model fit parameters.
sensitivity_and_specificity_s12p12n( Score, ..., shape1_pos, shape2_pos, shape1_neg, shape2_neg )
sensitivity_and_specificity_s12p12n( Score, ..., shape1_pos, shape2_pos, shape1_neg, shape2_neg )
Score |
vector of sensitivities to evaluate |
... |
force later arguments to bind by name. |
shape1_pos |
beta shape1 parameter for positive examples |
shape2_pos |
beta shape2 parameter for positive examples |
shape1_neg |
beta shape1 parameter for negative examples |
shape2_neg |
beta shape1 parameter for negative examples |
Score, Specificity and Sensitivity data frame
library(wrapr) empirical_data <- rbind( data.frame( Score = rbeta(1000, shape1 = 3, shape2 = 2), y = TRUE), data.frame( Score = rbeta(1000, shape1 = 5, shape2 = 4), y = FALSE) ) unpack[shape1_pos = shape1, shape2_pos = shape2] <- fit_beta_shapes(empirical_data$Score[empirical_data$y]) shape1_pos shape2_pos unpack[shape1_neg = shape1, shape2_neg = shape2] <- fit_beta_shapes(empirical_data$Score[!empirical_data$y]) shape1_neg shape2_neg ideal_roc <- sensitivity_and_specificity_s12p12n( seq(0, 1, 0.1), shape1_pos = shape1_pos, shape1_neg = shape1_neg, shape2_pos = shape2_pos, shape2_neg = shape2_neg) empirical_roc <- build_ROC_curve( modelPredictions = empirical_data$Score, yValues = empirical_data$y ) # # should look very similar # library(ggplot2) # ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) + # geom_line(data = empirical_roc, color='DarkBlue') + # geom_line(data = ideal_roc, color = 'Orange')
library(wrapr) empirical_data <- rbind( data.frame( Score = rbeta(1000, shape1 = 3, shape2 = 2), y = TRUE), data.frame( Score = rbeta(1000, shape1 = 5, shape2 = 4), y = FALSE) ) unpack[shape1_pos = shape1, shape2_pos = shape2] <- fit_beta_shapes(empirical_data$Score[empirical_data$y]) shape1_pos shape2_pos unpack[shape1_neg = shape1, shape2_neg = shape2] <- fit_beta_shapes(empirical_data$Score[!empirical_data$y]) shape1_neg shape2_neg ideal_roc <- sensitivity_and_specificity_s12p12n( seq(0, 1, 0.1), shape1_pos = shape1_pos, shape1_neg = shape1_neg, shape2_pos = shape2_pos, shape2_neg = shape2_neg) empirical_roc <- build_ROC_curve( modelPredictions = empirical_data$Score, yValues = empirical_data$y ) # # should look very similar # library(ggplot2) # ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) + # geom_line(data = empirical_roc, color='DarkBlue') + # geom_line(data = ideal_roc, color = 'Orange')
Based on: https://blog.revolutionanalytics.com/2016/08/roc-curves-in-two-lines-of-code.html
sensitivity_from_specificity_q(Specificity, q)
sensitivity_from_specificity_q(Specificity, q)
Specificity |
vector of sensitivities to evaluate |
q |
shape parameter for |
Sensitivity
sensitivity_from_specificity_q(seq(0, 1, 0.1), 0.61)
sensitivity_from_specificity_q(seq(0, 1, 0.1), 0.61)
Estimate significance of difference in two AUCs by resampling.
testAUCpair( d, model1Name, model2Name, yName, yTarget = TRUE, ..., na.rm = FALSE, returnScores = FALSE, nrep = 100, parallelCluster = NULL )
testAUCpair( d, model1Name, model2Name, yName, yTarget = TRUE, ..., na.rm = FALSE, returnScores = FALSE, nrep = 100, parallelCluster = NULL )
d |
data.frame |
model1Name |
character model 1 column name |
model2Name |
character model 2 column name |
yName |
character outcome column name |
yTarget |
target to match to y |
... |
extra arguments (not used) |
na.rm |
logical, if TRUE remove NA values |
returnScores |
logical if TRUE return detailed resampledScores |
nrep |
number of re-sample repetition to estimate p value. |
parallelCluster |
(optional) a cluster object created by package parallel or package snow |
AUC pair test
set.seed(25325) d <- data.frame(x1=c(1,2,3,4,5,6,7,7), x2=1, y=c(FALSE,TRUE,FALSE,FALSE, TRUE,TRUE,FALSE,TRUE)) testAUCpair(d,'x1','x2','y',TRUE)
set.seed(25325) d <- data.frame(x1=c(1,2,3,4,5,6,7,7), x2=1, y=c(FALSE,TRUE,FALSE,FALSE, TRUE,TRUE,FALSE,TRUE)) testAUCpair(d,'x1','x2','y',TRUE)
Wrap TInterval (test of Binomial/Bernoulli rate).
TInterval(x, ...)
TInterval(x, ...)
x |
numeric, data.frame or test. |
... |
extra arguments |
TIntervalS
, TInterval.numeric
, TInterval.data.frame
Student-T tolerance-style interval around an estimate of a mean from a data.frame.
## S3 method for class 'data.frame' TInterval(x, ColumnName, ..., conf.level = 0.95, na.rm = FALSE)
## S3 method for class 'data.frame' TInterval(x, ColumnName, ..., conf.level = 0.95, na.rm = FALSE)
x |
data.frame |
ColumnName |
character name of measurment column |
... |
extra arguments passed to TInterval |
conf.level |
confidence level to draw interval |
na.rm |
logical, if TRUE remove NA values |
wrapped stat
TInterval
, TIntervalS
, TInterval.numeric
, TInterval.data.frame
set.seed(2018) d <- data.frame(x = rnorm(100) + 3.2) TInterval(d, "x")
set.seed(2018) d <- data.frame(x = rnorm(100) + 3.2) TInterval(d, "x")
Student-T tolerance-style interval around an estimate of a mean from observations.
## S3 method for class 'numeric' TInterval(x, ..., conf.level = 0.95, na.rm = FALSE)
## S3 method for class 'numeric' TInterval(x, ..., conf.level = 0.95, na.rm = FALSE)
x |
logical, vector of observations. |
... |
extra arguments passed to TInterval |
conf.level |
confidence level to draw interval |
na.rm |
logical, if TRUE remove NA values |
wrapped stat
TInterval
, TIntervalS
, TInterval.numeric
, TInterval.data.frame
set.seed(2018) d <- rnorm(100) + 3.2 TInterval(d)
set.seed(2018) d <- rnorm(100) + 3.2 TInterval(d)
Student-T tolerance-style interval around an estimate of a mean from summary.
TIntervalS( sample_size, sample_mean, sample_var, ..., nNA = 0, conf.level = 0.95 )
TIntervalS( sample_size, sample_mean, sample_var, ..., nNA = 0, conf.level = 0.95 )
sample_size |
numeric scalar integer, size of sample. |
sample_mean |
numeric scalar, mean of sample. |
sample_var |
numeric scalar, variance of sample (Bessel-corrected). |
... |
extra arguments passed to TInterval. |
nNA |
number of NAs seen. |
conf.level |
confidence level to draw interval |
wrapped stat
TInterval
, TIntervalS
, TInterval.numeric
, TInterval.data.frame
set.seed(2018) d <- rnorm(100) + 3.2 TIntervalS(length(d), mean(d), stats::var(d))
set.seed(2018) d <- rnorm(100) + 3.2 TIntervalS(length(d), mean(d), stats::var(d))
Wrap binom.test (test of Binomial/Bernoulli rate).
wrapBinomTest(x, ...)
wrapBinomTest(x, ...)
x |
numeric, data.frame or test. |
... |
extra arguments |
wrapBinomTest.htest
, wrapBinomTestS
, wrapBinomTest.logical
, wrapBinomTest.numeric
, wrapBinomTest.data.frame
Wrap binom.test (test of Binomial/Bernoulli rate).
## S3 method for class 'data.frame' wrapBinomTest( x, ColumnName, SuccessValue = TRUE, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, na.rm = FALSE )
## S3 method for class 'data.frame' wrapBinomTest( x, ColumnName, SuccessValue = TRUE, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, na.rm = FALSE )
x |
data.frame |
ColumnName |
character name of measurment column |
SuccessValue |
value considered a success (positive) |
... |
extra arguments passed to binom.test |
p |
number, hypothesized probability of success. |
alternative |
passed to |
conf.level |
passed to |
na.rm |
logical, if TRUE remove NA values |
wrapped stat
wrapBinomTest
, wrapBinomTest.htest
, wrapBinomTestS
, wrapBinomTest.logical
, wrapBinomTest.numeric
, wrapBinomTest.data.frame
d <- data.frame(x = c(rep(0, 3), rep(1, 7))) wrapBinomTest(d, "x", 1, p = 0.5) d <- data.frame(x = c(rep(0, 15), rep(1, 35))) wrapBinomTest(d, "x", 1, p = 0.5)
d <- data.frame(x = c(rep(0, 3), rep(1, 7))) wrapBinomTest(d, "x", 1, p = 0.5) d <- data.frame(x = c(rep(0, 15), rep(1, 35))) wrapBinomTest(d, "x", 1, p = 0.5)
Wrap binom.test (test of Binomial/Bernoulli rate).
## S3 method for class 'htest' wrapBinomTest(x, ...)
## S3 method for class 'htest' wrapBinomTest(x, ...)
x |
binom.test result |
... |
not used, just for argument compatibility |
wrapped stat
wrapBinomTest
, wrapBinomTest.htest
, wrapBinomTestS
, wrapBinomTest.logical
, wrapBinomTest.numeric
, wrapBinomTest.data.frame
bt <- binom.test(7, 10, 0.5) wrapBinomTest(bt)
bt <- binom.test(7, 10, 0.5) wrapBinomTest(bt)
Wrap binom.test (test of Binomial/Bernoulli rate).
## S3 method for class 'logical' wrapBinomTest( x, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, na.rm = FALSE )
## S3 method for class 'logical' wrapBinomTest( x, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, na.rm = FALSE )
x |
logical, vector of trials. |
... |
extra arguments passed to binom.test |
p |
number, hypothesized probability of success. |
alternative |
passed to |
conf.level |
passed to |
na.rm |
logical, if TRUE remove NA values |
wrapped stat
wrapBinomTest
, wrapBinomTest.htest
, wrapBinomTestS
, wrapBinomTest.logical
, wrapBinomTest.numeric
, wrapBinomTest.data.frame
x = c(rep(FALSE, 3), rep(TRUE, 7)) wrapBinomTest(x) x = c(rep(FALSE, 15), rep(TRUE, 35)) wrapBinomTest(x)
x = c(rep(FALSE, 3), rep(TRUE, 7)) wrapBinomTest(x) x = c(rep(FALSE, 15), rep(TRUE, 35)) wrapBinomTest(x)
Wrap binom.test (test of Binomial/Bernoulli rate).
## S3 method for class 'numeric' wrapBinomTest( x, SuccessValue = TRUE, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, na.rm = FALSE )
## S3 method for class 'numeric' wrapBinomTest( x, SuccessValue = TRUE, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, na.rm = FALSE )
x |
numeric, vector of trials. |
SuccessValue |
value considered a success (positive) |
... |
extra arguments passed to binom.test |
p |
number, hypothesized probability of success. |
alternative |
passed to |
conf.level |
passed to |
na.rm |
logical, if TRUE remove NA values |
wrapped stat
wrapBinomTest
, wrapBinomTest.htest
, wrapBinomTestS
, wrapBinomTest.logical
, wrapBinomTest.numeric
, wrapBinomTest.data.frame
x = c(rep(0, 3), rep(1, 7)) wrapBinomTest(x, 1) x = c(rep(0, 15), rep(1, 35)) wrapBinomTest(x, 1)
x = c(rep(0, 3), rep(1, 7)) wrapBinomTest(x, 1) x = c(rep(0, 15), rep(1, 35)) wrapBinomTest(x, 1)
Wrap binom.test (test of Binomial/Bernoulli rate) from summary.
wrapBinomTestS( x, n, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95 )
wrapBinomTestS( x, n, ..., p = NA, alternative = c("two.sided", "less", "greater"), conf.level = 0.95 )
x |
numeric scalar, number of successes. |
n |
numeric scalar, number of trials. |
... |
extra arguments passed to binom.test |
p |
number, hypothesized probability of success. |
alternative |
passed to |
conf.level |
passed to |
wrapped stat
wrapBinomTest
, wrapBinomTest.htest
, wrapBinomTestS
, wrapBinomTest.logical
, wrapBinomTest.numeric
, wrapBinomTest.data.frame
wrapBinomTestS(3, 7, p = 0.5) wrapBinomTestS(300, 700, p = 0.5)
wrapBinomTestS(3, 7, p = 0.5) wrapBinomTestS(300, 700, p = 0.5)
Wrap quality of a categorical prediction roughly in "APA Style" ( American Psychological Association ).
wrapChiSqTest(x, ...)
wrapChiSqTest(x, ...)
x |
numeric, data.frame or lm where to get model or data to score. |
... |
extra arguments |
wrapChiSqTestImpl
, wrapChiSqTest.glm
, and wrapChiSqTest.data.frame
Format ChiSqTest from anova of logistic model.
## S3 method for class 'anova' wrapChiSqTest(x, ...)
## S3 method for class 'anova' wrapChiSqTest(x, ...)
x |
result from stats::anova(stats::glm(family=binomial)) |
... |
extra arguments (not used) |
list of formatted string and fields
d <- data.frame(x1= c(1,2,3,4,5,6,7,7), x2= c(1,0,3,0,5,0,7,0), y= c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x1+x2, data=d, family=binomial) summary(model) render(wrapChiSqTest(model), pLargeCutoff=1, format='ascii') anov <- anova(model) print(anov) lapply(sigr::wrapChiSqTest(anov), function(ti) { sigr::render(ti, pLargeCutoff= 1, pSmallCutoff= 0, statDigits=4, sigDigits=4, format='ascii') })
d <- data.frame(x1= c(1,2,3,4,5,6,7,7), x2= c(1,0,3,0,5,0,7,0), y= c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x1+x2, data=d, family=binomial) summary(model) render(wrapChiSqTest(model), pLargeCutoff=1, format='ascii') anov <- anova(model) print(anov) lapply(sigr::wrapChiSqTest(anov), function(ti) { sigr::render(ti, pLargeCutoff= 1, pSmallCutoff= 0, statDigits=4, sigDigits=4, format='ascii') })
Format ChiSqTest from data.
## S3 method for class 'data.frame' wrapChiSqTest( x, predictionColumnName, yColumnName, ..., yTarget = TRUE, nParameters = 1, meany = mean(x[[yColumnName]] == yTarget), na.rm = FALSE )
## S3 method for class 'data.frame' wrapChiSqTest( x, predictionColumnName, yColumnName, ..., yTarget = TRUE, nParameters = 1, meany = mean(x[[yColumnName]] == yTarget), na.rm = FALSE )
x |
data frame containing columns to compare |
predictionColumnName |
character name of prediction column |
yColumnName |
character name of column containing dependent variable |
... |
extra arguments (not used) |
yTarget |
y value to consider positive |
nParameters |
number of variables in model |
meany |
(optional) mean of y |
na.rm |
logical, if TRUE remove NA values |
wrapped test
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x, data=d, family=binomial) summary(model) d$pred <- predict(model,type='response',newdata=d) render(wrapChiSqTest(d,'pred','y'),pLargeCutoff=1)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x, data=d, family=binomial) summary(model) d$pred <- predict(model,type='response',newdata=d) render(wrapChiSqTest(d,'pred','y'),pLargeCutoff=1)
Format ChiSqTest from model.
## S3 method for class 'glm' wrapChiSqTest(x, ...)
## S3 method for class 'glm' wrapChiSqTest(x, ...)
x |
glm logistic regression model (glm(family=binomial)) |
... |
extra arguments (not used) |
wrapped test
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x,data=d,family=binomial) summary(model) render(wrapChiSqTest(model),pLargeCutoff=1,format='ascii')
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x,data=d,family=binomial) summary(model) render(wrapChiSqTest(model),pLargeCutoff=1,format='ascii')
Format ChiSqTest from model summary.
## S3 method for class 'summary.glm' wrapChiSqTest(x, ...)
## S3 method for class 'summary.glm' wrapChiSqTest(x, ...)
x |
summary(glm(family=binomial)) object. |
... |
extra arguments (not used) |
wrapped test
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x,data=d,family=binomial) sum <- summary(model) render(wrapChiSqTest(sum),pLargeCutoff=1,format='ascii')
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x,data=d,family=binomial) sum <- summary(model) render(wrapChiSqTest(sum),pLargeCutoff=1,format='ascii')
Format quality of a logistic regression roughly in "APA Style" ( American Psychological Association ).
wrapChiSqTestImpl(df.null, df.residual, null.deviance, deviance)
wrapChiSqTestImpl(df.null, df.residual, null.deviance, deviance)
df.null |
null degrees of freedom. |
df.residual |
residual degrees of freedom. |
null.deviance |
null deviance |
deviance |
residual deviance |
wrapped statistic
wrapChiSqTestImpl(df.null=7,df.residual=6, null.deviance=11.09035,deviance=10.83726)
wrapChiSqTestImpl(df.null=7,df.residual=6, null.deviance=11.09035,deviance=10.83726)
Wrap Cohen's D (effect size between groups).
wrapCohenD(x, ...)
wrapCohenD(x, ...)
x |
numeric, data.frame or test. |
... |
extra arguments |
Wrap Cohen's D (effect size between groups).
## S3 method for class 'data.frame' wrapCohenD(x, Column1Name, Column2Name, ..., na.rm = FALSE)
## S3 method for class 'data.frame' wrapCohenD(x, Column1Name, Column2Name, ..., na.rm = FALSE)
x |
data.frame |
Column1Name |
character column 1 name |
Column2Name |
character column 2 name |
... |
extra arguments (not used) |
na.rm |
if TRUE remove NAs |
formatted string and fields
d <- data.frame(x = c(1,1,2,2,3,3,4,4), y = c(1,2,3,4,5,6,7,7)) render(wrapCohenD(d,'x','y'))
d <- data.frame(x = c(1,1,2,2,3,3,4,4), y = c(1,2,3,4,5,6,7,7)) render(wrapCohenD(d,'x','y'))
Wrap Cohen's D (effect size between groups).
## S3 method for class 'numeric' wrapCohenD(x, treatment, ..., na.rm = FALSE)
## S3 method for class 'numeric' wrapCohenD(x, treatment, ..., na.rm = FALSE)
x |
numeric reference or control measurements |
treatment |
numeric treatment or group-2 measurements |
... |
extra arguments (not used) |
na.rm |
if TRUE remove NAs |
formatted string and fields
d <- data.frame(x = c(1,1,2,2,3,3,4,4), y = c(1,2,3,4,5,6,7,7)) render(wrapCohenD(d$x, d$y))
d <- data.frame(x = c(1,1,2,2,3,3,4,4), y = c(1,2,3,4,5,6,7,7)) render(wrapCohenD(d$x, d$y))
Wrap cor.test (test of liner correlation).
wrapCorTest(x, ...)
wrapCorTest(x, ...)
x |
numeric, data.frame or test. |
... |
extra arguments |
wrapCorTest.htest
, and wrapCorTest.data.frame
Wrap cor.test (test of liner correlation).
## S3 method for class 'data.frame' wrapCorTest( x, Column1Name, Column2Name, ..., alternative = c("two.sided", "less", "greater"), method = c("pearson", "kendall", "spearman"), exact = NULL, conf.level = 0.95, continuity = FALSE, na.rm = FALSE )
## S3 method for class 'data.frame' wrapCorTest( x, Column1Name, Column2Name, ..., alternative = c("two.sided", "less", "greater"), method = c("pearson", "kendall", "spearman"), exact = NULL, conf.level = 0.95, continuity = FALSE, na.rm = FALSE )
x |
data.frame |
Column1Name |
character column 1 name |
Column2Name |
character column 2 name |
... |
extra arguments passed to cor.test |
alternative |
passed to |
method |
passed to |
exact |
passed to |
conf.level |
passed to |
continuity |
passed to |
na.rm |
logical, if TRUE remove NA values |
wrapped stat
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) wrapCorTest(d,'x','y')
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) wrapCorTest(d,'x','y')
Wrap cor.test (test of liner correlation).
## S3 method for class 'htest' wrapCorTest(x, ...)
## S3 method for class 'htest' wrapCorTest(x, ...)
x |
cor.test result |
... |
extra arguments (not used) |
wrapped stat
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) ct <- cor.test(d$x,d$y) wrapCorTest(ct)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) ct <- cor.test(d$x,d$y) wrapCorTest(ct)
Wrap fisher.test (test of categorical independence).
wrapFisherTest(x, ...)
wrapFisherTest(x, ...)
x |
numeric, data.frame or test. |
... |
extra arguments |
wrapFisherTest.htest
, and wrapFisherTest.data.frame
Wrap fisher.test (test of categorical independence).
## S3 method for class 'data.frame' wrapFisherTest( x, Column1Name, Column2Name, ..., na.rm = FALSE, workspace = 2e+05, hybrid = FALSE, control = list(), or = 1, alternative = "two.sided", conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE, B = 2000 )
## S3 method for class 'data.frame' wrapFisherTest( x, Column1Name, Column2Name, ..., na.rm = FALSE, workspace = 2e+05, hybrid = FALSE, control = list(), or = 1, alternative = "two.sided", conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE, B = 2000 )
x |
data.frame |
Column1Name |
character column 1 name |
Column2Name |
character column 2 name |
... |
extra arguments (not used) |
na.rm |
logical, if TRUE remove NA values |
workspace |
passed to |
hybrid |
passed to |
control |
passed to |
or |
passed to |
alternative |
passed to |
conf.int |
passed to |
conf.level |
passed to |
simulate.p.value |
passed to |
B |
passed to |
wrapped test.
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) wrapFisherTest(d, 'x', 'y')
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) wrapFisherTest(d, 'x', 'y')
Wrap fisher.test (test of categorical independence).
## S3 method for class 'htest' wrapFisherTest(x, ...)
## S3 method for class 'htest' wrapFisherTest(x, ...)
x |
fisher.test result |
... |
extra arguments (not used) |
wrapped test.
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) ft <- fisher.test(table(d)) wrapFisherTest(ft)
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) ft <- fisher.test(table(d)) wrapFisherTest(ft)
Wrap fisher.test (test of categorical independence).
## S3 method for class 'table' wrapFisherTest( x, ..., workspace = 2e+05, hybrid = FALSE, control = list(), or = 1, alternative = "two.sided", conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE, B = 2000 )
## S3 method for class 'table' wrapFisherTest( x, ..., workspace = 2e+05, hybrid = FALSE, control = list(), or = 1, alternative = "two.sided", conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE, B = 2000 )
x |
data.frame |
... |
extra arguments (not used) |
workspace |
passed to |
hybrid |
passed to |
control |
passed to |
or |
passed to |
alternative |
passed to |
conf.int |
passed to |
conf.level |
passed to |
simulate.p.value |
passed to |
B |
passed to |
wrapped test.
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) t <- table(d) wrapFisherTest(t)
d <- data.frame(x=c('b','a','a','a','b','b','b'), y=c('1','1','1','2','2','2','2')) t <- table(d) wrapFisherTest(t)
Wrap F-test (significance identity relation).
wrapFTest(x, ...)
wrapFTest(x, ...)
x |
numeric, data.frame or lm where to get model or data to score. |
... |
extra arguments |
wrapFTestImpl
, wrapFTest.lm
, and wrapFTest.data.frame
Wrap quality statistic of a linear relation from anova.
## S3 method for class 'anova' wrapFTest(x, ...)
## S3 method for class 'anova' wrapFTest(x, ...)
x |
result from stats::anova(stats::lm()) |
... |
extra arguments (not used) |
list of formatted string and fields
d <- data.frame(x1 = c(1,2,3,4,5,6,7,7), x2 = c(1,0,3,0,5,6,0,7), y = c(1,1,2,2,3,3,4,4)) model <- lm(y~x1+x2, data=d) summary(model) sigr::wrapFTest(model) anov <- stats::anova(model) print(anov) lapply(sigr::wrapFTest(anov), function(ti) { sigr::render(ti, pLargeCutoff= 1, pSmallCutoff= 0, statDigits=4, sigDigits=4, format='ascii') })
d <- data.frame(x1 = c(1,2,3,4,5,6,7,7), x2 = c(1,0,3,0,5,6,0,7), y = c(1,1,2,2,3,3,4,4)) model <- lm(y~x1+x2, data=d) summary(model) sigr::wrapFTest(model) anov <- stats::anova(model) print(anov) lapply(sigr::wrapFTest(anov), function(ti) { sigr::render(ti, pLargeCutoff= 1, pSmallCutoff= 0, statDigits=4, sigDigits=4, format='ascii') })
Wrap quality statistic of identity relation from data.
## S3 method for class 'data.frame' wrapFTest( x, predictionColumnName, yColumnName, nParameters = 1, meany = mean(x[[yColumnName]]), ..., na.rm = FALSE, format = NULL )
## S3 method for class 'data.frame' wrapFTest( x, predictionColumnName, yColumnName, nParameters = 1, meany = mean(x[[yColumnName]]), ..., na.rm = FALSE, format = NULL )
x |
data frame containing columns to compare |
predictionColumnName |
character name of prediction column |
yColumnName |
character name of column containing dependent variable |
nParameters |
number of variables in model |
meany |
(optional) mean of y |
... |
extra arguments (not used) |
na.rm |
logical, if TRUE remove NA values |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx") |
formatted string and fields
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) model <- lm(y~x,data=d) summary(model) d$pred <- predict(model,newdata=d) sigr::wrapFTest(d,'pred','y')
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) model <- lm(y~x,data=d) summary(model) d$pred <- predict(model,newdata=d) sigr::wrapFTest(d,'pred','y')
Wrap F-test (ratio of variances).
## S3 method for class 'htest' wrapFTest(x, ..., format = NULL)
## S3 method for class 'htest' wrapFTest(x, ..., format = NULL)
x |
lm model |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
formatted string
v <- var.test(c(1,2,3,4,5,6,7,7), c(1, 1, 2)) sigr::wrapFTest(v)
v <- var.test(c(1,2,3,4,5,6,7,7), c(1, 1, 2)) sigr::wrapFTest(v)
Wrap quality statistic of identity r regression.
## S3 method for class 'lm' wrapFTest(x, ..., format = NULL)
## S3 method for class 'lm' wrapFTest(x, ..., format = NULL)
x |
lm model |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
formatted string
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) model <- lm(y~x,data=d) summary(model) sigr::wrapFTest(model)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) model <- lm(y~x,data=d) summary(model) sigr::wrapFTest(model)
Wrap quality statistic of linear regression summary.
## S3 method for class 'summary.lm' wrapFTest(x, ..., format = NULL)
## S3 method for class 'summary.lm' wrapFTest(x, ..., format = NULL)
x |
summary.lm summary(lm()) object |
... |
extra arguments (not used) |
format |
if set the format to return ("html", "latex", "markdown", "ascii", "docx", ...) |
formatted string
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) model <- lm(y~x,data=d) sum <- summary(model) sigr::wrapFTest(sum)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) model <- lm(y~x,data=d) sum <- summary(model) sigr::wrapFTest(sum)
Please see https://github.com/WinVector/sigr/issues/1#issuecomment-322311947 for an example.
wrapFTestezANOVA(x, ...)
wrapFTestezANOVA(x, ...)
x |
list result from ezANOVA (package ez). |
... |
extra arguments (not used) |
list of formatted string and fields
Wrap F-test (significance of identity relation).
wrapFTestImpl(numdf, dendf, FValue, ..., format = NULL)
wrapFTestImpl(numdf, dendf, FValue, ..., format = NULL)
numdf |
degrees of freedom 1. |
dendf |
degrees of freedom 2. |
FValue |
observed F test statistic |
... |
not used, force later arguments to bind by name |
format |
optional, suggested format |
wrapped statistic
wrapFTestImpl(numdf=2,dendf=55,FValue=5.56)
wrapFTestImpl(numdf=2,dendf=55,FValue=5.56)
Wrap pwr test (difference in means by group).
wrapPWR(x, ...)
wrapPWR(x, ...)
x |
test from pwr package |
... |
extra arguments |
Wrap pwr test.
## S3 method for class 'power.htest' wrapPWR(x, ...)
## S3 method for class 'power.htest' wrapPWR(x, ...)
x |
pwr test result |
... |
extra arguments (not used) |
formatted string and fields
if(require("pwr", quietly = TRUE)) { # Example from pwr package # Exercise 6.1 p. 198 from Cohen (1988) test <- pwr::pwr.2p.test(h=0.3,n=80,sig.level=0.05,alternative="greater") wrapPWR(test) }
if(require("pwr", quietly = TRUE)) { # Example from pwr package # Exercise 6.1 p. 198 from Cohen (1988) test <- pwr::pwr.2p.test(h=0.3,n=80,sig.level=0.05,alternative="greater") wrapPWR(test) }
Wrap a significance
wrapSignificance(significance, symbol = "p")
wrapSignificance(significance, symbol = "p")
significance |
numeric the significance value. |
symbol |
the name of the value (e.g. "p", "t", ...). |
wrapped significance
wrapSignificance(1/300)
wrapSignificance(1/300)
Wrap t.test (difference in means by group).
wrapTTest(x, ...)
wrapTTest(x, ...)
x |
numeric, data.frame or test. |
... |
extra arguments |
wrapTTest.htest
, and wrapTTest.data.frame
Wrap t.test (difference in means by group).
## S3 method for class 'data.frame' wrapTTest( x, Column1Name, Column2Name, ..., y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, na.rm = FALSE )
## S3 method for class 'data.frame' wrapTTest( x, Column1Name, Column2Name, ..., y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, na.rm = FALSE )
x |
data.frame |
Column1Name |
character column 1 name |
Column2Name |
character column 2 name |
... |
extra arguments passed to ttest |
y |
passed to |
alternative |
passed to |
mu |
passed to |
paired |
passed to |
var.equal |
passed to |
conf.level |
passed to |
na.rm |
logical, if TRUE remove NA values |
formatted string and fields
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) render(wrapTTest(d,'x','y'),pLargeCutoff=1) # confirm p not order depedent render(wrapTTest(d,'y','x'),pLargeCutoff=1)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) render(wrapTTest(d,'x','y'),pLargeCutoff=1) # confirm p not order depedent render(wrapTTest(d,'y','x'),pLargeCutoff=1)
Wrap t.test (difference in means by group).
## S3 method for class 'htest' wrapTTest(x, ...)
## S3 method for class 'htest' wrapTTest(x, ...)
x |
t.test result |
... |
extra arguments (not used) |
formatted string and fields
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) tt <- t.test(d$x,d$y) render(wrapTTest(tt),pLargeCutoff=1) # confirm not rescaling, as a correlation test would render(wrapTTest(t.test(d$x,2*d$y)),pLargeCutoff=1)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) tt <- t.test(d$x,d$y) render(wrapTTest(tt),pLargeCutoff=1) # confirm not rescaling, as a correlation test would render(wrapTTest(t.test(d$x,2*d$y)),pLargeCutoff=1)
Wrap t.test (difference in means by group).
## S3 method for class 'numeric' wrapTTest( x, pop2, ..., y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, na.rm = FALSE )
## S3 method for class 'numeric' wrapTTest( x, pop2, ..., y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, na.rm = FALSE )
x |
numeric population 1 |
pop2 |
numeric population 2 |
... |
extra arguments passed to ttest |
y |
passed to |
alternative |
passed to |
mu |
passed to |
paired |
passed to |
var.equal |
passed to |
conf.level |
passed to |
na.rm |
logical, if TRUE remove NA values |
formatted string and fields
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) render(wrapTTest(d$x, d$y), pLargeCutoff=1) # confirm p not order depedent render(wrapTTest(d$y, d$x),pLargeCutoff=1)
d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(1,1,2,2,3,3,4,4)) render(wrapTTest(d$x, d$y), pLargeCutoff=1) # confirm p not order depedent render(wrapTTest(d$y, d$x),pLargeCutoff=1)