fityxOptimx: Maximum likelihood estimation for unknown hazard and...

Description Usage Arguments Details Value See Also Examples

View source: R/2DLToptimx.R

Description

Uses optim to obtain a MLE for the hazard function and animal perpendicular distance distribution. Functional forms for the hazard and perpendicular distance distribution must be specified.

Usage

1
2
3
fityxOptimx(y, x, b, hr, ystart, pi.x, logphi, w, method = "Nelder-Mead",
  lower = -Inf, upper = Inf, control = list(), itnmax = NULL,
  hessian = FALSE, corrFlag = 0.7, ...)

Arguments

y

forward distance observations

x

perpendicular distance observations

b

two to four element vector of hazard rate parameters, some of which may be logged

hr

hazard rate function

ystart

max forward distance at which could possibly detect animal (see details).

pi.x

perpendicular distance density distribution

logphi

parameters for pi.x (some maybe logged)

w

perpendicular truncation distance.

method

optimisation method to be used by optimx. Default is "Nelder-Mead"

lower,

upper Bounds for parameters for use with methods such as "L-BFGS-B". See optimx.

control

see optimx control

itnmax

maximum number of iterations for the Nelder-Mead method. NB this is not passed in via the control argument

hessian

return hessian. See also optimx.

...

arguments to be passed into optimx

corrFlag=0.7

Absolute parameter correlation value above which a warning is issued.

Details

Must to ensure the hazard function has decayed to (very close to) zero by ystart.

Value

optim fit object and
$hr = hazard rate function used.
$pi.x = perpendicular distance function used.
$ystart = ystart max forward distance detection used.
$w = perpendicular truncation distance used.
$b = estimated hazard parameters
$dat = data frame with data ($x and $y)
$logphi
AIC AIC value
And if hessian=TRUE:
vcov variance covariance matrix. Will warn if there is a problem inverting the hessian.
CVpar Coefficient of variation for each paramter estimate.
error Boolean, TRUE if convergence!=0 or problem inverting the hessian, or parameter correlation is exceeded.

See Also

negloglik.yx fityx optimx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
#Data preparation:
w=0.03;ystart=0.05
library(xlsx)
dat=read.xlsx("~/Dropbox/packages/LT2D/data/Jantho Primate Line.xlsx",1)
x=dat$PP.Distance
y=dat$Forward.Distance
nas=which(is.na(y))
x=x[-nas]
y=y[-nas]
gtw=which(x>w)
x=x[-gtw]
y=y[-gtw]
#Example model fits:

b=c(-7.3287948, 0.9945317)
logphi=c(.01646734, -4.67131261)
fit.n.optx=NULL
fit.n.optx=fityxOptimx(y,x,b=b,
           hr=h1,ystart=ystart,
           control=list(trace=5),hessian=TRUE,
           pi.x=pi.norm,logphi=logphi,w=w)

b=c(-7.3329141,0.9948721)
logphi=c(-0.05,-4.7)
fit.chn.optx=NULL
fit.chn.optx=fityxOptimx(y,x,b=b,hr=h1,ystart=ystart,
             pi.x=pi.chnorm,logphi=logphi,w=w,itnmax=5000,
             hessian=TRUE,control=list(trace=5))

b=c(5.2919208, -0.2205593, 8.4701307)
logphi=c(0.01784102, -4.42209067)
fit.n.ip1.optx=NULL
fit.n.ip1.optx=fityxOptimx(y,x,b=b,hr=ip1,ystart=ystart,
               pi.x=pi.norm,logphi=logphi,w=w,
               hessian=TRUE,control=list(trace=6))

## End(Not run)

david-borchers/LT2D documentation built on Aug. 17, 2020, 1:37 a.m.