From 3941b146ce0178fc1a87e52895241673c376dcf4 Mon Sep 17 00:00:00 2001 From: Richard McElreath Date: Wed, 4 Nov 2020 15:51:41 +0100 Subject: [PATCH] map() no linear model bug - example R code 4.39 model m4.3 in 1st Edition of book doesn't work with link(). This should fix it. --- R/z_link-map-quap.r | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/z_link-map-quap.r b/R/z_link-map-quap.r index 4eb4924..660481d 100644 --- a/R/z_link-map-quap.r +++ b/R/z_link-map-quap.r @@ -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