nlogLik_cauchy {OptimModel}R Documentation

Negative log-likelihood function for Cauchy regression

Description

The negative log-likelihood function for Cauchy regression, for use with rout_fitter. Usually not called by the end user.

Usage

 
       nlogLik_cauchy(theta, x, y, f.model, lbs)

Arguments

theta

Parameters for f.model and an extra parameter for the scale parameter; e.g., f.model=hill.model

x

Explanatory variable(s). Can be vector, matrix, or data.frame

y

Response variable.

f.model

Name of mean model function.

lbs

Logical. lbs = log both sides. See details.

Details

The function provides the negative log-likelihood for Cauchy regression

Let mu = f.model(theta[1:(p-1)], x) and sigma = exp(theta[p]), where p = number of parameters in theta.

The Cauchy likelihood is

L = \prod \frac{1}{\pi \sigma} ( 1 + ( \frac{y_i - \mu_i}{\sigma} )^2 )^{-1}

.

The function returns \log(L).

If lbs == TRUE, then \mu is replaced with \log(mu).

Value

Returns a single numerical value.

Author(s)

Steven Novick

See Also

rout_fitter

Examples

set.seed(123L)
x = rep( c(0, 2^(-4:4)), each=4 )
theta = c(emin=0, emax=100, lec50=log(.5), m=2)
y = hill_model(theta, x)  + rnorm( length(x), mean=0, sd=2 )

theta1 = c(theta, lsigma=log(2))
nlogLik_cauchy(theta1, x=x, y=y, f.model=hill_model, lbs=FALSE)

  ## Cauchy regression via maximum likelihood
optim( theta1, nlogLik_cauchy, x=x, y=y, f.model=hill_model, lbs=FALSE )


[Package OptimModel version 2.0-1 Index]