Announcement

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

  • Issue running xtreg commands with scalar

    I am using Stata version 15.1 and I have 47 variables and 1,010 observations in my dataset. I am doing educational research with 112 colleges included.

    I am trying to run scalar code to have some of my comparisons come right up as my command is run. This being the case I did some research and understood that scalar commands were able to deliver this solution. However, I am concerned that there is an issue with the panel commands as I use xtset and xtreg.

    My commands are below:

    xtreg log_total_stu_less_than_30000 ///
    ///
    log_net_price_less_than_30000 ///
    ///
    log_avg_tuition_fees_ft ///
    ///
    endowment_beg composite_financial_index number_admitted unemployment ///
    ///
    ,fe
    *Extract the Coefficient to make the output cleaner and more clear then add display text to make the results easier to digest
    scalar beta_Log_net_price_less_than_30000 =_b[Log_net_price_less_than_30000]
    display "A 1% increase in the discount for students in this income range is associated with " beta_Log_net_price_less_than_30000 " % increase in student enrollment for this income range"
    display "A 5% increase in the discount for students in this income range is associated with " beta_Log_net_price_less_than_30000*5 " % increase in student enrollment for this income range"
    display "A 15% increase in the discount for students in this income range is associated with " beta_Log_net_price_less_than_30000*15 " % increase in student enrollment for this income range"
    I reviewed the xtreg handbook from Stata and I see on page 26 that the coefficient command is listed under the matrices section as follows - "e(b) coefficient vector" The manual I am referencing is located here. I feel like the solution is here or related to a code modification of this, but I am still a bit lost on how this should be incorporated into the code or why my scalar command is not working as planned and how to adjust to get the scalar to work with my data.

  • #2
    What exactly is your question? The code you show looks OK. Is it producing results you doubt? If so, what is it about them that seems wrong? What is the issue?

    I will say this: the widespread use of the coefficient in a log-log regression as the estimate is based on an approximation that is only valid when the coefficient is small--it's a decent approximation when the coefficient is < 0.1, but deteriorates rapidly as you go above that. Even if the coefficient itself is small, when you start multiplying by 5 and 15, it may not be any longer. So that may be a problem for you, but it doesn't seem like that's what you're asking about.

    Comment


    • #3
      Clyde,

      I really appreciate you taking the time to look at this. The error message I am getting is below.

      . *Extract the Coefficient to make the output cleaner and more clear then add display text to make the results easier to digest
      . scalar beta_Log_net_price_less_than_30000 =_b[Log_net_price_less_than_30000]
      beta_Log_net_price_less_than_30000 invalid name
      r(198);
      As I said before I am a bit unsure how to resolve this and I would really appreciate your insight. I will also keep in mind your suggestion about multiplying when the coefficient is less than <.1. Thank you for your feedback and consideration of helping me with my issue.

      Comment


      • #4
        Ah, I didn't spot the problem before: if you had shown the specific error message, we would not have wasted our time. When asking for help troubleshooting code, always show the exact output you are getting, including any error messages.

        The problem is simply that beta_Log_net_price_less_than_30000 is 34 characters long, and the maximum allowable length for the name of a scalar is 32 characters. So you need to pick a shorter name. Maybe beta_log_net_price_lt_30000 would be good. Or, if you don't like lt for less than, maybe b instead of beta.

        Comment


        • #5
          Thank you very much, Clyde! That was an embarrassingly simple solution and I very much appreciate your feedback and the time you took to work through my question. As far as me including this in the first place you are right of course. I will make sure I remember to include that in the future.

          Comment

          Working...
          X