Announcement

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

  • How to solve factor variables may not contain noninteger values?

    I am a student and I am doing my assignment. Can someone help me out? I really appreciate your help.
    Click image for larger version

Name:	QQ图片20180115121127.png
Views:	1
Size:	39.1 KB
ID:	1425769


    The variable length is too long, therefore, when I use Stata command. The result shows this problem?
    Click image for larger version

Name:	QQ图片20180115121328.png
Views:	1
Size:	32.4 KB
ID:	1425770



  • #2
    Wenbin:
    as this is not your first post, as per FAQ you are supposed to know the forum policy about class/home assignments: please do not ask, please do not reply.
    However, as you challenged yourself first and ask for a well-definied issue, I would reply to your query.
    Whenever you have noninteger values, you actually do not have a factor variables.
    Hence, your code (I shy away here from any comments concerning the meaning/goal of your statistical approach) should be:
    Code:
    reg c.uhat A386
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      I wonder if Wenbin has confused the number one with the letter l: they look very similar, of course.

      If 1.uhat were allowed, it would be an indicator (dummy) variable taking on the value 1 when uhat == 1 and 0 otherwise. Looking at the values of uhat shown, it seems likely that there would be very few, if any, observations with uhat == 1. I wonder if Wenbin is trying to regress uhat against its first lag. The notation would be l.hat, with the letter ell, not the number 1. And it would run just fine assuming the data has been properly -xtset- or -tsset-.

      Code:
      . webuse grunfeld, clear
      
      . xtset company year
             panel variable:  company (strongly balanced)
              time variable:  year, 1935 to 1954
                      delta:  1 year
      
      . regress mvalue l.mvalue // LETTER L (LAG OPERATOR), NOT NUMBER 1
      
            Source |       SS           df       MS      Number of obs   =       190
      -------------+----------------------------------   F(1, 188)       =   2137.01
             Model |   307252594         1   307252594   Prob > F        =    0.0000
          Residual |  27030034.8       188  143776.781   R-squared       =    0.9191
      -------------+----------------------------------   Adj R-squared   =    0.9187
             Total |   334282629       189  1768691.16   Root MSE        =    379.18
      
      ------------------------------------------------------------------------------
            mvalue |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
            mvalue |
               L1. |    .985079   .0213092    46.23   0.000      .943043    1.027115
                   |
             _cons |   54.30588   35.63359     1.52   0.129    -15.98717    124.5989
      ------------------------------------------------------------------------------
      In addition to Carlo's reminder that the posting of homework assignments here is strongly discouraged, I will pile on with a reminder the showing example data by screenshots is also strongly discouraged. Were it necessary to import the data to Stata to test out code on it to solve your problem, it would not be possible from a screenshot.

      Please read the Forum FAQ to familiarize yourself with the guidelines for effective use of this forum. The guidelines are there to help you ask clear questions and to display information in ways that make it easy for those who want to help you to make use of it. Read them, and please follow them, going forward.

      Comment

      Working...
      X