Announcement

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

  • Dissertation help: Gaussian Kernel Regression, Piecewise regression, Probit Regression

    Hi all,
    I am currently writing my dissertation and encountering some issues with the regressions I want to run. I have attched the regressions and spessifications that I am trying to replicate below, which is a smaple from Baker et al. (2012) "the effect of reference point pricing on mergers and acquisitions". Below is the dataex, if more information is needed please let me know.
    Any help at all would be highly appreciated!

    input str10 date str16 deal_status float(offer_price target_price_4_weeks_prior) str13 target_high_ltm float(log_offer_price log_ltm)
    "14/12/2023" "Completed" 5.25 3.56 "4.18" .17 .07
    "12/12/2023" "Completed" .93 .62 "0.66" .18 .03
    "08/12/2023" "Completed" 12.18 8.06 "10.20" .18 .1
    "06/12/2023" "Completed" 33.98 22.49 "25.00" .18 .05
    "24/11/2023" "Completed" 57.64 40.07 "42.30" .16 .02
    "13/11/2023" "Completed" 6.6 4.02 "6.46" .22 .21
    "10/11/2023" "Completed" 17.18 12.02 "15.06" .16 .1
    "10/11/2023" "Completed" 5.29 3.95 "6.02" .13 .18
    "06/11/2023" "Completed" 8.37 5.57 "5.83" .18 .02
    "30/10/2023" "Completed" 3.77 2.23 "2.40" .23 .03
    "17/10/2023" "Completed" 22.17 15.42 "22.12" .16 .16
    "17/10/2023" "Completed" 3.04 2.81 "3.37" .03 .08
    "05/10/2023" "Completed" .33 .32 "0.33" .01 .01
    "29/09/2023" "Completed" 8.71 5.85 "6.67" .17 .06
    "19/09/2023" "Completed" .79 .56 "0.61" .15 .04
    "04/09/2023" "Completed" .05 .04 "0.05" .11 .11
    "15/08/2023" "Completed" 2.48 1.11 "1.87" .35 .23
    "10/08/2023" "Completed" 20.87 16.55 "18.11" .1 .04
    "09/08/2023" "Completed" 12.19 5.92 "6.70" .31 .05
    "13/07/2023" "Completed" 18.77 8.68 "10.45" .34 .08
    "04/07/2023" "Completed" 2.06 1.65 "2.34" .1 .15
    "29/06/2023" "Withdrawn" .06 .05 "0.09" .12 .28
    "27/06/2023" "Completed" 54.49 40.3 "47.87" .13 .07
    "27/06/2023" "Completed" 4.88 3.06 "6.60" .2 .33
    "27/06/2023" "Completed" 1.17 .85 "1.02" .14 .08
    "14/06/2023" "Completed" 1.33 1.15 "1.94" .06 .23
    "07/06/2023" "Completed" 8.6 5.78 "9.00" .17 .19
    "15/05/2023" "Completed" 3.54 2.16 "2.97" .21 .14
    "04/05/2023" "Completed" 30 23.51 "30.95" .11 .12
    "04/05/2023" "Completed" 21.71 17.05 "20.00" .1 .07
    "16/04/2023" "Completed" .91 .81 "7.95" .05 .99
    "13/04/2023" "Completed" 4.7 2.52 "8.38" .27 .52
    "30/03/2023" "Withdrawn" .54 .36 "0.80" .17 .34
    "23/03/2023" "Completed" 35.15 38.04 "45.94" -.03 .08
    "20/03/2023" "Completed" 30 26.65 "53.06" .05 .3
    "13/03/2023" "Completed" 10.38 10.43 "14.61" 0 .15
    "07/03/2023" "Completed" 8.31 7.72 "8.92" .03 .06
    "01/03/2023" "Completed" .99 .96 "1.01" .01 .02
    "28/02/2023" "Completed" .04 .02 "0.06" .28 .47
    "13/02/2023" "Completed" 6.77 4.43 "6.50" .18 .17
    "09/02/2023" "Completed" 9.29 6.87 "7.61" .13 .04
    "09/02/2023" "Completed" 1.4 1.16 "4.10" .08 .55
    "08/02/2023" "Completed" 22.74 17.08 "18.56" .12 .04
    "03/02/2023" "Completed" 1.31 .7 "2.96" .27 .63
    "01/02/2023" "Completed" 18.15 10.34 "31.51" .24 .48
    "31/01/2023" "Completed" 11.51 8.26 "12.09" .14 .17
    "20/01/2023" "Completed" .37 .1 "3.06" .55 1.46
    "18/01/2023" "Completed" 1.83 1.41 "2.75" .11 .29
    "17/01/2023" "Completed" 60 36.86 "46.97" .21 .11
    "13/01/2023" "Completed" 11.34 7.45 "8.31" .18 .05
    "09/01/2023" "Completed" 1.46 .64 "1.50" .36 .37
    "04/01/2023" "Completed" 6.82 4.51 "10.32" .18 .36
    "16/12/2022" "Completed" 6.15 2.18 "9.16" .45 .62
    "16/12/2022" "Completed" .05 .03 "0.04" .2 .05
    "28/11/2022" "Completed" 67 51.79 "82.25" .11 .2
    "21/11/2022" "Completed" 32.88 17.86 "34.96" .26 .29
    "11/11/2022" "Completed" 25.9 16.72 "23.17" .19 .14
    "11/11/2022" "Completed" 16.74 13.4 "18.89" .1 .15
    "09/11/2022" "Withdrawn" 9.76 4.86 "483.55" .3 2
    "14/10/2022" "Completed" 17.93 13.37 "17.99" .13 .13
    "03/10/2022" "Withdrawn" .05 .05 "0.07" .03 .13
    "28/09/2022" "Completed" 10.82 9.07 "10.20" .08 .05
    "26/09/2022" "Withdrawn" .31 .31 "0.32" .01 .02
    "23/09/2022" "Completed" 2.26 1.56 "2.96" .16 .28
    "19/09/2022" "Completed" 24.9 18.96 "27.40" .12 .16
    "14/09/2022" "Completed" 43.21 37.48 "45.03" .06 .08
    "12/09/2022" "Completed" .03 .01 "0.08" .44 .81
    "01/09/2022" "Completed" 10.79 7.87 "9.81" .14 .1
    "31/08/2022" "Completed" 1.5 .82 "2.82" .26 .54
    "23/08/2022" "Completed" .84 .69 "1.65" .09 .38
    "10/08/2022" "Completed" .21 .09 "0.37" .34 .6
    "09/08/2022" "Completed" 16.13 9.54 "17.44" .23 .26
    "28/07/2022" "Completed" 17.66 15.44 "18.27" .06 .07
    "27/06/2022" "Completed" 3.67 2.61 "2.68" .15 .01
    "24/06/2022" "Completed" 4.42 3.75 "4.55" .07 .08
    "23/06/2022" "Completed" 30.09 21.7 "29.27" .14 .13
    "23/06/2022" "Withdrawn" .24 .21 "0.23" .06 .03
    "13/06/2022" "Withdrawn" 1.35 1.19 "1.29" .05 .04
    "10/06/2022" "Completed" .31 .23 "0.39" .12 .23
    "08/06/2022" "Completed" 6.75 3.7 "7.15" .26 .29
    "03/06/2022" "Completed" 17.36 10.26 "14.45" .23 .15
    "25/05/2022" "Completed" 21 14.42 "28.27" .16 .29
    "13/05/2022" "Completed" 32.54 24.46 "28.72" .12 .07
    "12/05/2022" "Completed" 884.89 825.52 "1,014.56" .03 .09
    "10/05/2022" "Completed" 16.12 9.33 "11.58" .24 .09
    "28/04/2022" "Completed" 21.42 16.83 "17.93" .1 .03
    "26/04/2022" "Completed" .88 .77 "1.38" .06 .25
    "25/04/2022" "Completed" 4.71 3.79 "4.13" .09 .04
    "22/04/2022" "Withdrawn" 8.43 5.15 "5.73" .21 .05
    "14/04/2022" "Completed" 54.2 37.3 "71.71" .16 .28
    "14/04/2022" "Completed" 43.65 24.34 "49.66" .25 .31
    "14/04/2022" "Completed" 25.04 17.74 "24.00" .15 .13
    "01/04/2022" "Withdrawn" 2.3 1.89 "2.58" .08 .14
    "30/03/2022" "Completed" .95 .63 "1.03" .18 .21
    "22/03/2022" "Withdrawn" 6.45 5.15 "5.73" .1 .05
    "16/03/2022" "Completed" 43.59 33.52 "36.78" .11 .04
    "10/03/2022" "Completed" 32.87 30.24 "35.31" .04 .07
    "09/03/2022" "Completed" 52.77 38.99 "52.82" .13 .13
    "27/02/2022" "Completed" .7 .32 "0.57" .34 .25
    "14/02/2022" "Completed" 24.65 16.34 "19.50" .18 .08
    end
    [/CODE]
    Attached Files

  • #2
    there's a lot more to it given the description, but this might get you started.
    Code:
    destring target_high_ltm , replace force
    drop if target_high_ltm>100
    npregress kernel offer_price  target_high_ltm , kernel(gaussian)
    npgraph

    Comment


    • #3
      As a small twist on George Ford 's helpful answer, here is a detail of mundane but also vital data management.

      Let's explore why one variable was presented as string:

      Code:
      . tab target_high_ltm if missing(real(target_high_ltm))
      
      target_high_l |
                 tm |      Freq.     Percent        Cum.
      --------------+-----------------------------------
           1,014.56 |          1      100.00      100.00
      --------------+-----------------------------------
              Total |          1      100.00
      It's the comma. You need to remove the comma as part of the destring with ignore(,) -- not use the force option.

      If there are other problems in the full dataset, the tabulation will find them.

      The logic is which values would yield missing if we pushed this string variable through real() to get a numeric variable?

      Problems often seen that cause otherwise numeric content to be imported as string include

      commas (if commas are decimal points, see the dpcomma option)

      NA or .. or some other unStataish convention to indicate missing

      metadata such as variable descriptors
      Last edited by Nick Cox; 16 Aug 2024, 03:45.

      Comment


      • #4
        Yes. I use ignore a lot more now, after having some data chuck full of it. Good advice and handy.

        Comment


        • #5
          The first version of destring arose when Stata introduced what is now the Data Editor. Many users typed header information into the first observation(s) and the Editor was predisposed to assume that a string variable was being entered. It was quite hard work to reverse that with the commands then available.

          It can still be hard work to find out why something numeric has been imported as string!

          Comment


          • #6
            I suspect a program could be created that would search a string variable for all non-numeric characters and tell you what those were, or even provide the proper "ignore" statement.

            Code:
            check_ignore stringvar
            
            When using destring, add:  ignore("," "$", "...")
            In fact, that sort of thing could be a frontend on destring to automate it. Or, a global could be created.

            Code:
            check_ignore stringvar
            
            destring stringvar, replace ignore($IGNORE)

            Comment


            • #7
              See #6 at https://www.statalist.org/forums/for...iable-problems for a program to find problematic string variables and document what inhibits destring.

              Comment


              • #8
                Code:
                clear
                input str10 X1
                "1,234"
                "$4,422"
                "z"
                end
                
                
                capture program drop destring_check
                program destring_check
                args var
                tempvar tv
                g `tv' = ustrregexra(`var', "[0-9]", "", .)
                
                global U
                forv i = 1/`=_N' {
                    local u = `tv'[`i']
                    global U $U `u'
                }
                
                *display "$U"
                local LU = "$U"
                *di "`LU'"
                local LU = subinstr("`LU'"," ","",.)
                *di "`LU'"
                
                // Loop through each character in the string
                local results ""
                forvalues i = 1/`:length local LU' {
                    local char = substr("`LU'", `i', 1)
                    *di "`char'"
                    // Add the character to result if it's not already there
                    if !strpos("`result'", "`char'") {
                        local result "`result' `char'"
                        *di "`result'"
                    }
                }
                // Display the result
                display "Include in unique: `result'"
                end
                destring_check X1

                Comment


                • #9
                  It would be nice if the result was:

                  Code:
                  Include in your destring as an option:  unique("," "$" "z")
                  but I couldn't figure it out.

                  Comment

                  Working...
                  X