R/num_parameters.R

Defines functions num_parameters.default num_parameters

Documented in num_parameters num_parameters.default

#' Get the Number of Parameters
#' 
#' Gets the Number of Parameters associated with an object.
#' Generic, with method \code{\link{num_parameters.default}}.
#' @param x object of dispatch
#' @param ... passed arguments
#' @export
#' @keywords internal
num_parameters <-
  function(x,...)UseMethod('num_parameters')

#' Get the Number of Declared Parameters for a NONMEM Model
#' 
#' Gets the number of declared parameters for a NONMEM model.
#' 
#' Parameters fixed to some value are included, but unlike (*.ext) matrix off-diagonals
#' are not included unless specified.
#' 
#' @param x object of dispatch
#' @param ... passed arguments
#' @return integer
#' @export
#' @keywords internal
#' @examples
#' library(magrittr)
#' options(project = system.file('project/model',package='nonmemica'))
#' 1001 %>% num_parameters
num_parameters.default <-
  function(x,...){
    y <- as.model(x,parse=TRUE,...)
    y <- y[names(y) %in% c('theta','omega','sigma')]
    len <- sapply(y,length)
    sum(len)
  }
bergsmat/nonmemica documentation built on Sept. 15, 2023, 9:22 a.m.