unigausscpiterative: Iterative Gaussian Conjugate Prior It iterates over the data...

Description Usage Arguments Value Examples

View source: R/conjugatepriors.R

Description

Iterative Gaussian Conjugate Prior It iterates over the data and calls the function unigausscp for each point, setting the new prior as the posterior from the last data point.

Usage

1
unigausscpiterative(data, priormean, priorvar, datavar = NULL, n)

Arguments

data

data for analysis

priormean

- intial prior mean

priorvar

initial prior variance, if inverse gamma is desired this is the initial V0 parameter of the

datavar

a vector of the variance for each data point

n

a vector of sample sizes

Value

A list with the following elements: finalpostmean: a scalar of the final mean of the posterior, finalpostvar: the final posterior variance, finalpostsd: the final posterior standard deviation, dataweights: a vector of the weight of the data in the posterior, postmeans: a vector of the posterior means for each data point, postvar: a vector of the posterior variance for each data point, postsds: a vector of the posterior standard deviations for each data point, posta: a vector of the posterior values of a if invgamma = T, and postb: a vector of the posterior values of b in invgamma = T.

Examples

1
2
3
4
5
6
set.seed(12)
data1 = c(rnorm(10, mean = .48, sd = 0.05), rnorm(20, mean = .49, sd = 0.05),  rnorm(20, mean = .51, sd = 0.05))
n = floor(runif(50, 200, 800))
unigausscpiterative(data1, 0.5, 0.05, n = n)
data2 = c(rnorm(50, mean = 0.5, 0.05))
unigausscpiterative(data2, 0.5, 0.05, n = n)

balexanderstats/bayesurvey documentation built on Sept. 20, 2020, 11:40 a.m.