[R] estimate likelihood
ProfJCNash
profjcnash at gmail.com
Thu Mar 3 20:54:14 CET 2016
Not possible, because the hessian is singular. Recoded as follows (your
code should be executable before you put it in a help request).
# asindii2.R -- Is it possible to estimate the likelihood parameter
# and test for significant as follows:
x <- c(1.6, 1.7, 1.7, 1.7, 1.8, 1.8, 1.8, 1.8)
y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
n <- c(59, 60, 62, 56, 63, 59, 62, 60)
DF <- data.frame(x, y, n)
# note: there is no need to have the choose(n, y) term in the likelihood
fn <- function(p, DF) {
z <- p[1]+p[2]*DF$x
sum( - (DF$y*DF$z) - DF$n*log(1+exp(DF$z*DF$x)))
}
out <- nlm(fn, p = c(-50,20), hessian = TRUE, print.level=2, DF=DF)
print(out)
eigen(out$hessian)
sqrt(diag(solve(out$hessian)))
## ----- end of snippet ---
On 16-03-03 01:30 PM, Alaa Sindi wrote:
> Hi all,
>
> Is it possible to estimate the likelihood parameter and test for significant as follows:
>
> x <- c(1.6, 1.7, 1.7, 1.7, 1.8, 1.8, 1.8, 1.8)
> y <- c( 6, 13, 18, 28, 52, 53, 61, 60)
> n <- c(59, 60, 62, 56, 63, 59, 62, 60)
>
> # note: there is no need to have the choose(n, y) term in the likelihood
> fn <- function(p)
>
>
> z = p[1]+p[2]*x
> sum( - (y*z) - n*log(1+exp(z*x)))
>
> out <- nlm(fn, p = c(-50,20), hessian = TRUE, print.level=2)
>
> out
>
> eigen(out$hessian)
> sqrt(diag(solve(out$hessian)))
>
>
> Thanks
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list