Announcement

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

  • error: factor variables and time-series operators are not allowed

    I am trying to use nlsur (Non-Linear SUR) for a system of five equations to find out price flexibility. I followed the examples in the stata manual and Stata publication by Poi 2008 to code my program. However, in the examples, they all used only price, quantity variables. I am trying to include some seasonal variables to control for any effect of season on the quantity harvested and included as factor variables. When I ran the program, it proceeds the process fine, but when I call the program for evaluating the coefficients, I got an error saying that: factor variables and time-series operators are not allowed. I browsed for any help online and I found a FAQ from Stata for dealing such errors. The FAQ explains that from version 11 or higher sometimes Stata wont recognize time and factor variables and therefore suggested to use fv in syntax statement, but the effort was in vain. Can anybody help me figure out what is the real problem that I am facing?

    capture program drop nlsuriaidsq
    program nlsuriaidsq

    version 11
    syntax varlist(min=34 max=34 ts fv) if, at(name)

    tokenize `varlist'
    args dep_var1 dep_var2 dep_var3 dep_var4 q_1 q_2 q_3 q_4 q_5 inc lagq_1 lagq_2 lagq_3 lagq_4 lagq_5 feb mar apr may jun jul aug sep oct nov dec tksgvng xmas

    tempname a1 a2 a3 a4 a5
    scalar `a1' = `at'[1,1]
    scalar `a2' = `at'[1,2]
    scalar `a3' = `at'[1,3]
    scalar `a4' = `at'[1,4]
    scalar `a5' = 1-`a1'-`a2'-`a3'-`a4'
    .....................
    Thanks
    Pratheesh

  • #2
    You have given us some of your program. You have not shown any of the code you used to try to run it. That creates an unanswerable question, as we can't easily expand on the error message you report.

    Comment


    • #3
      Hai Nick
      Thanks for the feedback. My program was so long and that makes me reluctant to include all the codes. I am copying my codes below.
      capture program drop nlsuriaidsq
      program nlsuriaidsq

      version 11
      syntax varlist(min=34 max=34 ts fv) if, at(name)

      tokenize `varlist'
      args dep_var1 dep_var2 dep_var3 dep_var4 q_1 q_2 q_3 q_4 q_5 lagq_1 lagq_2 lagq_3 lagq_4 lagq_5 feb mar apr may jun jul aug sep oct nov dec tksgvng xmas

      tempname a1 a2 a3 a4 a5
      scalar `a1' = `at'[1,1]
      scalar `a2' = `at'[1,2]
      scalar `a3' = `at'[1,3]
      scalar `a4' = `at'[1,4]
      scalar `a5' = 1-`a1'-`a2'-`a3'-`a4'

      tempname b1 b2 b3 b4 b5
      scalar `b1'= `at'[1,5]
      scalar `b2'= `at'[1,6]
      scalar `b3'= `at'[1,7]
      scalar `b4'= `at'[1,8]
      scalar `b5'= -`b1'-`b2'-`b3'-`b4'

      tempname g11 g12 g13 g14 g15
      tempname g21 g22 g23 g24 g25
      tempname g31 g32 g33 g34 g35
      tempname g41 g42 g43 g44 g45
      tempname g51 g52 g53 g54 g55

      scalar `g11' = `at'[1,9]
      scalar `g12' = `at'[1,10]
      scalar `g13' = `at'[1,11]
      scalar `g14' = `at'[1,12]
      scalar `g15' = -`g11'-`g12'-`g13'-`g14'

      scalar `g21' = `g12'
      scalar `g22' = `at'[1,13]
      scalar `g23' = `at'[1,14]
      scalar `g24' = `at'[1,15]
      scalar `g25' = -`g21'-`g22'-`g23'-`g24'

      scalar `g31' = `g13'
      scalar `g32' = `g23'
      scalar `g33' = `at'[1,16]
      scalar `g34' = `at'[1,17]
      scalar `g35' = -`g31'-`g32'-`g33'-`g34'

      scalar `g41' = `g14'
      scalar `g42' = `g24'
      scalar `g43' = `g34'
      scalar `g44' = `at'[1,18]
      scalar `g45' = -`g41'-`g42'-`g43'-`g44'

      scalar `g51' = `g15'
      scalar `g52' = `g25'
      scalar `g53' = `g35'
      scalar `g54' = `g45'
      scalar `g55' = -`g51'-`g52'-`g53'-`g54'

      tempname v1 v2 v3 v4 v5
      scalar `v1' = `at'[1,19]
      scalar `v2' = `at'[1,20]
      scalar `v3' = `at'[1,21]
      scalar `v4' = `at'[1,22]
      scalar `v5' = -`v1'-`v2'-`v3'-`v4'

      tempname m11 m12 m13 m14 m15 m16 m17 m18 m19 m110 m111
      tempname m21 m22 m23 m24 m25 m26 m27 m28 m29 m210 m211
      tempname m31 m32 m33 m34 m35 m36 m37 m38 m39 m310 m311
      tempname m41 m42 m43 m44 m45 m46 m47 m48 m49 m410 m411
      tempname m51 m52 m53 m54 m55 m56 m57 m58 m59 m510 m511

      scalar `m11' = `at'[1,23]
      scalar `m12' = `at'[1,24]
      scalar `m13' = `at'[1,25]
      scalar `m14' = `at'[1,26]
      scalar `m15' = `at'[1,27]
      scalar `m16' = `at'[1,28]
      scalar `m17' = `at'[1,29]
      scalar `m18' = `at'[1,30]
      scalar `m19' = `at'[1,31]
      scalar `m110'= `at'[1,32]
      scalar `m111'= `at'[1,33]

      scalar `m21' = `at'[1,34]
      scalar `m22' = `at'[1,35]
      scalar `m23' = `at'[1,36]
      scalar `m24' = `at'[1,37]
      scalar `m25' = `at'[1,38]
      scalar `m26' = `at'[1,39]
      scalar `m27' = `at'[1,40]
      scalar `m28' = `at'[1,41]
      scalar `m29' = `at'[1,42]
      scalar `m210'= `at'[1,43]
      scalar `m211'= `at'[1,44]

      scalar `m31' = `at'[1,45]
      scalar `m32' = `at'[1,46]
      scalar `m33' = `at'[1,47]
      scalar `m34' = `at'[1,48]
      scalar `m35' = `at'[1,49]
      scalar `m36' = `at'[1,50]
      scalar `m37' = `at'[1,51]
      scalar `m38' = `at'[1,52]
      scalar `m39' = `at'[1,53]
      scalar `m310'= `at'[1,54]
      scalar `m311'= `at'[1,55]

      scalar `m41' = `at'[1,56]
      scalar `m42' = `at'[1,57]
      scalar `m43' = `at'[1,58]
      scalar `m44' = `at'[1,59]
      scalar `m45' = `at'[1,60]
      scalar `m46' = `at'[1,61]
      scalar `m47' = `at'[1,62]
      scalar `m48' = `at'[1,63]
      scalar `m49' = `at'[1,64]
      scalar `m410'= `at'[1,65]
      scalar `m411'= `at'[1,66]

      scalar `m51' = -`m11'-`m21'-`m31'-`m41'
      scalar `m52' = -`m12'-`m22'-`m32'-`m42'
      scalar `m53' = -`m13'-`m23'-`m33'-`m43'
      scalar `m54' = -`m14'-`m24'-`m34'-`m44'
      scalar `m55' = -`m15'-`m25'-`m35'-`m45'
      scalar `m56' = -`m16'-`m26'-`m36'-`m46'
      scalar `m57' = -`m17'-`m27'-`m37'-`m47'
      scalar `m58' = -`m18'-`m28'-`m38'-`m48'
      scalar `m59' = -`m19'-`m29'-`m39'-`m49'
      scalar `m510' = -`m110'-`m210'-`m310'-`m410'
      scalar `m511' = -`m111'-`m211'-`m311'-`m411'

      tempname n11 n12
      tempname n21 n22
      tempname n31 n32
      tempname n41 n42
      tempname n51 n52

      scalar `n11' = `at'[1,67]
      scalar `n12' = `at'[1,68]
      scalar `n21' = `at'[1,69]
      scalar `n22' = `at'[1,70]
      scalar `n31' = `at'[1,71]
      scalar `n32' = `at'[1,72]
      scalar `n41' = `at'[1,73]
      scalar `n42' = `at'[1,74]
      scalar `n51' = -`n11'-`n21'-`n31'-`n41'
      scalar `n52' = -`n12'-`n22'-`n32'-`n42'

      quietly {
      tempvar lnQ
      gen double `lnQ' = 5+ `a1'*`q_1'+`a2'*`q_2'+`a3'*`q_3'+`a4'*`q_4'+`a5'*` q_5'

      forvalues i= 1/5 {
      forvalues j= 1/5 {
      replace `lnQ' = `lnQ' + 0.5*`g`i'`j''*`lnq`i''*`lnq`j''
      }
      }
      replace `dep_var1' = `a1'+`g11'*`q_1'+`g12'*`q_2'+`g13'*`q_3' +`g14'*`q_4'+`g15'*`q_5'+`b1'*`lnQ'+`v1'*` lagq_1'+`m11'*`feb'+`m12'*`mar'+`m13'*`apr'+`m14 '*`may'+`m15'*`jun'+`m16'*`jul'+`m17'*`aug'+`m18'* `sep'+`m19'*`oct'+`m110'*`nov'+`m111'*`dec'+`n11'* `tksgvng'+`n12'*`xmas'

      replace `dep_var2 = `a2'+`g21'*`q_1'+`g22'*`q_2'+`g23'*`q_3' +`g24'*`q_4'+`g25'*`q_5'+`b2'*`lnQ'+`v2'*` lagq_2'+`m21'*`feb'+`m22'*`mar'+`m23'*`apr'+`m24' *`may'+`m25'*`jun'+`m26'*`jul'+`m27'*`aug'+`m28'*` sep'+`m29'*`oct'+`m210'*`nov'+`m211'*`dec'+`n21'*` tksgvng'+`n22'*`xmas'

      replace `dep_var3' = `a3'+`g31'*`q_1'+`g32'*`q_2'+`g33'*`q_3' +`g34'*`q_4'+`g35'*`q_5'+`b3'*`lnQ'+`v3'*` lagq_3'+`m31'*`feb'+`m32'*`mar'+`m33'*`apr'+`m34' *`may'+`m35'*`jun'+`m36'*`jul'+`m37'*`aug'+`m38'*` sep'+`m39'*`oct'+`m310'*`nov'+`m311'*`dec'+`n31'*` tksgvng'+`n32'*`xmas'

      replace `dep_var4' = `a4'+`g41'*`q_1'+`g42'*`q_2'+`g43'*`q_3' +`g44'*`q_4'+`g45'*`q_5'+`b4'*`lnQ'+`v4'*` lagq_4'+`m41'*`feb'+`m42'*`mar'+`m43'*`apr'+`m44 '*`may'+`m45'*`jun'+`m46'*`jul'+`m47'*`aug'+`m48'* `sep'+`m49'*`oct'+`m410'*`nov'+`m411'*`dec'+`n41'* `tksgvng'+`n42'*`xmas'

      }
      end

      use C:\Users\Pratheesh\Documents\Stata\OysterDemand\an alysis\data\iaidsdat.dta

      nlsur aids @ dep_var1 dep_var2 dep_var3 dep_var4 q_1 q_2 q_3 q_4 q_5 lagq_1 lagq_2 lagq_3 lagq_4 lagq_5 feb mar apr may jun jul aug sep oct nov dec tksgvng xmas
      parameters(a1 a2 a3 a4 b1 b2 b3 b4 g11 g12 g13 g14 g22 g23 g24 g33 g34 g44 v1 v2 v3 v4 m11 m12 m13 m14 m15 m16 m17 m18 m19 m110 m111 m21 m22 m23 m24 m25 m26 m27 m28 m29 m210 m211 m31 m32 m33 m34 m35 m36 m37 m38 m39 m310 m311 m41 m42 m43 m44 m45 m46 m47 m48 m49 m410 m411 n11 n12 n21 n22 n31 n32 n41 n42)
      neq(4) ifgnls


      Thanks
      Pratheesh
      Last edited by Pratheesh Omana-Sudhakaran; 19 Aug 2014, 17:44.

      Comment


      • #4
        You need a comma before the parameters() call. Your own program name doesn't match what you say in calling nlsur.

        There may well be other problems, but those details look problematic to me.

        Incidentally, Prathubfsc99 doesn't match our request for full real names.

        Comment


        • #5
          Hai Nick
          Thanks for the suggestion. I am Pratheesh Omana-Sudhakaran. Prathubfsc99 is my user name and I didnt find any place to include my full name. I again went to profile setting, but couldnt find columns for entering my name. Meanwhile I will work on your suggestions.
          Thanks
          Pratheesh

          Comment


          • #6
            Dear Pratheesh: welcome to Statalist! You can change your login name to "Pratheesh Omana-Sudhakaran" relatively easily (which would be good, and consistent with Forum etiquette as set out in the FAQ - that's what Nick is alluding to). Just hit the "Contact Us" button at the bottom right hand side of the screen, and make your request. Responses are typically fast. [BTW The names preferred on Statalist are your real name, rather than a "user name" that you might use on a local computer network.] thanks

            Comment

            Working...
            X