Hemken / Statamarkdown

Functions to write Stata documentation with knitr
Other
59 stars 11 forks source link

Output from `regress` command cuts out lines from coefficient table #18

Closed DaniMori closed 3 years ago

DaniMori commented 3 years ago

Take the following example (unfortunately I can't share the data so it's not a reprex):

regress positiveaffect age_group i.male_s0 i.study_agrup i.healtheat i.moderhigh_phy_activ_s0 i.no_daily_smoker_s0 i.no_heavy_alcohol_s0 i.sleep_quality

Here is the output from Stata:

      Source |       SS           df       MS      Number of obs   =     4,582
-------------+----------------------------------   F(10, 4571)     =     20.85
       Model |  245.101294        10  24.5101294   Prob > F        =    0.0000
    Residual |  5374.37876     4,571  1.17575558   R-squared       =    0.0436
-------------+----------------------------------   Adj R-squared   =    0.0415
       Total |  5619.48005     4,581  1.22669287   Root MSE        =    1.0843

------------------------------------------------------------------------------------------
          positiveaffect |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------------------+----------------------------------------------------------------
               age_group |   .1035648   .0245478     4.22   0.000     .0554393    .1516903
               1.male_s0 |   .1587417   .0330365     4.81   0.000     .0939743    .2235091
                         |
             study_agrup |
                  first  |  -.0424049   .0443068    -0.96   0.339    -.1292676    .0444578
         secundary/bach  |  -.0557807   .0462165    -1.21   0.228    -.1463874     .034826
             university  |   .0165693   .0569458     0.29   0.771    -.0950719    .1282106
                         |
             1.healtheat |   .1187273   .0357351     3.32   0.001     .0486692    .1887854
1.moderhigh_phy_activ_s0 |   .1419471   .0354298     4.01   0.000     .0724877    .2114066
    1.no_daily_smoker_s0 |   .1421319   .0404974     3.51   0.000     .0627375    .2215264
   1.no_heavy_alcohol_s0 |  -.1845019   .0934702    -1.97   0.048    -.3677487   -.0012552
         1.sleep_quality |   .3791113   .0391579     9.68   0.000     .3023428    .4558798
                   _cons |   4.249539   .1167263    36.41   0.000     4.020699    4.478379
------------------------------------------------------------------------------------------

While the output given by the Rmarkdown document is

      Source |       SS           df       MS      Number of obs   =     4,582
-------------+----------------------------------   F(10, 4571)     =     20.85
       Model |  245.101294        10  24.5101294   Prob > F        =    0.0000
    Residual |  5374.37876     4,571  1.17575558   R-squared       =    0.0436
-------------+----------------------------------   Adj R-squared   =    0.0415
       Total |  5619.48005     4,581  1.22669287   Root MSE        =    1.0843

------------------------------------------------------------------------------
positiveaf~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
   age_group |   .1035648   .0245478     4.22   0.000     .0554393    .1516903
             |
 study_agrup |
      first  |  -.0424049   .0443068    -0.96   0.339    -.1292676    .0444578
secundary~h  |  -.0557807   .0462165    -1.21   0.228    -.1463874     .034826
 university  |   .0165693   .0569458     0.29   0.771    -.0950719    .1282106
             |
1.moderhig~0 |   .1419471   .0354298     4.01   0.000     .0724877    .2114066
1.no_daily~0 |   .1421319   .0404974     3.51   0.000     .0627375    .2215264
1.no_heavy~0 |  -.1845019   .0934702    -1.97   0.048    -.3677487   -.0012552
1.sleep_qu~y |   .3791113   .0391579     9.68   0.000     .3023428    .4558798
       _cons |   4.249539   .1167263    36.41   0.000     4.020699    4.478379
------------------------------------------------------------------------------

It can be seen that the lines for some of the coefficients in the table are missing, e.g. the coefficient for 1.male_s0. This doesn't seem to be a problem with the model estimation, as the rest of the coefficients, degrees of freedom, and statistics are coincident in values. Therefore, it seems like some lines are being stripped off the output.

Interestingly, using the chunk option comment = '##' gives the correct output.

Hemken commented 3 years ago

I believe this is fixed now, in v0.6.1.

Also, if you'd like wider output, include the Stata command

set linesize 90 // or some other appropriate width

in the codeblock you would like to see wider, or in a codeblock marked collectcode=TRUE

DaniMori commented 3 years ago

Solved indeed! Thank you so much, and sorry for opening the issue before updating first to the last version... my mistake.

Hemken commented 3 years ago

Not your mistake! There was a bug – you prompted me to fix it – I then bumped the minor version. Sorry that wasn’t clear. Thanks for reporting the bug.

Doug Hemken

From: DaniMori @.> Sent: Monday, May 10, 2021 4:17 AM To: Hemken/Statamarkdown @.> Cc: Doug Hemken @.>; State change @.> Subject: Re: [Hemken/Statamarkdown] Output from regress command cuts out lines from coefficient table (#18)

Solved indeed! Thank you so much, and sorry for opening the issue before updating first to the last version... my mistake.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/issues/18#issuecomment-836448254, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACYBME63TUTEAZ2NPFYP2A3TM6P7RANCNFSM44HHKH2A.