-
Notifications
You must be signed in to change notification settings - Fork 21
/
LinMatrixL.R
37 lines (33 loc) · 1.25 KB
/
LinMatrixL.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#' The linearized matrix L
#'
#' Function computes the derivative of the model with respect to the between subject variability
#' terms in the model (b's and bocc's) evaluated at
#' a defined point
#' (b_ind and bocc_ind).
#'
#' @inheritParams mf3
#' @param bpop The fixed effects parameter values. Supplied as a vector.
#' @param b_ind The point at which to evaluate the derivative
#' @param bocc_ind The point at which to evaluate the derivative
#' @param poped.db A PopED database.
#'
#' @return As a list:
#' \item{y}{A matrix of size (samples per individual x number of random effects)}
#' \item{poped.db}{A PopED database}
#' @example tests/testthat/examples_fcn_doc/warfarin_optimize.R
#' @example tests/testthat/examples_fcn_doc/examples_LinMatrixL.R
#' @export
#' @keywords internal
## Function translated automatically using 'matlab.to.r()'
## Author: Andrew Hooker
LinMatrixL <- function(model_switch,xt_ind,x,a,bpop,b_ind,bocc_ind,poped.db){
if((poped.db$parameters$NumRanEff==0)){
y=0
} else {
returnArgs <- gradff(model_switch,xt_ind,x,a,bpop,b_ind,bocc_ind,poped.db)
grad_ff_tmp <- returnArgs[[1]]
poped.db <- returnArgs[[2]]
y=grad_ff_tmp%*%gradfg(x,a,bpop,b_ind,bocc_ind,poped.db)
}
return(list( y= y,poped.db=poped.db))
}