Forum Replies Created

Viewing 15 posts - 31 through 45 (of 69 total)
  • Author
    Posts
  • Attaullah Shah
    Keymaster
    Post count: 69

    To fill missing values with the mean value in a panel data, you can use the following command structure:

    bys id: fillmissing varname, with(mean)

    Where id is your panel id, such permno, company name, or country. And the varname is the name of the variable which contains missing values.

    Attaullah Shah
    Keymaster
    Post count: 69

    Hello Amina,

    pvar is a community-contributed program, which asdoc is not aware of. However, you can use the matrix left behind ny the pvargrager command and write it with asdoc, as mentioned in Section 12 of the asdoc’s help file. Here is one example. Please do remember to visit the asdocx program, which is more powerful and can export to Excel, LaTeX, and docx formats.

    webuse nlswork2
    xtset idcode year
    generate wage = exp(ln_wage)
    pvar wage hours
    mat t = r(pgstats)
    asdoc wmat, mat(t) replace
    
    
    -----------------------------------------------
                 |      chi2         df  Prob > ~2 
    -------------+---------------------------------
    wage         |                                 
           hours |     9.199      1.000      0.002 
             ALL |     9.199      1.000      0.002 
    -------------+---------------------------------
    hours        |                                 
            wage |    17.162      1.000      0.000 
             ALL |    17.162      1.000      0.000 
    -----------------------------------------------
    
    Attaullah Shah
    Keymaster
    Post count: 69

    Parek
    This issue was fixed in the recent updates
    The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.

    net install asdoc, from(http://fintechprofessor.com) replace

    Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.

    Please do remember to cite asdoc. To cite:
    In-text citation
    Tables were created using asdoc, a Stata program written by Shah (2018).

    Bibliography
    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.

    Attaullah Shah
    Keymaster
    Post count: 69

    Prerak
    You can use option dec() to control the number of decimal points. See these examples

    Default: three decimal points

    sysuse auto
    asdoc table foreign rep78, c(mean price)

    Two decimal points

    sysuse auto
    asdoc table foreign rep78, c(mean price) dec(2)

    One decimal point

    sysuse auto
    asdoc table foreign rep78, c(mean price) dec(1)
    Attaullah Shah
    Keymaster
    Post count: 69

    Right now, asdoc can tabulate and export string variables. See this example.

    sysuse nlsw88, clear
    decode industry, gen(ind2)
    asdoc tab ind2, replace
    
    
                   industry |      Freq.     Percent        Cum.
    ------------------------+-----------------------------------
      Professional Services |        824       36.92       36.92
              Manufacturing |        367       16.44       53.36
     Wholesale/Retail Trade |        333       14.92       68.28
    Finance/Ins/Real Estate |        192        8.60       76.88
      Public Administration |        176        7.89       84.77
          Personal Services |         97        4.35       89.11
     Transport/Comm/Utility |         90        4.03       93.15
        Business/Repair Svc |         86        3.85       97.00
               Construction |         29        1.30       98.30
      Ag/Forestry/Fisheries |         17        0.76       99.06
      Entertainment/Rec Svc |         17        0.76       99.82
                     Mining |          4        0.18      100.00
    ------------------------+-----------------------------------
                      Total |      2,232      100.00

    However, the sort option is not yet available. I shall add it to asdocx, which is almost ready. See details on asdocx here

    Attaullah Shah
    Keymaster
    Post count: 69

    Here is my quick proof of asreg accuracy.
    You can check your calculation

    . sysuse auto, clear
    (1978 Automobile Data)
    
    . reg price mpg rep78
    
          Source |       SS           df       MS      Number of obs   =        69
    -------------+----------------------------------   F(2, 66)        =     11.06
           Model |   144754063         2  72377031.7   Prob > F        =    0.0001
        Residual |   432042896        66  6546104.48   R-squared       =    0.2510
    -------------+----------------------------------   Adj R-squared   =    0.2283
           Total |   576796959        68  8482308.22   Root MSE        =    2558.5
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |  -271.6425   57.77115    -4.70   0.000    -386.9864   -156.2987
           rep78 |   666.9568   342.3559     1.95   0.056     -16.5789    1350.492
           _cons |   9657.754    1346.54     7.17   0.000       6969.3    12346.21
    ------------------------------------------------------------------------------
    
    . asreg reg price mpg rep78, rmse
    variable reg not found
    r(111);
    
    . asreg  price mpg rep78, rmse
    
    . list _rmse in 1
    
         +-----------+
         |     _rmse |
         |-----------|
      1. | 2558.5356 |
         +-----------+
    Attaullah Shah
    Keymaster
    Post count: 69

    Can you please share the dataset on which the said error is produced?

    Attaullah Shah
    Keymaster
    Post count: 69

    I just checked the following and works fine. Do you have an updated copy of asdoc? You can check by

    which asdoc
    asdoc table foreign rep78, contents(freq mean price sd price min price max price ) replace
    
    ------------------------------------------------------------
              |                Repair Record 1978               
     Car type |        1         2         3         4         5
    ----------+-------------------------------------------------
     Domestic |        2         8        27         9         2
              |  4,564.5   5,967.6   6,607.1   5,881.6   4,204.5
              | 522.5519  3579.357  3661.267  1592.019  311.8341
              |    4,195     3,667     3,291     3,829     3,984
              |    4,934    14,500    15,906     8,814     4,425
              | 
      Foreign |        .         .         3         9         9
              |        .         .   4,828.7   6,261.4   6,292.7
              |        .         .  1285.613  1896.092  2765.629
              |        .         .     3,895     3,995     3,748
              |        .         .     6,295     9,735    11,995
    ------------------------------------------------------------
    
    Attaullah Shah
    Keymaster
    Post count: 69

    See this example

    sysuse auto, clear
    bysort foreign rep78  : sum price
    table foreign rep78, contents(freq mean price sd price min price min price )
    asdoc table foreign rep78, contents(freq mean price sd price min price min price ) replace
    
    ------------------------------------------------------------
              |                Repair Record 1978               
     Car type |        1         2         3         4         5
    ----------+-------------------------------------------------
     Domestic |        2         8        27         9         2
              |  4,564.5   5,967.6   6,607.1   5,881.6   4,204.5
              | 522.5519  3579.357  3661.267  1592.019  311.8341
              |    4,195     3,667     3,291     3,829     3,984
              |    4,195     3,667     3,291     3,829     3,984
              | 
      Foreign |        .         .         3         9         9
              |        .         .   4,828.7   6,261.4   6,292.7
              |        .         .  1285.613  1896.092  2765.629
              |        .         .     3,895     3,995     3,748
              |        .         .     3,895     3,995     3,748
    ------------------------------------------------------------
    
    *And using tabstat
    by foreign, sort : tabstat price, statistics( count mean sd min min ) by(rep78)
    
    
    Attaullah Shah
    Keymaster
    Post count: 69

    Perhaps you need to use the tabstat command for this. tabstat is more flexible than sum command. And even you can give a try to the table command.

    Attaullah Shah
    Keymaster
    Post count: 69

    This has been fixed. However, you need to remember that using by(vars), the grouping variable var should not have more than two categories, this is the limitation imposed by Stata.

    The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
    net install asdoc, from(http://fintechprofessor.com) replace

    Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.

    Please do remember to cite asdoc. To cite:
    In-text citation
    Tables were created using asdoc, a Stata program written by Shah (2018).

    Bibliography
    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.

    Attaullah Shah
    Keymaster
    Post count: 69

    Currently, asdoc allows bysort prefix with only one variable. If you need to use two variables with bysort, then there is a workaround. Convert both the variables to a single with using the group function of egen, and then use the new variable with asdoc. see this example

    egen Ctry_ID= group(Country IDType)
    
    bysort Ctry_ID: asdoc sum Var1

    Please cite asdoc in your research.
    In-text citation
    Tables were created using asdoc, a Stata program written by Shah (2018).

    Bibliography
    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.

    Attaullah Shah
    Keymaster
    Post count: 69

    bys firmid year means that the regression will be run on each year within each firmid, in your dataset, there are only one observation for each firmid per year, therefore, regression cannot be estimated on a single observation.

    Attaullah Shah
    Keymaster
    Post count: 69

    Currently, asdoc does not report additional statistics with tabulation commands. I am working on asdocx, a premium version of asdoc, which shall add all these missing functionalities. At the moment, there is a workaround for this issue. If you read the asdoc help file, you shall see in Section 1.9 that there is a text() option that can be used for reporting text or any additional statistics from the r() and e() macros. Since tabulation command leaves the Chi2 and its P-value in r() macros, therefore, they can be written to the existing document using the text option. See the following examples

    webuse citytemp2
    asdoc tabulate region agecat, chi2 replace
    asdoc, text(Chi2 =`r(chi2)'  Pr=`r(p)')
    Attaullah Shah
    Keymaster
    Post count: 69

    Thanks for reporting this. I have fixed the bug.

    The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.

    net install asdoc, from(http://fintechprofessor.com) replace

    Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.

    Please do remember to cite asdoc. To cite:

    In-text citation

    Tables were created using asdoc, a Stata program written by Shah (2018).

    Bibliography

    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.

Viewing 15 posts - 31 through 45 (of 69 total)