Learn R Programming

Bolstad2 (version 1.0-29)

pnullNum: Test a one sided hypothesis from a numerically specified posterior CDF

Description

Calculates the probability of a one sided null hypothesis from a numerically calculated posterior CDF.

Usage

pnullNum(theta0, theta, cdf, type = "upper")

Arguments

theta0

the hypothesized value, i.e. H0: theta <= theta0

theta

the values over which the the posterior CDF is specified

cdf

the values of the CDF, \(F(\theta) = \int_{-\infty}^{\theta}f(t).df\) where \(f(t)\) is the PDF.

type

the type of probability to return, 'lower' = Pr(theta <= theta0) or 'upper' = Pr(theta >= theta0). It is sufficient to use 'l' or 'u'

Value

a list containing the element prob which will be the upper or lower tail probability depending on type

Details

This function uses linear interpolation to calculate bounds for points that may not be specified by CDF

Examples

Run this code
# NOT RUN {
## commands for calculating a numerical posterior CDF.
## In this example, the likelihood is proportional to
## \eqn{\theta^{3/2}\times \exp(-\theta/4)} and a N(6, 9) prior is used.
theta = seq(from = 0.001, to = 40, by = 0.001)
prior = dnorm(theta,6,3)
ppnLike = theta^1.5*exp(-theta/4)
ppnPost = prior*ppnLike
scaleFactor = sintegral(theta, ppnPost)$int
posterior = ppnPost/scaleFactor
cdf = sintegral(theta, posterior)$y
pnullNum(1, theta, cdf)

# }

Run the code above in your browser using DataLab