Dear all, It's my first time posting a question (I have been applying lots of tips you guys have solved). In advance, I would like to say I am a huge fan of Mr. Nick Cox (I have learned a lot due to its comments).
I am trying to use the same commands from the paper published by Dr. Anna Makles entitled "Stata tip 110: How to get the optimal k-means cluster solution, Stata Journal (2012) 12, Number 2, pp. 347-351".
The command used is executed until the last line, however, before the graphs are estimated, the following fault appears:
"unexpected end of file"
r (612)
Could you help me to solve this question?
The command applied was the follows:
. use http://www.stata-press.com/data/r12/physed, clear
. local list1 " flex speed strength "
. foreach v of varlist `list1´ {
2. egen z_`v' = std(`v')
3. local list2 "flex speed strength"
4. forvalues k = 1(1)20 {
5. cluster kmeans `list2´, k(`k') start(random(123)) name(cs`k')
6. }
7. * WSS matrix
. matrix WSS = J(20,5,.)
8. matrix colnames WSS = k WSS log(WSS) eta-squared PRE
9. * WSS for each clustering
. forvalues k = 1(1)20 {
10. scalar ws`k' = 0
11. foreach v of varlist `list2´ {
12. quietly anova `v' cs`k'
13. scalar ws`k' = ws`k' + e(rss)
14. }
15. matrix WSS[`k', 1] = `k'
16. matrix WSS[`k', 2] = ws`k'
17. matrix WSS[`k', 3] = log(ws`k')
18. matrix WSS[`k', 4] = 1 - ws`k'/WSS[1,2]
19. matrix WSS[`k', 5] = (WSS[`k'-1,2] - ws`k')/WSS[`k'-1,2]
20. }
21. matrix list WSS
22. local squared = char(178)
23. _matplot WSS, columns(2 1) connect(l) xlabel(#10) name(plot1, replace) nodraw noname
24. _matplot WSS, columns(3 1) connect(l) xlabel(#10) name(plot2, replace) nodraw noname
25. _matplot WSS, columns(4 1) connect(l) xlabel(#10) name(plot3, replace) nodraw noname ytitle({&eta}`squared')
26. _matplot WSS, columns(5 1) connect(l) xlabel(#10) name(plot4, replace) nodraw noname
27. graph combine plot1 plot2 plot3 plot4, name(plot1to4, replace)
28.
unexpected end of file
r(612);
end of do-file
I am using STATA 13.0
Related Posts with Do file issues
Coefplot - option rename()Dear statalist members, in fact, I have got three questions concerning coefplot (Ben Jann, 2014) bu…
Calculating the lengthDear All, I was asked this question. First, the data is Code: * Example generated by -dataex-. To …
Fixed effects regression drops a variable of interestRight now I have a standard OLS model with one year of data, and I'm interested in the coefficient f…
Lasso for binary outcomeI am using lassopack, do I need to specify anything if my outcome is binary? Thanks! …
mi estimate not using all observationsHi all, I am trying out multiple imputation in STATA and I noticed something wondering if people can…
Subscribe to:
Post Comments (Atom)
0 Response to Do file issues
Post a Comment