Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to make a descriptive statistics like the picture (including Jarque‐Bera test for normality) and output the result

    "sum,de" did not include Jarque‐Bera test for normality, and how to use the panel data to achieve the picture result.

    clear
    input str9 province byte id int year double(netrate urban)
    "shanghai" 1 1997 .34 71.64
    "shanghai" 1 1998 .62 72.83
    "shanghai" 1 1999 5.37 73.19
    "shanghai" 1 2000 12.3 74.62
    "shanghai" 1 2001 19.21 75.28
    "jiangsu" 2 1997 .05 29.9
    "jiangsu" 2 1998 .16 31.5
    "jiangsu" 2 1999 .6 34.9
    "jiangsu" 2 2000 1.67 41.5
    "jiangsu" 2 2001 3.67 42.6
    "zhejiang" 3 1997 .05 39.04
    "zhejiang" 3 1998 .22 42.26
    "zhejiang" 3 1999 .88 45.48
    "zhejiang" 3 2000 3.24 48.7
    "zhejiang" 3 2001 4.82 50.9
    "jiangxi" 4 1997 .01 25.32
    "jiangxi" 4 1998 .08 26.05
    "jiangxi" 4 1999 .09 26.79
    "jiangxi" 4 2000 1.12 27.69
    "jiangxi" 4 2001 1.45 30.41
    end
    [/CODE]
    Click image for larger version

Name:	1594216716222.jpg
Views:	1
Size:	127.7 KB
ID:	1562418

  • #2
    o

    Comment


    • #3
      Something along the following lines could work:
      Code:
      putexcel set some-file.xlsx, replace
      putexcel A1="Province" B1="Variable" C1="Mean" D1="SD" E1="Skewness" F1="Kurtosis" G1="J-B"
      mat results=J(8,5,.)
      local count 0
      levelsof province, local(prov) clean
      forvalues i=1/4{    
          putexcel A`=`count'+2'="`=word("`prov'",`i')'"
          foreach var in netrate urban{
          putexcel B`=`count'+2'="`var'"
          local ++count
          qui sum `var' if id==`i',d
          mat results[`count',1]=r(mean)
          mat results[`count',2]=r(sd)
          mat results[`count',3]=r(skewness)
          mat results[`count',4]=r(kurtosis)
          sktest `var' if id==`i'
          mat results[`count',5]=r(chi2)
          }    
      }
      putexcel C2=matrix(results)
      This code is just a quick solution and needs modification from your side to give you the desired result.

      Comment


      • #4
        Originally posted by Sven-Kristjan Bormann View Post
        Something along the following lines could work:
        Code:
        putexcel set some-file.xlsx, replace
        putexcel A1="Province" B1="Variable" C1="Mean" D1="SD" E1="Skewness" F1="Kurtosis" G1="J-B"
        mat results=J(8,5,.)
        local count 0
        levelsof province, local(prov) clean
        forvalues i=1/4{
        putexcel A`=`count'+2'="`=word("`prov'",`i')'"
        foreach var in netrate urban{
        putexcel B`=`count'+2'="`var'"
        local ++count
        qui sum `var' if id==`i',d
        mat results[`count',1]=r(mean)
        mat results[`count',2]=r(sd)
        mat results[`count',3]=r(skewness)
        mat results[`count',4]=r(kurtosis)
        sktest `var' if id==`i'
        mat results[`count',5]=r(chi2)
        }
        }
        putexcel C2=matrix(results)
        This code is just a quick solution and needs modification from your side to give you the desired result.
        thanks for your kind help

        Comment

        Working...
        X