posteriorTime_EmpiricalBayesian: posteriorTime_EmpiricalBayesian

Description Usage Arguments Details Value Author(s) Examples

View source: R/posteriorTime_EmpiricalBayesian.R

Description

Calculating the posterior distribution of time for new individuals

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
posteriorTime_EmpiricalBayesian(
  New_Y,
  Data_Y,
  Data_time,
  nu0 = 1,
  Lambda0 = NULL,
  Sigma0 = NULL,
  Beta0 = NULL,
  maxTime = 12,
  delta = 0.01,
  priorTime = NULL,
  optsettings = list(noptim = 4, optimsd = 1)
)

Arguments

New_Y

The observed response for new individuals (nsamples x nsites) matrix (also possible with vector)

Data_Y

This is observed multi-responses (nsamples x nsites)

Data_time

This is observed times (nsamples vector)

nu0

degrees of freedom hyperparameter of invWishart prior distribution (should be 0=non-informative or 1=informative)

Lambda0

Scale matrix hyperparameter of invWishart prior distribution of Covariance (can be numeric or matrix)

Sigma0

Covariance hyperparameter of Normal prior distribution of beta (can be numeric, 2 or 3 long vector)

Beta0

Mean hyperparameter of Normal prior distribution of beta (can be 2 long vector or matrix)

maxTime

maximum of time (upper limit)

delta

Grid size for the time variable

priorTime

A prior distribution for the time variable (NULL means uniform distribution)

optsettings

A list of settings for optimizing the marginal evidence wrt hyperparam

Details

This function provides posterior distribution of time, based on a multivariate model (Full Bayesian approach), where time as a continuous exploratory variable from zero to maxTime

Prediction: Applying Bayes Theorem: p(time|Y) = konstant x p(Y|time) x p(time) We assume an uniform prior for p(log(time))=unif, gives p(time)=1/t

Model: A full Bayesian model (takes into account the uncertainty of the parameters) p(Y|time) = int_theta p(Y|time,theta)p(theta) d_theta Where p(Y|time,theta)=MVN(b0 + b1*time, SIGMA), SIGMA= COVARIANCE MATRIX with latent priors 'normal-invWishart' p(b0,b1|SIGMA)=MVN(0,0, diag(sig0 SIGMA,sig1 SIGMA)) p(SIGMA) = invWishart(Lambda0,nu0), where diag(Lambda0) = lam0

Posterior predictor p(Ynew|time) is a m-Multivariate T-distribution(M,A,nu): p(Y) = gamma((nu+m)/2)/gamma(nu/2) (pi*nu)^(-m/2) |A|^-0.5 (1 + (Y-M)'A^-1(Y-M)/nu)^-(nu+m)/2

Value

ret list with posterior distribution for each new individuals (separate list for univariate prediction and all combined)

Author(s)

Oyvind Bleka

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run:  
ntrain = 100
ntest = 1
dat = genData(ntrain+ ntest,seed=1)
Data_Y = dat$Data_Y[1:ntrain,]
Data_time = dat$Data_time[1:ntrain]
New_Y = dat$Data_Y[-(1:ntrain),]
New_time = dat$Data_time[-(1:ntrain)]
predObj = posteriorTime_EmpiricalBayesian(New_Y, Data_Y, Data_time)
plotPredictions(predObj)

## End(Not run)

oyvble/TSDpredict documentation built on June 28, 2020, 10:42 a.m.