Announcement

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

  • no observations

    Dear friends,

    I am trying to run univariable logistic regression model using the following

    . logistic x y

    and the response was

    no observations
    r(2000);

    but

    . tab x y

    gave me the table

    x is coded 0, 1 and y is sex coded as F and M

    Am I missing or doing something wrong, please?

    Aminu.

  • #2
    Please check whether you have a string variable. Also, you are supposed to have 0 and 1 for yvar. To end, we usually name y the DV, not the IV. I recommend to avoid misnamed variables, since this can lead to confusion. All in all, Stata will consider the first variable after - logistic - as yvar, no matter its name being x.
    Last edited by Marcos Almeida; 17 Jun 2018, 12:28.
    Best regards,

    Marcos

    Comment


    • #3
      The dependent and independent variables in most models must be numeric, not string. If your sex variable is indeed a string variable taking the values "M" and "F" you need to create a numeric variable with numeric values corresponding to "M" and "F". The easiest way to do that is using the encode command, see the output of help encode for details. Here is an example.
      Code:
      . clear
      
      . input str1 sex_str
      
             sex_str
        1. M
        2. F
        3. end
      
      . encode sex_str, generate(sex)
      
      . describe sex
      
                    storage   display    value
      variable name   type    format     label      variable label
      ------------------------------------------------------------------------------------------------
      sex             long    %8.0g      sex        
      
      . label list sex
      sex:
                 1 F
                 2 M
      
      . list
      
           +---------------+
           | sex_str   sex |
           |---------------|
        1. |       M     M |
        2. |       F     F |
           +---------------+
      
      . list, nolabel
      
           +---------------+
           | sex_str   sex |
           |---------------|
        1. |       M     2 |
        2. |       F     1 |
           +---------------+
      
      .

      Comment


      • #4
        x was coded (0,1) and sex (M,F). Month was coded (1-12); and it says the same thing when I ran the following for month

        . logistic x month

        no observations
        r(2000);

        Comment


        • #5
          Now both numeric but received the following output:

          . logistic paralysis sex
          outcome does not vary; remember:
          0 = negative outcome,
          all other nonmissing values = positive outcome
          r(2000);

          Comment


          • #6
            Here are tables for the variables:

            . tab sex

            Sex | Freq. Percent Cum.
            ------------+-----------------------------------
            F | 7,215 43.43 43.43
            M | 9,398 56.57 100.00
            ------------+-----------------------------------
            Total | 16,613 100.00

            . tab paralysis

            Flaccidsudd |
            enparalysis | Freq. Percent Cum.
            ------------+-----------------------------------
            0 | 118 0.71 0.71
            1 | 16,482 99.29 100.00
            ------------+-----------------------------------
            Total | 16,600 100.00

            Comment


            • #7
              The reason for the output in #5 is clearly stated by Stata itself. How could a predictive model be avented if the outcomes are the same?

              The old saying ‘know your data’ should prevail here.

              Please type - describe - and share the output. This way, it will become clear what happens to the variables.
              Last edited by Marcos Almeida; 17 Jun 2018, 12:50.
              Best regards,

              Marcos

              Comment


              • #8
                Dear Marcos,

                The table is disrupted when I copied and pasted here. Is there a way to make it organised before I can share, please?

                Kind regards,

                Aminu.

                Comment


                • #9
                  Please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. See especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], as described in section 12 of the FAQ.

                  Comment


                  • #10
                    To describe the data, it is not necessary to provide a table.

                    As I previously recommended and William underlined in #9, you just need to type - describe -,copy the output, open the code delimiters (click on the sign # in the upper right corner) and paste it between code delimiters.

                    Had you acted according the FAQ advice, you'd probably have already solved your doubts.
                    Best regards,

                    Marcos

                    Comment


                    • #11
                      Looking at posts 5 an 6, given how simple your model is, along with the description of your variables, you should post the results of
                      Code:
                      tab sex paralysis, missing nolabel
                      in a CODE block as well. I think the very few observations for which paralysis is 0 all have a missing value for sex.

                      Comment

                      Working...
                      X