R: Test a one sided hypothesis using a sample from a posterior...
pnullSamp
R Documentation
Test a one sided hypothesis using a sample from a posterior density
Description
Calculates the probability of a one sided null hypothesis from a sample
from a posterior density.
Usage
pnullSamp(theta, theta0 = 0, type = 'upper')
Arguments
theta
a sample of values from a posterior density
theta0
the hypothesized value, i.e. H0: theta <= theta0
type
the type of probability to return, 'lower' = Pr(theta <=
theta0) or 'upper' = Pr(theta >= theta0). It is sufficient to use 'l' or
'u'
Details
This function uses linear interpolation to calculate bounds for points
that may not be specified by CDF
Value
a list containing the element prob which will be the upper or lower
tail probability depending on type
Examples
## The posterior density is N(3,1)
theta <- rnorm(1000,3)
## test whether the true mean is greater than 0 (it is obviously!)
pnullSamp(theta)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Bolstad2)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Bolstad2/pnullSamp.Rd_%03d_medium.png", width=480, height=480)
> ### Name: pnullSamp
> ### Title: Test a one sided hypothesis using a sample from a posterior
> ### density
> ### Aliases: pnullSamp
>
> ### ** Examples
>
> ## The posterior density is N(3,1)
> theta <- rnorm(1000,3)
>
> ## test whether the true mean is greater than 0 (it is obviously!)
> pnullSamp(theta)
Posterior Pr(theta>=theta0) is 0.002
>
>
>
>
>
> dev.off()
null device
1
>