fosr_predict: We have that Y_i(t) = sum(x_ij * alpha_tilde_j(t)) +...

Description Usage Arguments Details Value Examples

View source: R/helper_functions.R

Description

To get gamma_tilde, \gamma_k,i is simulated from it's predictive distribution using post_sigma_delta_k and post_nu. If post_sigma_delta_k is not provided, it is not sampled.

Usage

1
2
3
4
5
6
7
8
fosr_predict(
  X,
  post_fk,
  post_alpha,
  post_sigma_delta_k = NULL,
  post_nu = NULL,
  post_sigma_e = NULL
)

Arguments

X

a new input dataset to predict from

post_fk

mcmc samples from param fk

post_alpha

mcmc samples from param alpha

post_sigma_delta_k

mcmc samples from param sigma_delta_k

post_nu

mcmc samples from param nu

post_sigma_e

mcmc samples from param sigma_e

Details

eps_i is just white noise with standard deviations from post_sigma_e. If post_sigma_e is not provded, it is not sampled.

Value

a list containing the following:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library(fosr)

# Simulate some data:
n = 100
m = 20
p_0 = 100
p_1 = 5
sim_data  = simulate_fosr(n = n, m = m, p_0 = p_0, p_1 = p_1)

# Data:
Y = sim_data$Y
X = sim_data$X
tau = sim_data$tau

# Dimensions:
n = nrow(Y)
m = ncol(Y)
p = ncol(X)

# Run the FOSR:
out = fosr(
  Y = Y,
  tau = tau,
  X = X,
  K = 6,
  mcmc_params = list("fk", "alpha", "Yhat", "sigma_e", "sigma_g", "sigma_delta_k", "nu"))

YPredictInfo = fosr_predict(X, out$fk, out$alpha, out$sigma_delta_k, out$nu, out$sigma_e)

i = sample(1:n, 1)

YPredict = YPredictInfo$mean + YPredictInfo$gammaTilde + YPredictInfo$eps

plot_fitted(y = sim_data$Y[i,], mu = colMeans(YPredictInfo$mean[,i,]),
            postY = YPredict[,i,], y_true = sim_data$Y_true[i,], t01 = sim_data$tau)

drkowal/fosr documentation built on Oct. 2, 2020, 11:20 a.m.