Wednesday February 22 20:44:59 2017

Page 1

®

Statistics/Data Analysis

name: log: > .smcl log type: opened on:

U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli\stan_022217_v4 smcl 22 Feb 2017, 20:43:30

1 . /* Version 4: specify the model inline, so it is written to the > text file of your choosing but everything is controlled from the do-file > (the Charles Opondo method) */ 2 . 3 . // make the data 4 . set more off 5 . clear all 6 . set obs 10 number of observations (_N) was 0, now 10 7 . gen y=0 8 . replace y=1 in 2 (1 real change made) 9 . replace y=1 in 10 (1 real change made) 10. count 10 11. global N=r(N) 12. 13. global cmdstandir "U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli" 14. // write the model from Stata into a plain text file 15. tempname writemodel 16. file open `writemodel' using "mystanmodel.stan", write replace 17. #delimit ; delimiter now ; 18. foreach line in > "data { " > " int N; " > " int y[N];" > "} " > "parameters {" > " real theta;" > "} " > "model {" > " theta ~ beta(1,1);" > " for (n in 1:N) " > " y[n] ~ bernoulli(theta);" > "}" > {; 2. #delimit cr delimiter now cr 19. file write `writemodel' "`line'" _n 3. }

Wednesday February 22 20:44:59 2017

Page 2

20. file close `writemodel' 21. 22. // call Stan 23. stan y, modelfile("mystanmodel.stan") cmd("$cmdstandir") globals("N") load mode StataStan version: 1.2.2 CmdStan version: U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli ############################### ### Output from compiling ### ############################### U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli>make "mystanmodel.exe" 'make' is not recognized as an internal or external command, operable program or batch file. U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli>echo Finished! Finished! ############################## ### Output from sampling ### ############################## U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli>U:\NON_PROJECT_DATA\Jing\cm > dstan-2.14.0\examples\bernoulli\mystanmodel.exe method=sample algorithm=hmc steps > ize=1 stepsize_jitter=0 output file="U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\exampl > es\bernoulli\output.csv" data file="U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples > \bernoulli\statastan_data.R" 'U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli\mystanmodel.exe' is not re > cognized as an internal or external command, operable program or batch file. U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli>echo Finished! Finished! U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli>bin\stansummary.exe "U:\NON > _PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli\output*.csv" The system cannot find the path specified. U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli>echo Finished! Finished! file U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli\output.csv not found r(601); end of do-file r(601); 24. do "C:\Users\jdong\AppData\Local\Temp\25\STD00000000.tmp" 25. log close name: log: > .smcl log type: closed on:

U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli\stan_022217_v4 smcl 22 Feb 2017, 20:44:59

U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0 ... -

Feb 22, 2017 - 13. global cmdstandir "U:\NON_PROJECT_DATA\Jing\cmdstan-2.14.0\examples\bernoulli". 14. // write the model from Stata into a plain text file.

111KB Sizes 0 Downloads 149 Views

Recommend Documents

No documents