Hi all,
I am making a twoway scatterplot graph on Stata (see code below) on which I include the fitted curve from a regression.
My dataset is a panel (N=198), T= 2. I would like to connect the points by group in the graph. Basically, I would like to have a line that connects village V1 in time T1 to village V1 in time T2, village V2 in time T1 to village V2 in time T2 etc
Here is my code, if anyone have suggestions so I can keep draw a line between the two periods for each village and include the fitted curve from the model in the graph.
Thanks!
I am making a twoway scatterplot graph on Stata (see code below) on which I include the fitted curve from a regression.
My dataset is a panel (N=198), T= 2. I would like to connect the points by group in the graph. Basically, I would like to have a line that connects village V1 in time T1 to village V1 in time T2, village V2 in time T1 to village V2 in time T2 etc
Here is my code, if anyone have suggestions so I can keep draw a line between the two periods for each village and include the fitted curve from the model in the graph.
Code:
reg Y X1 X2 c.X1#c.X2 i.ID i.year, r predict Live_predict if e(sample)==1, xb gen X1_effect = _b[X1]*X1 replace Live_predict = Live_predict - lndist_effect egen Live_mean = mean(Live_predict) gen model_Live = Live_mean + lndist_effect drop X1_effect * Scatter plot twoway (scatter Y X1, mlabel()) (connected model_Live X1, connect(ascending) sort(X1) msymbol(i)), ytitle("Y title") xtitle("X title") graphregion(color(white)) leg(off) graph export graph2.png, replace
Comment