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
error opening .dta file created in sashello, I converted a sas data file into a stata .dta file ( or atleast i thought i did) and it will …
Problem with Difference in difference specificationHi all, I am sorry if this topic has been covered before. However, I did my research but failed. I…
Cluster analysis with longitudinal dataAre there commands in Stata that are similar to the kml3d package in R (see e.g. Genolini et al 2015…
Generate a week from a data and "xtset" the dataDear Stata Users, I have the sample of data attached below. I need to create a “week” date that goes…
Regress y on each variable each timeHi, I want to run regressions in the following way: reg y x1 i.year i.ind reg y x2 i.year i.ind re…
Subscribe to:
Post Comments (Atom)
0 Response to Do file issues
Post a Comment