Skip to content

Update basic_distributions syntax #190

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

Merged
merged 5 commits into from
Jan 28, 2021
Merged

Update basic_distributions syntax #190

merged 5 commits into from
Jan 28, 2021

Conversation

andrjohns
Copy link
Collaborator

I'm going to start (slowly & sporadically) updating the syntax in these example models to modern Stan language, and remove deprecated syntax.

This PR updates the models in the basic_distributions folder. I've checked that all models parse under Stanc3 (with the exception of a known issue

@rok-cesnovar
Copy link
Member

Nice! Thanks!

Do you check using rstan 2.26? cmdstan adds a _model suffix and rstan should as well to avoid the problem.

@andrjohns
Copy link
Collaborator Author

Ah good call, yep no errors under RStan 2.26

Copy link
Member

@rok-cesnovar rok-cesnovar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto-formatter from stanc3 suggests a bit different formatting in some places, though I guess its a matter of personal taste a bit so feel free to ignore.

Thanks for doing this!

Comment on lines +2 to +3
matrix[2,2] Sigma = [[1, 0.1],
[0.1, 1]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
matrix[2,2] Sigma = [[1, 0.1],
[0.1, 1]];
matrix[2,2] Sigma = [[1, 0.1], [0.1, 1]];

Comment on lines +2 to +4
cov_matrix[3] S = [[2, 0, 0],
[0, 1, 0],
[0, 0, 0.5]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cov_matrix[3] S = [[2, 0, 0],
[0, 1, 0],
[0, 0, 0.5]];
cov_matrix[3] S = [[2, 0, 0], [0, 1, 0], [0, 0, 0.5]];

Comment on lines +2 to +3
cov_matrix[2] S = [[2, 0],
[0, 0.5]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cov_matrix[2] S = [[2, 0],
[0, 0.5]];
cov_matrix[2] S = [[2, 0], [0, 0.5]];


for (m in 1:4)
for (n in 1:(m-1))
S[m,n] <- S[n,m];
S[m,n] = S[n,m];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the above was filling the lower triangular parts we could use symmetrize_from_lower_tri but no sense complicating I guess.

Comment on lines +13 to +14
cov_matrix[2] S = [[2, 0],
[0, 0.5]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cov_matrix[2] S = [[2, 0],
[0, 0.5]];
cov_matrix[2] S = [[2, 0], [0, 0.5]];

Comment on lines 24 to 25
matrix[2,2] W = [[sd1^2, cov],
[cov, sd2^2]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
matrix[2,2] W = [[sd1^2, cov],
[cov, sd2^2]];
matrix[2,2] W = [[sd1 ^ 2, cov], [cov, sd2 ^ 2]];

@andrjohns
Copy link
Collaborator Author

Just for the example models I think I'd prefer to leave the matrix declarations in the matrix layout (rather than a one-liner), so that the [[],[]] declaration syntax is a bit more immediately intuitive for the unfamiliar. But will update the rest

@rok-cesnovar
Copy link
Member

Yeah, its why I said these are optional. Let me know when to take another look.

@andrjohns
Copy link
Collaborator Author

Works for me! Ready for another look

Copy link
Member

@rok-cesnovar rok-cesnovar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rok-cesnovar rok-cesnovar merged commit e2de966 into stan-dev:master Jan 28, 2021
@andrjohns andrjohns deleted the feature/basic_dist_update branch February 7, 2021 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants