-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Error in symbols[[left_symbol]] : no such index at level 2 #2
Comments
Easier to find than I thought: Lines 1227 to 1228 in 1a040c3
|
I think it actually happens here: Lines 1036 to 1044 in 1a040c3
Conditional on log_lik=TRUE, and inside the conditional |
I think I'm right because if I change the code to: if ( i==1 && log_lik==TRUE ) {
# add by default
built <- compose_distibution( left_symbol , flist[[i]] , as_log_lik=TRUE )
m_gq2 <- concat( m_gq2 , built )
message(left_symbol)
N <- symbols[[left_symbol]]$dims[[2]]
message("Worked")
m_gq1 <- concat( m_gq1 , indent , "vector[" , N , "] log_lik;\n" )
# save N to attr so nobs/compare can get it later
nobs_save <- N
} And run the test model, I get:
So N <- symbols[[left_symbol]]$dims[[2]] |
So something interesting happens when I test with two outcome variables: m14.6 <- ulam(
alist(
c(W,E) ~ multi_normal( c(muW,muE) , Rho , Sigma ),
muW <- aW + bEW*E,
muE <- aE + bQE*Q,
c(aW,aE) ~ normal( 0 , 0.2 ),
c(bEW,bQE) ~ normal( 0 , 0.5 ),
Rho ~ lkj_corr( 2 ),
Sigma ~ exponential( 1 )
), data=dat_sim , chains=4 , cores=4, log_lik=T, sample = F)
cat(m14.6$model) This does not give an error, but it does show an interesting bug in the generated Stan code:
So with two outcome variables the if ( i==1 && log_lik==TRUE ) {
# add by default
built <- compose_distibution( left_symbol , flist[[i]] , as_log_lik=TRUE )
m_gq2 <- concat( m_gq2 , built )
message(left_symbol)
N <- symbols[[left_symbol]]$dims[[2]]
message("Worked")
m_gq1 <- concat( m_gq1 , indent , "vector[" , N , "] log_lik;\n" )
# save N to attr so nobs/compare can get it later
nobs_save <- N
} We get this bug because N <- symbols[[left_symbol[1]]]$dims[[2]] |
Tested with a single outcome variable as well and it works. |
Very descriptive error....
Occurs when a multi_normal log_likelihood is calculated with more than 2 variables, e.g.:
Gives:
The text was updated successfully, but these errors were encountered: