Skip to content

Commit

Permalink
map() no linear model bug
Browse files Browse the repository at this point in the history
- example R code 4.39 model m4.3 in 1st Edition of book doesn't work with link(). This should fix it.
  • Loading branch information
Richard McElreath committed Nov 4, 2020
1 parent 3b48ec8 commit 3941b14
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/z_link-map-quap.r
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function( fit , data , n=1000 , post , refresh=0 , replace=list() , flatten=TRUE
# hacky solution -- find density function and insert whatever expression in typical link spot
flik <- as.character(fit@formula[[1]][[3]][[1]])
# mu for Gaussian
if ( flik=="dnorm" ) lm <- as.character( fit@formula[[1]][[3]][[2]] )
if ( flik=="dnorm" ) lm <- deparse( fit@formula[[1]][[3]][[2]] )
# p for binomial -- assume in third spot, after size
if ( flik=="dbinom" ) lm <- as.character( fit@formula[[1]][[3]][[3]] )
if ( flik=="dbinom" ) lm <- deparse( fit@formula[[1]][[3]][[3]] )
# lambda for poisson
if ( flik=="dpois" ) lm <- as.character( fit@formula[[1]][[3]][[2]] )
if ( flik=="dpois" ) lm <- deparse( fit@formula[[1]][[3]][[2]] )
}
# empty matrix to hold samples-by-cases values of linear model
n_cases <- 0
Expand Down

0 comments on commit 3941b14

Please sign in to comment.