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
Maximum CSV size in Stata SE and what to do about 'fat' dataI have a dataset with 4600 observations of 3500 variables. The .xlsx file is 90 MB and the .csv vers…
Does -xtmixed- use the full data set ?Dear all, In texts books, we are told that mixed effects models use the "full" data set. For exampl…
-estimates use-, error message when reading stored estimates across Stata versionsI have one model estimates file made using Stata v15.1. My co-worker is trying to do -estimates use-…
graphHi all, I have data about companies' performance over time and a variable that identifies uncertain…
WeightingGreetings Stata community, Am using Stata version 13. I would like to perform a chi-square test for…
Subscribe to:
Post Comments (Atom)
0 Response to Do file issues
Post a Comment