Announcement

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

  • CART.ado program error

    I am trying to use the 'CART' module to perform Classification And Regression Tree analysis,
    package cart from http://fmwww.bc.edu/RePEc/bocode/c
    I am getting a "program error: matching close brace not found r(198);" error each time I try to run it.

    Here I what I have tried:
    I opened up the cart.ado file and hand checked that all the braces are properly closed.

    I see that cart.ado is declaring version 7, and I am running Stata SE 14.2 for Mac.
    So I read https://www.stata.com/support/faqs/p...stata-version/
    I tried to run the cart command preceded by
    version 7: cart prediction_model, fail(sk_ca) time(tptime)
    and got the same error.

    I also tried to update cart.ado file to declare version 14.2 for both cart.ado and carts.ado (a subroutine called by cart)
    and got the same error.

    Does anyone have any ideas for what I might try next?

    Thanks,
    Sarah

  • #2
    Is it the case that the command you ran was exactly
    Code:
    cart prediction_model, fail(sk_ca) time(tptime)
    where prediction_model, sk_ca, and tptime are three variables in your dataset? Or was this perhaps an abbreviation of a more complicated command?

    Grasping at straws here, you don't happen to accidentally have a cart.ado - perhaps one you were editing - installed somewhere other than in what Stata identifies as your PLUS directory?
    Code:
    . sysdir
       STATA:  /Applications/Stata/
        BASE:  /Applications/Stata/ado/base/
        SITE:  /Applications/Stata/ado/site/
        PLUS:  /Users/lisowskiw/Library/Application Support/Stata/ado/plus/
    PERSONAL:  /Users/lisowskiw/Library/Application Support/Stata/ado/personal/
    OLDPLACE:  ~/ado/
    
    . which cart
    /Users/lisowskiw/Library/Application Support/Stata/ado/plus/c/cart.ado
    *!cart.ado WvP ,  20/5/2002
    *!first version 6/4/98
    *!id() option added to save identifier in _CART.dta
    *!carts.ado Subroutine called by CART
    *!CART analysis performs the searching within a group for optimal cutpoint and best covariate 
    *!tree.ado   Subroutine for CART. 
    *!10/4/98 -> 5/8/98

    Comment


    • #3
      The command I ran was exactly
      Code:
      . cart prediction_model, fail(sk_ca) time(tptime)
      where prediction_model is my predictor variable, sk_ca is my binary failure variable, and tptime is my time to event variable.

      which results in
      program error: matching close brace not found
      r(198);

      I don't find any another cart.ado, and I was very careful when trying edits. My path looks like yours:

      Code:
      . sysdir
         STATA:  /Applications/Stata 14/
          BASE:  /Applications/Stata 14/ado/base/
          SITE:  /Applications/Stata 14/ado/site/
          PLUS:  ~/Library/Application Support/Stata/ado/plus/
      PERSONAL:  ~/Library/Application Support/Stata/ado/personal/
      OLDPLACE:  ~/ado/
      
      . which cart
      /Users/Sarah/Library/Application Support/Stata/ado/plus/c/cart.ado
      *!cart.ado WvP ,  20/5/2002
      *!first version 6/4/98
      *!id() option added to save identifier in _CART.dta
      *!carts.ado Subroutine called by CART
      *!CART analysis performs the searching within a group for optimal cutpoint and best covariate
      *!tree.ado   Subroutine for CART.
      *!10/4/98 -> 5/8/98
      Any other ideas?

      Comment


      • #4
        I have ideas, but their value is at best indeterminate.

        I assume that following your editing, you reverted to a clean installation of the latest version of the cart command.
        Code:
        . ssc uninstall cart
        
        package cart from http://fmwww.bc.edu/RePEc/bocode/c
              'CART': module to perform Classification And Regression Tree analysis
        
        (package uninstalled)
        
        . ssc install cart
        checking cart consistency and verifying not already installed...
        installing into /Users/lisowskiw/Library/Application Support/Stata/ado/plus/...
        installation complete.
        The documentation for CART is ... sparse, lacking even an example to run. So I made up a meaningless example and it worked, where "worked" means no more than "ran with no syntax errors". You might try the same test. This output in the Results window was accompanied by the graph of a regression tree with two limbs.
        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . cart weight, time(price) fail(foreign)
        CARTi=1  , CARTn=1 
        Group 1,Level 0 ,Number 74
        CARTi=1  , CARTn=2 
        Group 1,Level 1 ,Number 52
        CARTi=2  , CARTn=2 
        Group 2,Level 1 ,Number 22
        
        CART history:
        
            group   level   from   order           varnr    val        mima   dec    chi2   pnom   padj    n    f      e      hr    rhr   last  
                1       1      1       1   Weight (lbs.)   2410   2520-4840     0   49.89   0.00   0.00   52    6   18.3    0.07   0.33      1  
                2       1      1       3   Weight (lbs.)   2410   1760-2410     0   49.89   0.00   0.00   22   16    3.7   13.36   4.37      1  
        
        CART end groups:
        
        **** if last==1
        
            group   level   from   order           varnr    val        mima   dec    chi2   pnom   padj    n    f      e      hr    rhr  
                1       1      1       1   Weight (lbs.)   2410   2520-4840     0   49.89   0.00   0.00   52    6   18.3    0.07   0.33  
                2       1      1       3   Weight (lbs.)   2410   1760-2410     0   49.89   0.00   0.00   22   16    3.7   13.36   4.37  
        
        Ranges of variables:
        
                   |  CART group number 
                   |   1    2 |Total 
        -----------+----------+----
        Weight (lbs.)
          Number   |  52   22 |  74 
          Minimum  |2520 1760 |1760 
          Maximum  |4840 2410 |4840
        You mentioned cart.ado and carts.ado. I'm not encouraging you to do any further editing, but I want to point out that there are several other ado files installed by cart.
        Code:
        . ssc describe cart
        
        ...
              
              Distribution-Date: 20061017
              
              Author: Wim van Putten, Erasmus MC - Daniel den Hoed Cancer Center
              Support: email [email protected]
              
        
        INSTALLATION FILES                                 (type net install cart)
              cart.ado
              cart.hlp
              carts.ado
              change.ado
              change.hlp
              cvar.ado
              cvar.hlp
              ../e/eformat.ado
              ../e/eformat.hlp
              ../f/fns.ado
              ../f/fns.hlp
              ../l/ljust.ado
              ../l/ljust.hlp
              ../q/qlist.ado
              ../q/qlist.hlp
              ../s/sumby.ado
              ../s/sumby.hlp
              ../t/tabby.ado
              ../t/tabby.hlp
              ../t/tree.ado
              ../t/ttitle.ado
              ../u/uc.ado
        I mention that to keep in mind if you try my next suggestion.

        Are you familiar with using the trace command to see the details of do-file execution? If not, take a look at the output of help trace to get the idea. Here is what I would try.
        Code:
        set tracedepth 1
        set trace on
        cart prediction_model, fail(sk_ca) time(tptime)
        set trace off
        If you're lucky, this will allow you to determine where Stata is throwing the error message. If you're less lucky, it will turn out to be within one of the subsidiary ado files, in which case you will increase tracedepth to 2 and try again, continuing to increase tracedepth until the source of the error is apparent.

        Eventually you should be able to determine where the error is arising, and perhaps be able to take action to correct the problem.

        It should be obvious that I am grasping at straws here, but perhaps something here will prove helpful. Your problem is inexplicable to me; I went to the effort of running each ado file in the list above manually, and in no case did I get the error you did, which I would expect to be a "compile-time" error.

        Note also that the author's email address is given above in the output from ssc describe cart. Perhaps it is still good 11 years after the last program update.

        Do let Statalist know what happens.

        Comment


        • #5
          Thanks for all the advice. I did try emailing the author a while back and didn't get a reply.

          The good news is after a lot of testing I found the hangup- Cart can't handle a time to event value less than 0, even though the documentation suggests it will left-censor those values in the same way a Cox regression would. If I drop cases where the time to event is negative (occurring prior to entry), Cart runs to completion. So future users of Cart beware! you need to left-censor your data manually.

          Sarah

          Comment


          • #6
            Thank you for closing the loop on this, and documenting the fix. Since the Statalist archive is searchable, this warning may indeed help future users.

            Comment

            Working...
            X