parnames: get and set parameter names

Description Usage Arguments Details Value Author(s) Examples

View source: R/mle.R

Description

Gets and sets the "parnames" attribute on a negative log-likelihood function

Usage

1
2
parnames(obj)
parnames(obj) <- value

Arguments

obj

a negative log-likelihood function

value

a character vector of parameter names

Details

The parnames attribute is used by mle2() when the negative log-likelihood function takes a parameter vector, rather than a list of parameters; this allows users to use the same objective function for optim() and mle2()

Value

Returns the parnames attribute (a character vector of parameter names) or sets it.

Author(s)

Ben Bolker

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- 1:5
set.seed(1001)
y <- rbinom(5,prob=x/(1+x),size=10)
mfun <- function(p) {
  a <- p[1]
  b <- p[2]
  -sum(dbinom(y,prob=a*x/(b+x),size=10,log=TRUE))
}
optim(fn=mfun,par=c(1,1))
parnames(mfun) <- c("a","b")
mle2(minuslogl=mfun,start=c(a=1,b=1),method="Nelder-Mead")

Example output

Loading required package: stats4
$par
[1] 0.8462090 0.1292243

$value
[1] 6.424763

$counts
function gradient 
      67       NA 

$convergence
[1] 0

$message
NULL


Call:
mle2(minuslogl = mfun, start = c(a = 1, b = 1), method = "Nelder-Mead")

Coefficients:
        a         b 
0.8462090 0.1292243 

Log-likelihood: -6.42 

bbmle documentation built on May 2, 2019, 4:54 p.m.