Announcement

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

  • Question on How to Write Add in Conditions for a Regression

    Hello,
    I need to run some regressions in Stata with a few conditions. I am examining data on incentive contracts in baseball and their impact on player performance. I want to run a regression to determine: (a) whether a player having incentives in their contract is impacted by a few variables, such as player position, age, whether they've had a major injury, and variance in the years before signing a contract (b) if certain player statistics were impacted by having incentives in their contract, and (c) whether player earnings increased by having incentives in their contract. A basic example of how my data is structured is below:
    Player Position Age Major Injury Offseason Year Contract Signed Contract Years Contract Amount Incentives in Contract 2015 Incentives in Contract 2016 Incentives in Contract 2017 Incentives in Contract 2018 Incentives in Contract 2019
    Max Scherzer 1 30 0 2015 7 210000000 1 1 1 1 1


    Player Year Games Started ERA WAR
    Max Scherzer 2012 33 3.74 4.4
    Max Scherzer 2013 32 2.90 6.5
    Max Scherzer 2014 33 3.15 5.8
    Max Scherzer 2015 33 2.79 6.9
    Max Scherzer 2016 34 2.96 6.2
    Max Scherzer 2017 31 2.51 7.2
    Max Scherzer 2018 33 2.53 8.4
    Max Scherzer 2019 27 2.92 5.5

    So in the first regression, I want to basically examine some of the columns in the first table along with some data in the second table before the contract was signed. In the second regression, I want to examine the statistics after the contract was signed. Does anyone have any idea how to add in these conditions? I think I have sufficiently merged the data.

  • #2
    When the two data are properly saved as .dta format, the example code below should work.

    Code:
    use data_below, clear
    merge m:1 player using data_above
    
    bys player (year): gen inc_in_contr = (year  >= offseason_year_contract_signed)
    The code above assumes players will always have incentives after signing the contract. The new variable "inc_in_contr" (0 or 1) indicates whether players have incentives. You may do further analysis using proper -if- conditions with "inc_in_contr".

    Comment


    • #3
      As already flagged in your previous thread

      https://www.statalist.org/forums/for...-merging-files

      you are asked to tell us about cross-posting, here at https://www.reddit.com/r/stata/comme...ions_in_stata/

      The policy is flagged at https://www.statalist.org/forums/help#crossposting -- which is included in the advice all members are asked to read before posting.

      I've seen comments on the web that cross-posting in different places without mentioning the fact is offensive to all the communities concerned, as implying that you don't care about any duplication of effort and that you don't trust any community to come up with a decent answer. Thoughtless rather than offensive, I would say, but know that such opinions do exist.

      Comment


      • #4
        Hello Mr. Cox,
        I am new to this forum so I apologize if I violated any guidelines. I had asked an earlier question about merging Stata files, and upon successfully doing that, I had another question about how I could possibly run a regression on this file, so I apologize if I should have continued asking that question in that thread. I also asked a more general question about if conditions in regressions on Reddit, but I figured I should provide more detail on my question and posted here. I didn't mean to offend anyone and appreciate any help for the question I asked.
        Last edited by sladmin; 16 Nov 2021, 07:36. Reason: anonymize original poster

        Comment


        • #5
          Thanks for your polite reply. However, I am not clear that you're quite getting the (small) point. When you started posting on Statalist you were asked to read the FAQ Advice. You posted the question in your first thread also on Reddit and then Leonardo Guizzetti underlined our request (which is in the FAQ Advice) to tell us about cross-posting. Your second thread here was also cross-posted on Reddit with no cross-reference. Cross-posting doesn't have mean identical posts.

          This is not about posting two separate threads here on Statalist, which is completely in order for different questions.

          Being new here is fine too, but precisely why it is a good idea to do as we ask and study the FAQ Advice.

          Comment

          Working...
          X