Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created December 3, 2021 12:28
Show Gist options
  • Select an option

  • Save MJacobs1985/08943374f9e138f0a4a88ad7eff1e422 to your computer and use it in GitHub Desktop.

Select an option

Save MJacobs1985/08943374f9e138f0a4a88ad7eff1e422 to your computer and use it in GitHub Desktop.
Book<- read_excel("X:/StatisticsPlatform/Website/ELearning/Workshops/Bayesian Analysis/Data/Book1.xlsx")
d<-Book%>%dplyr::select(ADG,Country)
d<-d[complete.cases(d), ]
d$Country<-as.factor(d$Country)
histogram(~ADG | Country, data=d,
type="density",
xlab="ADG" ,
ylab="Density")
fit<-lmer(ADG~1+(1|Country), data=d);summary(fit)
m13.1 <- ulam(
alist(
ADG ~ dnorm(m,s),
m <- a[Country] ,
a[Country] ~ dnorm(41, 6),
s ~ dnorm(47,6)
), data=d , chains=4 , log_lik=TRUE )
m13.2 <- ulam(
alist(
ADG ~ dnorm(m,s),
m <- a[Country] ,
a[Country] ~ dnorm(cm, cs),
cm ~ dnorm(41,6),
cs ~ dnorm(47,6),
s ~ dnorm(0,6)
), data=d , chains=4 , log_lik=TRUE )
show(m13.2)
precis(m13.2 , 2 )
pairs(m13.2 )
traceplot(m13.2)
trankplot(m13.2 )
coef(m13.2)
postcheck(m13.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment