hifm: Runs Hierarchical infinite factor model - using HDP prior on...

Description Usage Arguments Value Examples

Description

Runs Hierarchical infinite factor model - using HDP prior on loadings matrix Includes coefficient calculations

Usage

1
2
3
hifm(X, Y = NULL, K, groups, n.sim, alpha0, test, train, lam,
  fact_prior = "laplace", alpha_j, a, b, tau, pi0 = NULL, wj1 = NULL,
  wj2 = NULL, phi_0 = NULL, C = 2, J = 2, Ytest = NULL)

Arguments

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

Value

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

Examples

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")

lizlorenzi/hifm documentation built on May 20, 2019, 9:38 a.m.