Announcement

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

  • Dealing with multicollinearity

    Dear Statalists,

    I run in some trouble with the cnsreg function in combination with multicollinearity. I restrict my dummy regression such that it deals with multicollinearity, the only problem is that it seems that Stata first deals with multicollinearity before it takes my constraints in account. Does anyone know how I could change this in Stata?

    I asked this question before, only slightly different: https://www.statalist.org/forums/for...lticolinearity

    This are my code, results and an example of the data:
    Commands:
    Code:
    bysort _j: drop if industry==. 
    
    levelsof country1, local(country1)
    levelsof industry, local(industry)
    
    local country1_constraint 0
    local industry_constraint 0
    
    foreach c of local country1 {
        count if country1 == `c'
        local country1_constraint `country1_constraint' + `r(N)'*cc`c'
        gen byte cc`c' = `c'.country1
    }
    
    foreach i of local industry {
        count if industry == `i'
        local industry_constraint `industry_constraint' + `r(N)'*ii`i'
        gen byte ii`i' = `i'.industry
    }
    display `"`industry_constraint'"'
    
    constraint def 1 `country1_constraint' = 0
    constraint def 2 `industry_constraint' = 0
    
    cnsreg ret eumean cc* ii*, constraints(1 2)

    Results:
    Code:
     
     cnsreg ret cc* ii*, noconstant constraints(1 2) note: cc12 omitted because of collinearity note: ii9 omitted because of collinearity  Constrained linear regression                   Number of obs     =  1,318,853                                                 F(  18,1318835)   =      32.37                                                 Prob > F          =     0.0000                                                 Root MSE          =     0.0570   ( 1)  46463*cc1 + 87208*cc2 + 47568*cc3 + 237840*cc4 + 236090*cc5 + 48559*cc6 +        33694*cc7 + 145677*cc8 + 94145*cc9 + 44595*cc10 + 101082*cc11 +        518293*o.cc12 = 0  ( 2)  44581*ii0 + 98129*ii1 + 340901*ii2 + 193278*ii3 + 96144*ii4 + 208134*ii5 +        27733*ii6 + 56496*ii7 + 472727*ii8 + 103091*o.ii9 = 0 ------------------------------------------------------------------------------       return |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval] -------------+----------------------------------------------------------------          cc1 |   .0003957   .0002856     1.39   0.166    -.0001641    .0009556          cc2 |   .0000548   .0002046     0.27   0.789    -.0003461    .0004557          cc3 |   .0005556   .0002751     2.02   0.043     .0000163    .0010948          cc4 |   .0009013   .0001129     7.98   0.000       .00068    .0011226          cc5 |   .0009292   .0001164     7.98   0.000      .000701    .0011574          cc6 |   .0003177   .0002664     1.19   0.233    -.0002046    .0008399          cc7 |   .0009946   .0003508     2.84   0.005      .000307    .0016822          cc8 |  -.0006696    .000161    -4.16   0.000    -.0009851   -.0003541          cc9 |  -.0041605   .0001988   -20.92   0.000    -.0045502   -.0037707         cc10 |   .0002611   .0002857     0.91   0.361    -.0002988    .0008211         cc11 |  -.0005411   .0002012    -2.69   0.007    -.0009354   -.0001467         cc12 |          0  (omitted)          ii0 |   .0001002   .0002989     0.34   0.738    -.0004857    .0006861          ii1 |   .0004428    .000195     2.27   0.023     .0000607    .0008249          ii2 |   .0002788   .0000955     2.92   0.004     .0000917     .000466          ii3 |   .0002778   .0001318     2.11   0.035     .0000195    .0005361          ii4 |  -.0001704   .0002131    -0.80   0.424    -.0005881    .0002474          ii5 |  -.0001667   .0001314    -1.27   0.205    -.0004243    .0000909          ii6 |  -.0009099   .0003944    -2.31   0.021    -.0016829    -.000137          ii7 |  -.0009552    .000261    -3.66   0.000    -.0014667   -.0004437          ii8 |  -.0001405   .0000786    -1.79   0.074    -.0002944    .0000135          ii9 |          0  (omitted) ------------------------------------------------------------------------------
    Data:
    Code:
     
     input int(date _j) double return long marketcap byte industry str14 country 14252 295 -.029411764705882495  207874 3 "Austria" 14259 319  -.03891233005157064  552000 2 "Austria" 14266 339 -.025473071324599684 4299390 7 "Portugal" 14273 301                    0  609427 8 "Portugal" 14280 327                    .  130248 3 "Germany" 14287 319  -.08069414316702818  552000 2 "Germany" 14294 307 -.004160887656033322  228750 8 "France" 14301 337                    0   46500 8 "France"
    Last edited by Ruben Jakobs; 04 Jun 2018, 04:24.

  • #2
    I appreciate that you tried to give us the data and program. However, the data you provided does not include all the variables in program statements or the cnsreg statement. This makes it hard to duplicate your problem.

    If you are just constraining some values to zero, there is probably another way to set it up to have a similar model.

    Comment


    • #3

      Phil Bromiley thanks for your reaction. Here you have a larger sample of my dataset. I have to say that in my original code I did not put "eumean" in the cnsreg, that was an experiment. So if you want to reproduce my outcomes you should leave that out.

      Lot of thanks in advance.

      Code:
      input int(date date1 _j) double(price return) long marketcap str14 country long country1 byte industry
      14252 14252  335                  .                    .         . "Austria"         1 .
      14252 14252  892                  .                    .         . "United Kingdom" 12 8
      14252 14252 1152             49.642   .03951418699612607   4790818 "Germany"         5 2
      14252 14252  904                  .                    .         . "United Kingdom" 12 2
      14252 14252  629              24.57   -.2140115163147793    105439 "United Kingdom" 12 2
      14252 14252 1259             22.639   .05923361250175446     24000 "Germany"         5 8
      14252 14252 1172              2.778 -.007147962830593287    636281 "Germany"         5 1
      14252 14252 1112              4.615 -.039542143600416135    150538 "Germany"         5 2
      14252 14252  350 5.9750000000000005  .023835226785928476     17956 "Portugal"       10 9
      14252 14252  545                  .                    .         . "United Kingdom" 12 8
      14252 14252 1422                  .                    .         . "France"          4 4
      14252 14252 1506            64.3242   .10138708865484423 134531892 "France"          4 6
      14252 14252   75                  .                    .         . "Italy"           8 5
      14252 14252  503 3.6645000000000003   .01523756753012887   1432977 "Spain"          11 2
      14252 14252 1671             37.853   .03180487485757593   4636490 "Belgium"         2 8
      14252 14252 1493                  .                    .         . "France"          4 2
      14252 14252  301 21.900000000000002 .0009140767824498687    609427 "Austria"         1 8
      14252 14252  913            1972.76    .1232797153024911   6606407 "United Kingdom" 12 8
      14252 14252 1096                  .                    .         . "Germany"         5 9
      14252 14252  552                  .                    .         . "United Kingdom" 12 8
      14252 14252  948             188.09 -.032060518731988424   2346845 "United Kingdom" 12 4
      14252 14252  122                  .                    .         . "Italy"           8 5
      14252 14252  737                  .                    .         . "United Kingdom" 12 8
      14252 14252 1255             18.782                    0    130760 "Germany"         5 1
      14252 14252  960                  .                    .         . "United Kingdom" 12 5
      14252 14252 1472                  .                    .         . "France"          4 4
      14252 14252  926              53.25   .04411764705882353    115313 "United Kingdom" 12 8
      14252 14252 1536                  .                    .         . "France"          4 3
      14252 14252 1607                  .                    .         . "Greece"          6 8
      14252 14252  883                  .                    .         . "United Kingdom" 12 8
      14252 14252 1513 1.4889000000000001 -.014234639830508378    371246 "France"          4 3
      14252 14252 1602               4.48    .1256281407035177    828185 "Greece"          6 3
      14252 14252 1396            26.4406  .019766199605833024    148902 "France"          4 2
      14252 14252 1605                  .                    .         . "Greece"          6 8
      14252 14252 1455            24.3766                    0    186488 "France"          4 8
      14252 14252  268                  .                    .         . "Netherlands"     9 .
      14252 14252  726                  .                    .         . "United Kingdom" 12 1
      14252 14252 1236                  .                    .    286650 "Germany"         5 9
      14252 14252 1331               34.9  -.08788454552344721   4771341 "Finland"         3 9
      14252 14252 1596                  .                    .         . "Greece"          6 4
      14252 14252 1122              2.458   .06823120382442417    103680 "Germany"         5 3
      14252 14252  247 108.32870000000001  .024482893268358313    174124 "Netherlands"     9 2
      14252 14252  893             517.77   .08563101503365268  10362413 "United Kingdom" 12 5
      14252 14252  650                  .                    .         . "United Kingdom" 12
      Last edited by Ruben Jakobs; 06 Jun 2018, 07:20.

      Comment

      Working...
      X