Skip to content

Commit

Permalink
updated demo3_6
Browse files Browse the repository at this point in the history
  • Loading branch information
avehtari committed Oct 8, 2018
1 parent 6659db7 commit cbb4861
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions demos_ch3/demo3_6.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ cB <- rep(B, length(A))

#' Make a helper function to calculate the log likelihood
#' given a dataframe with x, y, and n and evaluation
#' points a and b. For the likelihood see BDA p. 75
#' points a and b. For the likelihood see BDA3 p. 75<br>
#' `log1p(x)` computes log(x+1) in numerically more stable way.
logl <- function(df, a, b)
df['y']*(a + b*df['x']) - df['n']*log1p(exp(a + b*df['x']))

Expand All @@ -68,9 +69,6 @@ samp_B <- samp_B + runif(nsamp, (B[1] - B[2])/2, (B[2] - B[1])/2)
samps <- data_frame(ind = 1:nsamp, alpha = samp_A, beta = samp_B) %>%
mutate(ld50 = - alpha/beta)

#' Sample LD50 conditional beta > 0
sampsposbeta <- filter(samps, beta > 0)

#' Plot draws of logistic curves
invlogit <- plogis
xr <- seq(-1.5, 1.5, length.out = 100)
Expand Down

0 comments on commit cbb4861

Please sign in to comment.