Return a logical vector, indicating which parameters were free under maximization, as opposed to the fixed parameters that are treated as constants. See argument “fixed” for maxNR.

activePar(x, ...)
# Default S3 method
activePar(x, ...)

Arguments

x

object, created by a maximization routine, such as maxNR or maxLik, or derived from a maximization object.

...

further arguments for methods

Details

Several optimization routines allow the user to fix some parameter values (or do it automatically in some cases). For gradient or Hessian based inference one has to know which parameters carry optimization-related information.

Value

A logical vector, indicating whether the parameters were free to change during optimization algorithm.

Author

Ott Toomet

See also

maxNR, nObs

Examples

## a two-dimensional exponential hat
f <- function(a) exp(-a[1]^2 - a[2]^2)

## maximize wrt. both parameters 
free <- maxNR(f, start=1:2) 
summary(free)  # results should be close to (0,0)
#> --------------------------------------------
#> Newton-Raphson maximisation 
#> Number of iterations: 7 
#> Return code: 1 
#> gradient close to zero (gradtol) 
#> Function value: 1 
#> Estimates:
#>           estimate      gradient
#> [1,]  7.038825e-11 -1.110223e-10
#> [2,] -1.322742e-10  2.220446e-10
#> --------------------------------------------
activePar(free)
#> [1] TRUE TRUE

## keep the first parameter constant
cons <- maxNR(f, start=1:2, fixed=c(TRUE,FALSE))
summary(cons) # result should be around (1,0)
#> --------------------------------------------
#> Newton-Raphson maximisation 
#> Number of iterations: 4 
#> Return code: 1 
#> gradient close to zero (gradtol) 
#> Function value: 0.3678794 
#> Estimates:
#>          estimate      gradient
#> [1,] 1.000000e+00            NA
#> [2,] 3.515097e-07 -2.586265e-07
#> --------------------------------------------
activePar(cons)
#> [1] FALSE  TRUE