if (FALSE) {
set.seed(238642)
x <- seq(0, 100, length=100)
# Plots showing effects of changes in parameter Sigma
plot(x, halfnorm.like(20, x), type="l", col="red")
plot(x, halfnorm.like(40, x), type="l", col="blue")
# Estimate 'halfnorm' distance function
a <- 5
x <- rnorm(1000, mean=0, sd=a)
x <- x[x >= 0]
dfunc <- dfuncEstim(x~1, likelihood="halfnorm")
plot(dfunc)
# evaluate the log Likelihood
L <- halfnorm.like(dfunc$parameters, dfunc$detections$dist, covars=dfunc$covars,
w.lo=dfunc$w.lo, w.hi=dfunc$w.hi,
series=dfunc$series, expansions=dfunc$expansions,
scale=TRUE)
-sum(log(L), na.rm=TRUE) # the negative log likelihood
}
Run the code above in your browser using DataLab