nodes: 0, module; 1, function_definition; 2, function_name:runStickyEregressionsInStata; 3, parameters; 4, block; 5, identifier:infile_name; 6, identifier:interval_size; 7, identifier:meas_err; 8, identifier:sticky; 9, identifier:all_specs; 10, identifier:stata_exe; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, if_statement; 16, comment:# Define the command to run the Stata do file; 17, expression_statement; 18, comment:# Run Stata do-file; 19, expression_statement; 20, if_statement; 21, expression_statement; 22, comment:# Make results table and return it; 23, expression_statement; 24, return_statement; 25, string:'''
      Runs regressions for the main tables of the StickyC paper in Stata and produces a
      LaTeX table with results for one "panel". Running in Stata allows production of
      the KP-statistic, for which there is currently no command in statsmodels.api.
  
      Parameters
      ----------
      infile_name : str
          Name of tab-delimited text file with simulation data.  Assumed to be in
          the results directory, and was almost surely generated by makeStickyEdataFile
          unless we resort to fabricating simulated data.  THAT'S A JOKE, FUTURE REFEREES.
      interval_size : int
          Number of periods in each regression sample (or interval).
      meas_err : bool
          Indicator for whether to add measurement error to DeltaLogC.
      sticky : bool
          Indicator for whether these results used sticky expectations.
      all_specs : bool
          Indicator for whether this panel should include all specifications or
          just the OLS on lagged consumption growth.
      stata_exe : str
          Absolute location where the Stata executable can be found on the computer
          running this code.  Usually set at the top of StickyEparams.py.
  
      Returns
      -------
      panel_text : str
          String with one panel's worth of LaTeX input.
      '''; 26, assignment; 27, assignment; 28, assignment; 29, identifier:meas_err; 30, block; 31, else_clause; 32, assignment; 33, assignment; 34, comparison_operator:stata_status!=0; 35, block; 36, assignment; 37, assignment; 38, identifier:panel_text; 39, identifier:dofile; 40, string:"StickyETimeSeries.do"; 41, identifier:infile_name_full; 42, call; 43, identifier:temp_name_full; 44, call; 45, expression_statement; 46, block; 47, identifier:cmd; 48, list; 49, identifier:stata_status; 50, call; 51, identifier:stata_status; 52, integer:0; 53, raise_statement; 54, identifier:stata_output; 55, call; 56, identifier:panel_text; 57, call; 58, attribute; 59, argument_list; 60, attribute; 61, argument_list; 62, assignment; 63, expression_statement; 64, identifier:stata_exe; 65, string:"do"; 66, identifier:dofile; 67, identifier:infile_name_full; 68, identifier:temp_name_full; 69, call; 70, call; 71, attribute; 72, argument_list; 73, call; 74, attribute; 75, argument_list; 76, identifier:makeResultsPanel; 77, argument_list; 78, attribute; 79, identifier:abspath; 80, binary_operator:results_dir + infile_name + ".txt"; 81, attribute; 82, identifier:abspath; 83, binary_operator:results_dir + "temp.txt"; 84, identifier:meas_err_stata; 85, integer:1; 86, assignment; 87, identifier:str; 88, argument_list; 89, identifier:str; 90, argument_list; 91, identifier:subprocess; 92, identifier:call; 93, identifier:cmd; 94, keyword_argument; 95, identifier:ValueError; 96, argument_list; 97, identifier:pd; 98, identifier:read_csv; 99, identifier:temp_name_full; 100, keyword_argument; 101, keyword_argument; 102, keyword_argument; 103, keyword_argument; 104, keyword_argument; 105, keyword_argument; 106, keyword_argument; 107, keyword_argument; 108, keyword_argument; 109, keyword_argument; 110, keyword_argument; 111, identifier:os; 112, identifier:path; 113, binary_operator:results_dir + infile_name; 114, string:".txt"; 115, identifier:os; 116, identifier:path; 117, identifier:results_dir; 118, string:"temp.txt"; 119, identifier:meas_err_stata; 120, integer:0; 121, identifier:interval_size; 122, identifier:meas_err_stata; 123, identifier:shell; 124, string; 125, string; 126, identifier:sep; 127, string; 128, identifier:header; 129, integer:0; 130, identifier:Coeffs; 131, attribute; 132, identifier:StdErrs; 133, attribute; 134, identifier:Rsq; 135, attribute; 136, identifier:Pvals; 137, attribute; 138, identifier:OID; 139, attribute; 140, identifier:Counts; 141, attribute; 142, identifier:meas_err; 143, identifier:meas_err; 144, identifier:sticky; 145, identifier:sticky; 146, identifier:all_specs; 147, identifier:all_specs; 148, identifier:results_dir; 149, identifier:infile_name; 150, string_content:true; 151, string_content:Stata code could not run. Check the stata_exe in StickyEparams.py; 152, string_content:,; 153, identifier:stata_output; 154, identifier:CoeffsArray; 155, identifier:stata_output; 156, identifier:StdErrArray; 157, identifier:stata_output; 158, identifier:RsqArray; 159, identifier:stata_output; 160, identifier:PvalArray; 161, identifier:stata_output; 162, identifier:OIDarray; 163, identifier:stata_output; 164, identifier:ExtraInfo
code: def runStickyEregressionsInStata(infile_name,interval_size,meas_err,sticky,all_specs,stata_exe):
      '''
      Runs regressions for the main tables of the StickyC paper in Stata and produces a
      LaTeX table with results for one "panel". Running in Stata allows production of
      the KP-statistic, for which there is currently no command in statsmodels.api.
  
      Parameters
      ----------
      infile_name : str
          Name of tab-delimited text file with simulation data.  Assumed to be in
          the results directory, and was almost surely generated by makeStickyEdataFile
          unless we resort to fabricating simulated data.  THAT'S A JOKE, FUTURE REFEREES.
      interval_size : int
          Number of periods in each regression sample (or interval).
      meas_err : bool
          Indicator for whether to add measurement error to DeltaLogC.
      sticky : bool
          Indicator for whether these results used sticky expectations.
      all_specs : bool
          Indicator for whether this panel should include all specifications or
          just the OLS on lagged consumption growth.
      stata_exe : str
          Absolute location where the Stata executable can be found on the computer
          running this code.  Usually set at the top of StickyEparams.py.
  
      Returns
      -------
      panel_text : str
          String with one panel's worth of LaTeX input.
      '''
      dofile = "StickyETimeSeries.do"
      infile_name_full = os.path.abspath(results_dir + infile_name + ".txt")
      temp_name_full = os.path.abspath(results_dir + "temp.txt")
      if meas_err:
          meas_err_stata = 1
      else:
          meas_err_stata = 0
  
      # Define the command to run the Stata do file
      cmd = [stata_exe, "do", dofile, infile_name_full, temp_name_full, str(interval_size), str(meas_err_stata)]
  
      # Run Stata do-file
      stata_status = subprocess.call(cmd,shell = 'true')
      if stata_status!=0:
          raise ValueError('Stata code could not run. Check the stata_exe in StickyEparams.py')
      stata_output = pd.read_csv(temp_name_full, sep=',',header=0)
  
      # Make results table and return it
      panel_text = makeResultsPanel(Coeffs=stata_output.CoeffsArray,
                       StdErrs=stata_output.StdErrArray,
                       Rsq=stata_output.RsqArray,
                       Pvals=stata_output.PvalArray,
                       OID=stata_output.OIDarray,
                       Counts=stata_output.ExtraInfo,
                       meas_err=meas_err,
                       sticky=sticky,
                       all_specs=all_specs)
      return panel_text