#' Sum computation 2
#'
#' Internal function used compute a sum in FPCA-based covariance updates
#'
#' @param y outcome matrix
#' @param subj.id vector of subject ids
#' @param fixef current estimate of fixed effects
#' @param mu.q.c current value of mu.q.c
#' @param kt number of basis functions
#' @param theta spline basis
#'
#' @author Jeff Goldsmith \email{ajg2202@@cumc.columbia.edu}
#'
f_sum2 = function(y, subj.id, fixef, mu.q.c, kt, theta){
I = dim(mu.q.c)[1]
kp = dim(mu.q.c)[2]
ret.sum = matrix(0, nrow = kp*kt, ncol = 1)
subjs = unique(subj.id)
for(i in 1:I){
index = which(subj.id == subjs[i])
ret.sum = ret.sum + kronecker((matrix(mu.q.c[i,])), theta[,index]) %*% matrix(y[index] - fixef[index])
}
return(ret.sum)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.