I simulated a model 31 different times, and I want to compare how the estimator performs across various levels of Gaussian noise. - See my update at the bottom.
I originally tried a bar graph, and I've also experimented with histograms, but to me, it seems like a table would be better to display this information. So, I did
Where the row names are the levels of noise I introduced. However, the rows appear to be not aligned with the format I've specified. For example, take the very last number. When I do
I get
As expected. But, this isn't what the table shows, it shows the full number as though I've not reformatted it. Is this a display problem, or a precision one, and how might I do this such that the row names are rounded to a single decimal place, and the other three statistics are rounded to say, 3 decimal places?
UPDATE:
So, I've used Mata to reformat the. Now all I need to do is reformat the row names themselves
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(variance premse postmse ratio)
.1 .31061575 .3611799 1.1627868
.2 .3121041 .36341465 1.1644021
.3 .29441914 .3411821 1.1588312
.4 .29515648 .3421026 1.1590548
.5 .29718387 .3448728 1.1604693
.6 .2986346 .3474558 1.1634814
.7 .30110005 .3512891 1.1666857
.8 .303456 .3542318 1.1673254
.9 .3064812 .3580584 1.1682882
1 .3100766 .363158 1.1711879
1.1 .3154313 .3720172 1.1793923
1.2 .3182329 .3742517 1.176031
1.3 .32241 .3792378 1.1762595
1.4 .3291871 .3897445 1.1839602
1.5 .3338935 .3954707 1.1844217
1.6 .3461653 .412933 1.1928782
1.7 .3479584 .4143937 1.1909288
1.8 .3488469 .4131078 1.1842093
1.9 .3546743 .4203638 1.1852108
2 .3602999 .427142 1.1855181
2.1 .3661608 .4342337 1.1859097
2.2 .3673443 .4312872 1.1740681
2.3 .377447 .4473171 1.1851122
2.4 .3957823 .4730073 1.19512
2.5 .3819886 .4414285 1.1556065
2.6 .4139824 .4952473 1.1963006
2.7 .4175476 .4990176 1.1951153
2.8 .4163164 .4958761 1.1911038
2.9 .4248772 .5064601 1.1920152
3 .4310946 .5135548 1.1912811
6.2 .6136207 .7067071 1.1517003
end
graph hbar (asis) ratio, over(variance) ///
bar(1, fcolor(cyan) lcolor(cyan)) ///
blabel(bar, format(%6.3f)) ///
ytitle(Post/Pre RMSE Ratio) //
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(variance premse postmse ratio)
.1 .31061575 .3611799 1.1627868
.2 .3121041 .36341465 1.1644021
.3 .29441914 .3411821 1.1588312
.4 .29515648 .3421026 1.1590548
.5 .29718387 .3448728 1.1604693
.6 .2986346 .3474558 1.1634814
.7 .30110005 .3512891 1.1666857
.8 .303456 .3542318 1.1673254
.9 .3064812 .3580584 1.1682882
1 .3100766 .363158 1.1711879
1.1 .3154313 .3720172 1.1793923
1.2 .3182329 .3742517 1.176031
1.3 .32241 .3792378 1.1762595
1.4 .3291871 .3897445 1.1839602
1.5 .3338935 .3954707 1.1844217
1.6 .3461653 .412933 1.1928782
1.7 .3479584 .4143937 1.1909288
1.8 .3488469 .4131078 1.1842093
1.9 .3546743 .4203638 1.1852108
2 .3602999 .427142 1.1855181
2.1 .3661608 .4342337 1.1859097
2.2 .3673443 .4312872 1.1740681
2.3 .377447 .4473171 1.1851122
2.4 .3957823 .4730073 1.19512
2.5 .3819886 .4414285 1.1556065
2.6 .4139824 .4952473 1.1963006
2.7 .4175476 .4990176 1.1951153
2.8 .4163164 .4958761 1.1911038
2.9 .4248772 .5064601 1.1920152
3 .4310946 .5135548 1.1912811
6.2 .6136207 .7067071 1.1517003
end
recast double variance
clear matrix
mkmat pre-ratio if !mi(ratio), mat(B)
format variance %2.1g
levelsof variance, loc(vars)
cls
mat rownames B = `r(levels)'
mat l B
mata : st_matrix("r(B)", st_matrix("B"))
mata : st_matrixrowstripe("r(B)", st_matrixrowstripe("B"))
clear collect
collect get r(B)
collect layout (rowname)(colname)
Code:
di %2.1g 6.199999809265137
Code:
Res: 6.2
UPDATE:
So, I've used Mata to reformat the. Now all I need to do is reformat the row names themselves
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(variance premse postmse ratio)
.1 .31061575 .3611799 1.1627868
.2 .3121041 .36341465 1.1644021
.3 .29441914 .3411821 1.1588312
.4 .29515648 .3421026 1.1590548
.5 .29718387 .3448728 1.1604693
.6 .2986346 .3474558 1.1634814
.7 .30110005 .3512891 1.1666857
.8 .303456 .3542318 1.1673254
.9 .3064812 .3580584 1.1682882
1 .3100766 .363158 1.1711879
1.1 .3154313 .3720172 1.1793923
1.2 .3182329 .3742517 1.176031
1.3 .32241 .3792378 1.1762595
1.4 .3291871 .3897445 1.1839602
1.5 .3338935 .3954707 1.1844217
1.6 .3461653 .412933 1.1928782
1.7 .3479584 .4143937 1.1909288
1.8 .3488469 .4131078 1.1842093
1.9 .3546743 .4203638 1.1852108
2 .3602999 .427142 1.1855181
2.1 .3661608 .4342337 1.1859097
2.2 .3673443 .4312872 1.1740681
2.3 .377447 .4473171 1.1851122
2.4 .3957823 .4730073 1.19512
2.5 .3819886 .4414285 1.1556065
2.6 .4139824 .4952473 1.1963006
2.7 .4175476 .4990176 1.1951153
2.8 .4163164 .4958761 1.1911038
2.9 .4248772 .5064601 1.1920152
3 .4310946 .5135548 1.1912811
6.2 .6136207 .7067071 1.1517003
end
clear matrix
mkmat pre-ratio if !mi(ratio), mat(B)
cls
mata
B = st_matrix("B")
B = strofreal(B, "%3.2f")
B = round(st_matrix("B"),.001)
st_matrix("B", B)
end
levelsof variance, loc(vars)
mat rownames B = `r(levels)'
mat l B

Comment