贝叶斯估计
bioassay.post <- function(alpha = 0.1, beta = 5) {
k <- 4
x <- c(-0.86, -0.3, -0.05, 0.73)
n <- c(5, 5, 5, 5)
y <- c(0, 1, 3, 5)
prod <- 1
prod <- prod((exp(alpha + beta * x)/(1 + exp(alpha + beta * x)))^y *
(1/(1 + exp(alpha + beta * x)))^(n - y))
return(prod)
}
mlpost <- function(alpha = 0.1, beta = 5) {
-log(bioassay.post(alpha, beta))
}
library(bbmle)
mle(mlpost)
k <- 4
x <- c(-0.86, -0.3, -0.05, 0.73)
n <- c(5, 5, 5, 5)
y <- c(0, 1, 3, 5)
prod <- 1
prod <- prod((exp(alpha + beta * x)/(1 + exp(alpha + beta * x)))^y *
(1/(1 + exp(alpha + beta * x)))^(n - y))
return(prod)
}
mlpost <- function(alpha = 0.1, beta = 5) {
-log(bioassay.post(alpha, beta))
}
library(bbmle)
mle(mlpost)
评论
发表评论