楼主: alabala
5107 5

[回归分析求助] 关于intreg [推广有奖]

  • 0关注
  • 1粉丝

已卖:165份资源

硕士生

76%

还不是VIP/贵宾

-

威望
0
论坛币
1705 个
通用积分
0.1800
学术水平
8 点
热心指数
4 点
信用等级
0 点
经验
1541 点
帖子
164
精华
0
在线时间
86 小时
注册时间
2006-3-15
最后登录
2017-6-6

楼主
alabala 发表于 2012-3-25 22:49:22 |AI写论文
20论坛币
我在做回归的时候,遇到如下问题
intreg lnwage eduyear exp exp2 i.province male if worktype== 1
     est store state

显示:

. intreg lnwage eduyear exp exp2 i.province male if worktype== 1
observations with lnwage > eduyear not allowed

我检查了lnwage和eduyear的obs,是一样的啊,不知道为什么

最佳答案

蓝色 查看完整内容

Examples We have a dataset containing wages, truncated and in categories. Some of the observations on wages are wage1 wage2 20 25 meaning 20000
关键词:int REG observations observation province 工资 计算 如何 资料

沙发
蓝色 发表于 2012-3-25 22:49:23
Examples

    We have a dataset containing wages, truncated and in categories.  Some of the observations on
    wages are

        wage1    wage2
        20       25       meaning 20000 <= wages <= 25000
        50        .       meaning 50000 <= wages


    Setup
        . webuse intregxmpl

    Interval regression
        . intreg wage1 wage2 age c.age#c.age nev_mar rural school tenure

    Same as above, but suppress constant term
        . intreg wage1 wage2 age c.age#c.age nev_mar rural school tenure, noconstant


藤椅
蓝色 发表于 2012-3-26 08:31:16
你看intreg命令了吗
命令不是你想怎么写就怎么写
而是人家规定了格式你按照要求写。



Title

    [R] intreg -- Interval regression


Syntax

        intreg depvar1 depvar2 [indepvars] [if] [in] [weight] [, options]

Description

    intreg fits a model of y=[depvar1, depvar2] on indepvars, where y for each observation is
    point data, interval data, left-censored data, or right-censored data.

    depvar1 and depvar2 should have the following form:

             Type of data                  depvar1  depvar2
             ----------------------------------------------
             point data          a = [a,a]    a        a
             interval data           [a,b]    a        b
             left-censored data   (-inf,b]    .        b
             right-censored data   [a,inf)    a        .
             ----------------------------------------------





板凳
alabala 发表于 2012-3-29 10:58:25
蓝色 发表于 2012-3-26 08:31
你看intreg命令了吗
命令不是你想怎么写就怎么写
而是人家规定了格式你按照要求写。
仔细看了下版主写的,对比了下help,明白了,是我学的不深入,谢谢版主

报纸
wallyone 发表于 2014-2-11 21:25:22
c.age#c.age是什么意思

地板
蓝色 发表于 2014-2-11 21:35:07
Title

    [U] 11.4.3 Factor variables


Description

    Factor variables are extensions of varlists of existing variables.  When a command allows factor
    variables, in addition to typing variable names from your data, you can type factor variables,
    which might look like

        i.varname

        i.varname#i.varname

        i.varname#i.varname#i.varname

        i.varname##i.varname

        i.varname##i.varname##i.varname

    Factor variables create indicator variables from categorical variables, interactions of indicators
    of categorical variables, interactions of categorical and continuous variables, and interactions
    of continuous variables (polynomials).  They are allowed with most estimation and postestimation
    commands, along with a few other commands.

    There are four factor-variable operators:

         Operator  Description
         ---------------------------------------------------------------------------------------------
         i.        unary operator to specify indicators
         c.        unary operator to treat as continuous
         #         binary operator to specify interactions
         ##        binary operator to specify factorial interactions
         ---------------------------------------------------------------------------------------------

    The indicators and interactions created by factor-variable operators are referred to as virtual
    variables.  They act like variables in varlists but do not exist in the dataset.

    Categorical variables to which factor-variable operators are applied must contain nonnegative
    integers with values in the range 0 to 32,740, inclusive.

    Factor variables may be combined with the L. and F. time-series operators.


Remarks

    Remarks are presented under the following headings:

        Basic examples
        Base levels
        Selecting levels
        Applying operators to a group of variables


Basic examples

    Here are some examples of use of the operators:

         Factor            
         specification     Result
         ---------------------------------------------------------------------------------------------
         i.group           indicators for levels of group

         i.group#i.sex     indicators for each combination of levels of group and sex, a two-way
                             interaction

         group#sex         same as i.group#i.sex

         group#sex#arm     indicators for each combination of levels of group, sex, and arm, a
                             three-way interaction

         group##sex        same as i.group i.sex group#sex

         group##sex##arm   same as i.group i.sex i.arm group#sex group#arm sex#arm group#sex#arm

         sex#c.age         two variables -- age for males and 0 elsewhere, and age for females and 0
                             elsewhere; if age is also in the model, one of the two virtual variables
                             will be treated as a base

         sex##c.age        same as i.sex age sex#c.age

         c.age             same as age

         c.age#c.age       age squared

         c.age#c.age#c.age age cubed
         ---------------------------------------------------------------------------------------------


Base levels

    You can specify the base level of a factor variable by using the ib. operator.  The syntax is

           Base         
           operator(*)    Description
           -------------------------------------------------------------------------------------------
           ib#.           use # as base, #=value of variable
           ib(##).        use the #th ordered value as base (**)
           ib(first).     use smallest value as base (the default)
           ib(last).      use largest value as base
           ib(freq).      use most frequent value as base
           ibn.           no base level
           -------------------------------------------------------------------------------------------
            (*) The i may be omitted.  For instance, you may type ib2.group or b2.group.
           (**) For example, ib(#2). means to use the second value as the base.

    If you want to use group==3 as the base in a regression, you can type,

        . regress y  i.sex ib3.group

    You can also permanently set the base levels of categorical variables by using the fvset command.


Selecting levels

    You can select a range of levels -- a range of virtual variables -- by using the
    i(numlist). operator.

         Examples          Description
         ---------------------------------------------------------------------------------------------
         i2.cat            a single indicator for cat==2

         2.cat             same as i2.cat

         i(2 3 4).cat      three indicators, cat==2, cat==3, and cat==4;
                             same as i2.cat i3.cat i4.cat

         i(2/4).cat        same as i(2 3 4).cat

         2.cat#1.sex       a single indicator that is 1 when cat==2 and sex==1, and is 0 otherwise

         i2.cat#i1.sex     same as 2.cat#1.sex
         ---------------------------------------------------------------------------------------------


Applying operators to a group of variables

    Factor-variable operators may be applied to groups of variables by using parentheses.

    In the examples that follow, variables group, sex, arm, and cat are categorical, and variables
    age, wt, and bp are continuous:

         Examples                  Expansion
         ---------------------------------------------------------------------------------------------
         i.(group sex arm)         i.group i.sex i.arm

         group#(sex arm cat)       group#sex group#arm group#cat

         group##(sex arm cat)      i.group i.sex i.arm i.cat group#sex group#arm group#cat

         group#(c.age c.wt c.bp)   i.group group#c.age group#c.wt group#c.bp

         group#c.(age wt bp)       same as group#(c.age c.wt c.bp)
         ---------------------------------------------------------------------------------------------

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 22:09