parmatrix.byix: Create a function that will set up a parmatrix

Description Usage Arguments Details Value Examples

View source: R/parsetup.R

Description

Creates a function that takes a simple vector of parameters and creates a matrix, repeating parameters and substituting default values as required.

Usage

1
parmatrix.byix(ix, dpar)

Arguments

ix

A matrix that defines which value from the simple vector go in that location. If a default value is needed instead, the value should be set to NA.

dpar

A matrix that defines the default values for locations in the ix matrix set to NA. Values in other locations are ignored.

Details

Suppose a function takes a matrix of predictors, and you want to optimize those predictors, but with some of them always set equal to each other and others always set to some default value. Since the optimize function uses not the full matrix as input and output but instead, a simple vector of the parameters that are allowed to change. This function creates a function that will convert this simple vector to the full matrix, repeating values as necessary and filling in default values.

Value

A function that takes a simple vector of parameters and creates a matrix, repeating parameters and substituting default values as required.

Examples

1
2
3
4
5
6
7
(par.index <- matrix(c(1,1,2,NA), nrow=2))
 
(par.default <- matrix(c(NA,NA,NA,100), nrow=2))
 
par.function <- parmatrix.byix(par.index, par.default)
par.function(c(1.1, 1.2))
par.function(c(21, 22))

HegemanLab/ProteinTurnover documentation built on May 6, 2019, 11:50 p.m.