全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
4984 4
2013-06-08
您好!
       我在进行线性多元回归时,要区分处理组和控制组(已按1、0进行赋值),然后要怎样操作才能分别得出两种情况下的结果呢?
         为什么我用以下的方式不行:reg  p  ni  bv, by( icd)     【其中,P代表股价,ni代表净利润,bv代表账面价值,icd代表内部控制缺陷,即,存在内部控制缺陷为处理组,不存在内部控制为控制组】
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-6-9 00:15:28

Title

    [D] by -- Repeat Stata command on subsets of the data
    [U] 11 Language syntax


Syntax

        by varlist: stata_cmd

        bysort varlist: stata_cmd

    The above diagrams show by and bysort as they are typically used.  The full syntax of the commands is

        by varlist1 [(varlist2)] [, sort rc0]:  stata_cmd

        bysort varlist1 [(varlist2)] [, rc0]:  stata_cmd


Description

    Most Stata commands allow the by prefix, which repeats the command for each group of observations for which the values of
    the variables in varlist are the same.  by without the sort option requires that the data be sorted by varlist; see [D]
    sort.

    Stata commands that work with the by prefix indicate this immediately following their syntax diagram by reporting, for
    example, "by is allowed; see [D] by" or "bootstrap, by, etc., are allowed; see prefix".

    by and bysort are really the same command; bysort is just by with the sort option.

    The varlist1 (varlist2) syntax is of special use to programmers.  It verifies that the data are sorted by varlist1 varlist2
    and then performs a by as if only varlist1 were specified.  For instance,

        by pid (time): gen growth = (bp - bp[_n-1])/bp

    performs the generate by values of pid but first verifies that the data are sorted by pid and time within pid.


Options

    sort specifies that if the data are not already sorted by varlist, by should sort them.

    rc0 specifies that even if the stata_cmd produces an error in one of the by-groups, then by is still to run the stata_cmd on
        the remaining by-groups.  The default action is to stop when an error occurs.  rc0 is especially useful when stata_cmd
        is an estimation command and some by-groups have insufficient observations.


Examples

    ------------------------------------------------------------------------------------------------------------------------------
    Setup
        . sysuse auto

    For each category of foreign, display summary statistics for rep78
        . by foreign:  summarize rep78

    Same as above command, but check that the data are sorted by foreign and make within foreign
        . by foreign (make):  summarize rep78
        not sorted
        r(5);
        . sort foreign make
        . by foreign (make): summarize rep78

    For each category of rep78, display frequency counts of foreign
        . by rep78: tabulate foreign
        not sorted
        r(5);
        . sort rep78
        . by rep78: tabulate foreign

    Equivalent to above two commands
        . by rep78, sort:  tabulate foreign

    Equivalent to above command
        . bysort rep78: tabulate foreign

    For each category of rep78 within categories of foreign, display summary statistics for price
        . by foreign rep78, sort: summarize price

    ------------------------------------------------------------------------------------------------------------------------------
    Setup
        . sysuse autornd
        . keep in 1/20

    Store in new variable mean_w the mean value of weight for each category of mpg
        . by mpg, sort: egen mean_w = mean(weight)
    ------------------------------------------------------------------------------------------------------------------------------


Technical note

    by repeats the stata_cmd for each group defined by varlist.  If stata_cmd saves results, only the results from the last
    group on which stata_cmd executes will be saved.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-6-9 00:20:12
看看 by的格式
不是放在后面

如果放在后面,你查那个命令会列出来的
这些问题,查命令的help就都知道了


Title

    [R] table -- Tables of summary statistics


Syntax

        table rowvar [colvar [supercolvar]] [if] [in] [weight] [, options]


    options                Description
    ----------------------------------------------------------------------------------------------------------------------------
    Main
      contents(clist)      contents of table cells; select up to five statistics; default is contents(freq)
      by(superrowvarlist)  superrow variables

    Options
      cellwidth(#)         cell width
      csepwidth(#)         column-separation width
      stubwidth(#)         stub width
      scsepwidth(#)        supercolumn-separation width
      center               center-align table cells; default is right-align
      left                 left-align table cells; default is right-align
      cw                   perform casewise deletion
      row                  add row totals
      col                  add column totals
      scol                 add supercolumn totals
      concise              suppress rows with all missing entries
      missing              show missing statistics with period
      replace              replace current data with table statistics
      name(string)         name new variables with prefix string
      format(%fmt)         display format for numbers in cells; default is format(%9.0g)
    ----------------------------------------------------------------------------------------------------------------------------
    by is allowed; see [D] by.
    fweights, aweights, iweights, and pweights are allowed; see weight.
    pweights may not be used with sd, semean, sebinomial, or sepoisson.  iweights may not be used with semean, sebinomial, or
      sepoisson.  aweights may not be used with sebinomial or sepoisson.

Setup
        . webuse byssin1

    Four-way table
        . table workplace smokes race [fw=pop], by(sex) c(mean prob) format(%9.3f)

    Four-way table with supercolumn, row, and column totals
        . table workplace smokes race [fw=pop], by(sex) c(mean prob) format(%9.3f) sc col row





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-6-9 15:35:05
蓝色 发表于 2013-6-9 00:15
Title

    [D] by -- Repeat Stata command on subsets of the data
哦,谢谢您的指点,我得再慢慢看看,还有您的建议!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2018-11-19 20:56:48
stata有问题直接help,他会有例子举出来的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群