Hi. I am running a piecewise regression on a dataset with over 4,000 observations. The resultant twoway graph (below) is not helpful due to the number of observations in it. While trying to find a better way to depict my results, I came across the binscatter command. Is there anyway I can take a similar approach with my code (through binning) below, without changing the underlying method completely as I would if I were to use binscatter?
Or, is there any other manner in which to better depict these results. Any help will be very much appreciated?
Or, is there any other manner in which to better depict these results. Any help will be very much appreciated?
Code:
**Current code: xtset con_id week_num xtreg week_docalltele knot1 knot2 knot3 week1 week2 i.age_cat i.doc_desig, vce(cluster con_id) predict linear_spline /* Generate the predicted scores */ *** Plot graph sort week_num tw (scatter week_docalltele week_num , /// mc(gs10) msize(vsmall) title("Hyderabad") /// xline(78 114, lpattern(dash) lcol("cranberry")) /// xlab(40 "Pre-intervention" 95 "Mandate" 126 "Platform", noticks labsize (small)) /// ylab(, nogrid labsize(vsmall)) /// ytitle("Number of consultations") /// xtitle("") scheme(s1color) /// legend(region(lpattern(blank)) order(1 "observed" 2 "predicted values")) legend(size(vsmall))) /// (lfit linear_spline week_num if period==0, col("navy")) /// (lfit linear_spline week_num if period==1, col("navy")) /// (lfit linear_spline week_num if period==2, col("navy")) *Data sample input long con_id float(week_num week_docalltele) byte(knot1 knot2 knot3) float(week1 week2 age_cat) byte doc_desig float period 1 1 7 1 0 0 0 0 3 2 0 4 1 17 1 0 0 0 0 2 5 0 5 1 8 1 0 0 0 0 3 4 0 12 1 10 1 0 0 0 0 2 1 0 13 1 25 1 0 0 0 0 3 3 0 1 2 15 2 0 0 0 0 3 2 0 4 2 1 2 0 0 0 0 2 5 0 5 2 4 2 0 0 0 0 3 4 0 11 2 11 2 0 0 0 0 2 2 0 12 2 8 2 0 0 0 0 2 1 0 13 2 12 2 0 0 0 0 3 3 0 15 2 6 2 0 0 0 0 2 2 0 1 3 14 3 0 0 0 0 3 2 0 4 3 20 3 0 0 0 0 2 5 0 5 3 8 3 0 0 0 0 3 4 0 6 3 10 3 0 0 0 0 2 5 0 10 3 5 3 0 0 0 0 3 1 0 11 3 11 3 0 0 0 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11 10 0 0 0 0 2 5 0 5 10 12 10 0 0 0 0 3 4 0 6 10 28 10 0 0 0 0 2 5 0 11 10 3 10 0 0 0 0 2 2 0 12 10 15 10 0 0 0 0 2 1 0 13 10 14 10 0 0 0 0 3 3 0 1 11 15 11 0 0 0 0 3 2 0 5 11 10 11 0 0 0 0 3 4 0 10 11 11 11 0 0 0 0 3 1 0 12 11 13 11 0 0 0 0 2 1 0 13 11 21 11 0 0 0 0 3 3 0 15 11 9 11 0 0 0 0 2 2 0 5 12 11 12 0 0 0 0 3 4 0 6 12 7 12 0 0 0 0 2 5 0 10 12 8 12 0 0 0 0 3 1 0 11 12 15 12 0 0 0 0 2 2 0 12 12 16 12 0 0 0 0 2 1 0 13 12 17 12 0 0 0 0 3 3 0 15 12 11 12 0 0 0 0 2 2 0 4 13 7 13 0 0 0 0 2 5 0 10 13 7 13 0 0 0 0 3 1 0 11 13 17 13 0 0 0 0 2 2 0 12 13 35 13 0 0 0 0 2 1 0 13 13 25 13 0 0 0 0 3 3 0 15 13 14 13 0 0 0 0 2 2 0 1 14 14 14 0 0 0 0 3 2 0 4 14 12 14 0 0 0 0 2 5 0 5 14 16 14 0 0 0 0 3 4 0 6 14 20 14 0 0 0 0 2 5 0 8 14 9 14 0 0 0 0 2 2 0 11 14 15 14 0 0 0 0 2 2 0 12 14 14 14 0 0 0 0 2 1 0 13 14 31 14 0 0 0 0 3 3 0 15 14 10 14 0 0 0 0 2 2 0 1 15 10 15 0 0 0 0 3 2 0 3 15 6 15 0 0 0 0 2 1 0
Comment