Dear all,
I am trying to produce a set of 16 graphs in a loop, giving them as title alphabet letters in sequential order.
My task is as follows:
I have a dataset with 2 independent variables (X1 and X2) and 2 dependent variables (Y1 and Y2). I am running regressions in a loop for each independent variable over each dependent variable using the permute command with 1000 repetitions.
I then save the distribution of the coefficients obtained through the permutation in a dataset, as I want to use the distribution to make kdensity graphs. What I obtain in the end are 4 datasets, each one containing one distribution of the coefficient, and 4 graphs, one for each distribution.
However I am not finding a way to title these graphs with alphabet letters in sequential order. That is, I want the first graph to be titled "A", the second graph to be titled "B", the third "C" and the fourth "D".
Here is the code that I am trying to complete.
foreach exp in X1 X2 {
foreach dep in Y1 Y2 {
permute `exp' _b[ `exp' ], saving( `exp'_`dep' ) reps(1000): reg `dep' `exp'
preserve
use `exp'_`dep' , clear
twoway kdensity _pm_1, graphregion(color(white)) ytitle("Density") xtitle("") title()
graph save "`exp'_`dep'.gph", replace
restore
}
}
Hope I have been clear in describing my issue and that somebody here have hints for a solution.
Thanks, Davide
I am trying to produce a set of 16 graphs in a loop, giving them as title alphabet letters in sequential order.
My task is as follows:
I have a dataset with 2 independent variables (X1 and X2) and 2 dependent variables (Y1 and Y2). I am running regressions in a loop for each independent variable over each dependent variable using the permute command with 1000 repetitions.
I then save the distribution of the coefficients obtained through the permutation in a dataset, as I want to use the distribution to make kdensity graphs. What I obtain in the end are 4 datasets, each one containing one distribution of the coefficient, and 4 graphs, one for each distribution.
However I am not finding a way to title these graphs with alphabet letters in sequential order. That is, I want the first graph to be titled "A", the second graph to be titled "B", the third "C" and the fourth "D".
Here is the code that I am trying to complete.
foreach exp in X1 X2 {
foreach dep in Y1 Y2 {
permute `exp' _b[ `exp' ], saving( `exp'_`dep' ) reps(1000): reg `dep' `exp'
preserve
use `exp'_`dep' , clear
twoway kdensity _pm_1, graphregion(color(white)) ytitle("Density") xtitle("") title()
graph save "`exp'_`dep'.gph", replace
restore
}
}
Hope I have been clear in describing my issue and that somebody here have hints for a solution.
Thanks, Davide
Comment