-
Notifications
You must be signed in to change notification settings - Fork 614
Open
Description
I was trying to compare the no correlation, brownian, and OU models in the phlogenetic section, but, ran into issues with the log_lik argument
library(rethinking)
library(dplyr)
data(Primates301)
dstan <- Primates301 |>
mutate(name = as.character(name)) |>
filter(!is.na(group_size),
!is.na(body),
!is.na(brain)
)
# for matrices
spp_obs <- dstan$name
# A list of data
dat_list <- list(
N_spp = nrow(dstan),
M = standardize(log(dstan$body)),
B = standardize(log(dstan$brain)),
G = standardize(log(dstan$group_size)),
Imat = diag(nrow(dstan)) )
no_phylo <- ulam(
alist(
#likelihood
B ~ multi_normal( mu , SIGMA ),
# DGP
mu <- a + bM*M + bG*G,
# Autocorr
matrix[N_spp,N_spp]: SIGMA <- Imat * sigma_sq,
#priors
a ~ normal( 0 , 1 ),
c(bM,bG) ~ normal( 0 , 0.5 ),
sigma_sq ~ exponential( 1 )
), data=dat_list , chains=4 , cores=4,
log_lik = TRUE)
Yields
Compiling Stan program...
Semantic error in '/var/folders/qs/k7z4lcnx7rdg5hbhp2jr7rs00000gn/T/Rtmpr1OeQW/model-f57a72635ad9.stan', line 35, column 4 to column 11:
-------------------------------------------------
33: mu[i] = a + bM * M[i] + bG * G[i];
34: }
35: log_lik = multi_normal_lpdf( B | mu , SIGMA );
^
36: }
37:
-------------------------------------------------
Ill-typed arguments supplied to assignment operator =:
The left hand side has type
vector
and the right hand side has type
real
make: *** [/var/folders/qs/k7z4lcnx7rdg5hbhp2jr7rs00000gn/T/Rtmpr1OeQW/model-f57a72635ad9.hpp] Error 1
Error: An error occured during compilation! See the message above for more information.
And, correct me if I'm wrong, but, we need log_lik = TRUE. Otherwise, we get issues like
# from model fit where log_lik = FALSE
WAIC(no_phylo)
Error in rep(0, n_obs) : invalid 'times' argument
Metadata
Metadata
Assignees
Labels
No labels