Dear statalisters,
I am trying to obtain the percentages from a tabm table that uses weights and I get some precision error. You can see that for variable r12 and Categ5, the proportion is 53.85%. However, if I try to calculate this same proportion using the results stored by matcell(), the resulting proportion is 53.83. Is there any way to make matcells() store more decimals?
Below you have my code and results:
. tabm r1-r12 [aw=wgt], row nofreq matcell(freqs)
| values
variable | Categ1 Categ2 Categ3 Categ4 Categ5 | Total
------------------+-------------------------------------------------------+----------
r1 | 0.00 0.00 0.71 45.33 53.96 | 100.00
r2 | 0.00 0.00 1.93 44.11 53.96 | 100.00
r3 | 0.00 0.00 4.21 41.83 53.96 | 100.00
r4 | 4.83 1.48 0.69 39.15 53.85 | 100.00
.. | .... .... .... ..... ..... | ......
r12 | 0.00 0.00 0.00 46.15 53.85 | 100.00
------------------+-------------------------------------------------------+----------
Total | 1.76 0.80 1.47 42.09 53.88 | 100.00
. mat li freqs
freqs[12,5]
c1 c2 c3 c4 c5
r1 0 0 18.687787 1194.2136 1421.6247
r2 0 0 50.843143 1162.0582 1421.6247
r3 0 0 110.89391 1102.0074 1421.6247
r4 127.37912 39.013458 18.216818 1033.5905 1421.6247
.................................................. .......
r12 58.60397 45.169448 74.980403 1039.4461 1421.6247
mat percent = 100*freqs/2641
. mat li percent
percent[12,5]
c1 c2 c3 c4 c5
r1 0 0 .7076027 45.218234 53.829032
r2 0 0 1.9251474 44.000689 53.829032
r3 0 0 4.1989364 41.7269 53.829032
r4 4.8231396 1.4772229 .68976971 39.136331 53.829032
.................................................. .......
r12 2.2190068 1.7103161 2.8390914 39.358049 53.829032
Thank you in advance,
Aina
Related Posts with Getting more decimals from matcell
Rounding the coefficientsDear Researchers, I am sorry, my question may sound silly, but I searched for the answer and the an…
Referencing local variable in nested foreach var of varlistHi, I would like to do something which I believe is fairly simple, but I can't get the syntax corre…
Listing unique observations with a rolling windowDear all, Suppose I have the following dataset: Code: clear input str8 memberid year "B000" 1980…
Hazard as a Propensity Score for Matching - Propensity Score Matching with Time-Dependent CovariatesHello, I am trying to create a matched sample using hazard ratios by observation by id. I am conduct…
Maximum Likelihood Exploratory Factor Analysis and Confirmatory Factor AnalysisDear Statalist users, I am using Stata 15 and comparing the results between Maximum likelihood expl…
Subscribe to:
Post Comments (Atom)
0 Response to Getting more decimals from matcell
Post a Comment