Announcement

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

  • Error message "outcome does not vary; remember 0=negative outcome, all other nonmissing values=positive outcome"

    Hello,

    I have a binary variable that I called SRI. This variable equals 1 if an investor invests in an SRI fund, 0 otherwise. I ran a probit regression on the whole sample (which equals 1000). I also want to run a probit regression only on those who have invested in SRI funds (250 individuals), so I used this code probit SRI Envt Gender Age Education Financial_Knowledge if SRI==1. However I keep getting this error message "outcome does not vary; remember 0=negative outcome, all other nonmissing values=positive outcome".

    I do not have any missing values and my variables are coded 0 and 1 (not 1 and 2)

    Can someone help me with this?

    Thank you,
    Last edited by Serena Menny; 11 Nov 2022, 14:01.

  • #2
    I also want to run a probit regression only on those who have invested in SRI funds (250 individuals),
    This makes no sense. And the error message you are getting is self-explanatory: the outcome varible, SRI, is always 1 in the second regression, precisely because you have restricted it to only those observations with SRI == 1. You cannot learn anything about what is associated with investing in an SRI fund from a data subsample that only contains people who invested in one. All the information about those associations must come from an analysis of data including both investors and non-invesitors in SRI funds.

    Comment


    • #3
      t
      Last edited by Serena Menny; 11 Nov 2022, 14:16.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        This makes no sense. And the error message you are getting is self-explanatory: the outcome varible, SRI, is always 1 in the second regression, precisely because you have restricted it to only those observations with SRI == 1. You cannot learn anything about what is associated with investing in an SRI fund from a data subsample that only contains people who invested in one. All the information about those associations must come from an analysis of data including both investors and non-invesitors in SRI funds.
        Thank you Clyde Schechter for your reply!
        Doesn't this regression "probit SRI Envt Gender Age Education Financial_Knowledge" give results for the whole sample? How can I know the SRI investors characteristics in this case?

        Comment


        • #5
          Doesn't this regression "probit SRI Envt Gender Age Education Financial_Knowledge" give results for the whole sample?
          Yes, sort of. If you are getting the "outcome does not vary" message here, then the problem may be different. First, you should verify that your data set really does have some observations with SRI == 0:
          Code:
          count if SRI == 0
          If that count is 0, then something went wrong in the creation of your data set so that you ended up without any SRI non-investors at all. You need to review the data management that created the data set, figure out how that happened, and fix the error(s) you find.

          But there is another possibility. Maybe you do have some SRI non-investors in the data set. But in order for any observation to enter any regression, all of the variables in the regression must be non-missing. It may be that when you restrict to the observations with no missing values, all of the SRI non-investors evaporate. Try this:

          Code:
          count if SRI == 0 & !missing(Envt ,Gender, Age, Education, Financial_Knowledge)
          

          If that count turns out zero, then that confirms that this is the problem. And while that might reflect a problem in the data management that created the data set, it may very well just be that the pattern of missing values in the data worked against you. In that case, you need to either get a new data set, or find some way to fill in the missing values of those variables.

          If the count from the last code is not zero, then another possibility is that one of those variables is a string variable in your data set. You can tell that with:
          Code:
          ds SRI Envt Gender Age Education Financial_Knowledge, has(type string)
          If your data are correct, there should be no output at all from that command. If you see any output, it will name the variable(s) that is(are) string(s). You then need to convert those to numeric in the appropriate way. Be careful when you do that: some variables need to be converted with -encode- and others with -destring-. Make sure you read the PDF manual sections on both of those commands and understand the differences between them, and which to use when, before proceeding. If unsure, post back with example data, using the -dataex- command for additional assistance. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data. (Note: in your particular situation, -dataex- is the only way to show the data that will provide the information needed to help you. So don't bother wasting your time, or anybody else's, showing -list- output, or a screenshot, or anything else. Use -dataex- and only -dataex-.)

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            Yes, sort of. If you are getting the "outcome does not vary" message here, then the problem may be different. First, you should verify that your data set really does have some observations with SRI == 0:
            Code:
            count if SRI == 0
            If that count is 0, then something went wrong in the creation of your data set so that you ended up without any SRI non-investors at all. You need to review the data management that created the data set, figure out how that happened, and fix the error(s) you find.

            But there is another possibility. Maybe you do have some SRI non-investors in the data set. But in order for any observation to enter any regression, all of the variables in the regression must be non-missing. It may be that when you restrict to the observations with no missing values, all of the SRI non-investors evaporate. Try this:

            Code:
            count if SRI == 0 & !missing(Envt ,Gender, Age, Education, Financial_Knowledge)
            

            If that count turns out zero, then that confirms that this is the problem. And while that might reflect a problem in the data management that created the data set, it may very well just be that the pattern of missing values in the data worked against you. In that case, you need to either get a new data set, or find some way to fill in the missing values of those variables.

            If the count from the last code is not zero, then another possibility is that one of those variables is a string variable in your data set. You can tell that with:
            Code:
            ds SRI Envt Gender Age Education Financial_Knowledge, has(type string)
            If your data are correct, there should be no output at all from that command. If you see any output, it will name the variable(s) that is(are) string(s). You then need to convert those to numeric in the appropriate way. Be careful when you do that: some variables need to be converted with -encode- and others with -destring-. Make sure you read the PDF manual sections on both of those commands and understand the differences between them, and which to use when, before proceeding. If unsure, post back with example data, using the -dataex- command for additional assistance. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data. (Note: in your particular situation, -dataex- is the only way to show the data that will provide the information needed to help you. So don't bother wasting your time, or anybody else's, showing -list- output, or a screenshot, or anything else. Use -dataex- and only -dataex-.)
            Thank you soo much!!! I had a "string" problem. Now it is fixed and I can run my regression. Your help is much appreciated. Thank you!

            Comment

            Working...
            X