pvalueMC: Estimate or Format p-values from Monte Carlo Samples

Description Usage Arguments Value Examples

View source: R/utility_functions.R

Description

Given a set of Monte Carlo samples, estimates a p-value from the proportion of values that fall above or below a comparison point. If string is TRUE, takes a numeric p-value and converts it into a formatted character string, either 'p = ...' or 'p < ...'.

Usage

1
pvalueMC(x, comparison = 0, alternative = "two-sided", digits = 3)

Arguments

x

either 1) a vector of numeric values (Monte Carlo samples) or 2) a single p-value.

comparison

the comparison point used to compute the p-value for the Monte Carlo samples.

alternative

a character string, either 1) 'two-sided', 2) 'greater', or 3) 'less', indicating the type of alternativ hypothesis to test. If 'two-sided', uses the alternativ hypothsis that produces the smallest p-value, and then adjusts for the two-sided comparison by multiplying by two.

digits

the number of digits to round to when formatting the numeric p-value

Value

Either a numeric p-value or a character string, a nicely formatted version of the p-value.

Examples

1
2
3
4
5
6
7
x = rnorm( 1000 )
p = pvalueMC( x )
print( pvalueMC( p ) )
p = pvalueMC( x, alternative = 'greater' )
print( pvalueMC( p ) )
p = pvalueMC( x, alternative = 'less' )
print( pvalueMC( p, digits = 4 ) )

rettopnivek/utilityf documentation built on March 1, 2021, 7:05 p.m.