epinowcast
Loading...
Searching...
No Matches
combine_effects.stan
Go to the documentation of this file.
1
62vector combine_effects(array[] real intercept, vector beta,
63 int nobs, int neffs,
64 // Dense matrix components
65 matrix fdesign,
66 // Sparse matrix components
67 tuple(vector, array[] int, array[] int) sparse,
68 vector beta_sd,
69 // Dense matrix for random effects
70 matrix rdesign,
71 int add_intercept, int sparse_design) {
72 if (neffs) {
73 vector[1 + num_elements(beta_sd)] ext_beta_sd = append_row(1.0, beta_sd);
74 vector[nobs] result;
75 vector[neffs] scaled_beta = beta .* (rdesign * ext_beta_sd);
76
77 if (sparse_design) {
78 // Extract sparse matrix components from fdesign
79 result = csr_matrix_times_vector(
80 nobs, neffs, sparse.1, sparse.2, sparse.3, scaled_beta
81 );
82 } else {
83 result = fdesign * scaled_beta;
84 }
85
86 if (add_intercept) {
87 result = result + intercept[1];
88 }
89 return(result);
90 } else {
91 return(rep_vector(intercept[1], nobs));
92 }
93}
vector combine_effects(array[] real intercept, vector beta, int nobs, int neffs, matrix fdesign, tuple(vector, array[] int, array[] int) sparse, vector beta_sd, matrix rdesign, int add_intercept, int sparse_design)