Cpp function: calculate the four type of log likelihood function (observed likelihood, penalized likelihood, complete likelihood, penalized complete likelihood) in all levels.

calcLL(X, Z, y, seg, W, V, lambda1, lambda2, alpha1, alpha2, multiply = FALSE)

Arguments

X

an aggregated data matrix (n*P) of input in experts network (rbind of all levels input).

Z

a data matrix (n*q) of input in gating network.

y

a vector of response (n).

seg

an integer vector of length in each level (L).

W

aggregated parameters in experts network (cbind of all levels) ((P+L)*K).

V

parameters in gating network((q+1)*K).

lambda1

aggregated penalty lambda parameters in experts network(P*K).

lambda2

penalty parameters lambda in gating network(q*1).

alpha1

penalty parameters alpha in experts network(L*K).

alpha2

penalty parameter alpha in gating network(1).

multiply

a bool variable indicate whether lambda parameters times sample size.

Value

A matrix of four types of likelihood function.