activePar: free parameters under maximization

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/activePar.R

Description

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.

Usage

1
2
3
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(s)

Ott Toomet

See Also

maxNR, nObs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)
activePar(free)

## keep the first parameter constant
cons <- maxNR(f, start=1:2, fixed=c(TRUE,FALSE))
summary(cons) # result should be around (1,0)
activePar(cons)

Example output

Loading required package: miscTools

Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.

If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
--------------------------------------------
Newton-Raphson maximisation 
Number of iterations: 7 
Return code: 1 
gradient close to zero (gradtol) 
Function value: 1 
Estimates:
          estimate     gradient
[1,] -3.331680e-11 1.110223e-10
[2,] -5.643347e-11 1.110223e-10
--------------------------------------------
[1] TRUE TRUE
--------------------------------------------
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
--------------------------------------------
[1] FALSE  TRUE

maxLik documentation built on July 27, 2021, 1:07 a.m.