I know print(“lp=”, target()) can print out log-posterior for debug.
How can I print gradient?
Thank you.
Ziyi Chen
You can’t. You can specify the diagnostic_file
argument and the gradient vector (in the unconstrained space) will get written to that file for each iteration (not each leapfrog step).
I used diagnostic_file=“xxx.csv” in “sampling” function, and then
DiagFile.GMM=read.csv(“GMM_stan_unconstrained_noZ.csv”)
DiagFile.GMM is a 323*1 data.frame with the first few rows being strings, and the remaining rows being numbers, which is not readable.
Thank you.
I think you need to specify comment.char = "#"
when you call read.csv
Thanks.