Beispiel #1
0
   def get_modindices(self, delta=0.1, alpha = 0.05, multigroup=True):
      """
         Read the modification indices from the file,
         and calculate the power of the score test.
      """
      self.starting_string = re.compile("^MODEL MODIFICATION INDICES")
      self.stopping_string = re.compile('^TECHNICAL \d OUTPUT')

      in_block       = False
      critical = distributions.qchisq(1, alpha) # critical value for alpha level
      
      statement_string = re.compile('^[\[]*([\w ]+\w+)[ \]]+([-]*\d+\.\d+)[ ]+([-]*\d+\.\d+)[ ]+([-]*\d+\.\d+)[ ]+([-]*\d+\.\d+)')
      if multigroup:
          class_num_string = re.compile('^Group ([A-Z_-]+)[ ]*[\r\n]')
      else:
          class_num_string = re.compile('^CLASS (\d+)[ ]*[\r\n]')
      class_num = 1
      statements = dict()

      for line in self.f:
         if ( self.starting_string.findall(line) ):
            in_block = True
         if ( self.stopping_string.findall(line)  ):
            in_block = False
            
         if (in_block):
            class_tmp   = class_num_string.findall(line)
            if (class_tmp):
               class_num = str(class_tmp[0])

            about_variable = statement_string.findall(line)

            if (about_variable):
               in_statement = about_variable[0][0]
               in_statement = re.sub("[ ]+"," ", in_statement.strip())
               values = about_variable[0][1:]
               values = list(float(v) for v in values )
               
               if (values[0] != 999.0 and abs(values[3]) > 0.0001 and \
                    abs(values[1])> 1e-6):
                  ncp = ( values[0] / values[1]**2 ) * delta**2
                  values.append(ncp)
                  values.append(distributions.pchisq(1, ncp, critical))
               else:
                  values.extend([999.0,999.0]) # missing values

               if in_statement not in statements: 
                  statements[in_statement] = {class_num : values}
               else:
                  statements[in_statement][class_num] = values
                  
         about_variable = []

      self.f.seek(0) # rewind the file so it can be read again
      return(statements)         
Beispiel #2
0
 def get_critical(self):
     "Return critical value of 1df chi square test from field or cached value"
     if not self.critical: # not cached
         self.critical = distributions.qchisq(1, self.get_field_value('alpha'))
     return self.critical