Description Usage Arguments Value Examples
Runs Hierarchical infinite factor model - using HDP prior on loadings matrix Includes coefficient calculations
1 2 3 |
X |
predictors (unscaled). |
Y |
outcomes. |
K |
number of factors. |
groups |
vector indicating which groups people are in (for single group, rep(1, nrow(X))) |
n.sim |
number of iterations in sampler. |
alpha0 |
pi^0 concentration parameter (for top level of HDP). |
test |
test indices |
train |
indices for training set |
fact_prior |
= "laplace" or "normal" |
alpha_j |
concentration parameter should be of length J. |
tau |
degree of freedom for phi. |
pi0 |
initial values for pi0 |
C |
tuning parameter for pi^0 MH |
v |
degree of freedom for Sigma |
List of multiple return arguments: params - final iteration of all parameters, ftest - posterior samples of factors for test set (without any information on y), xtest - posterior samples of test set x with transformations, w_j - iterations of weights for each population, sigma2_j - posterior iterations of sigma2 (idiosyncratic noise), lambdas - posterior of loadings matrix, pred_resp - posterior predictive response of test set
1 2 3 4 5 6 7 8 |
sim1 <- sim_data(500, 5, 20, 300,alpha0 = 25, alpha_1=25, alpha_2=25)
test <- sample(sim1$Duke, 100);
groups_sim <- rep(1, 500); groups_sim[-sim1$Duke]=2
test_norm <- hifm(sim1$X[,-c(1)], Y=sim1$X[-test,1],K= 10,
groups=groups_sim, n.sim=1000, alpha0=15,test= test,
train=c(1:500)[-test], alpha_j=c(20,20), a=5, b=4, tau=4,
lam=2, J=2, C=40,fact_prior="normal")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.