title: How do I insert additional criteria to my existing statistics algorithm?
body: <h2>The Problem</h2>
  <p>I am writing a web app that will predict the winner of a baseball game. The user will select two teams, and based upon historical season data, my app will predict which team will win more games next season. Currently, the app uses the following data properties to calculate the number of games expected to win:</p>
  <pre><code>rs = runs scored
  ra = runs allowed
  g = number of games played total
  actual = the real number of games won
  </code></pre>
  <p><a href="https://i.stack.imgur.com/dT0tE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dT0tE.png" alt="Win Algorithm" /></a></p>
  <p><strong>The Code</strong></p>
  <pre><code>var numGames = 162;
  var runsScored = 901;
  var runsAllowed = 828;
  
  var numActual = 84;
  
  function winsPredicted1(rs, ra, g, actual){
      var wins = ((.102*rs-0.103*ra)/g+.505)*g;
      var diff = wins - numActual;
      return { wins: wins, diff: diff }; // 88, 4
  }
  
  </code></pre>
  <p>and so far so good. The formula is getting quite close...</p>
  <pre><code> 88.42800000000001
   4.4280000000000115
  </code></pre>
  <h2>Improving The Results</h2>
  <p>I now would like to add two more fields for the algorithm to consider:</p>
  <ol>
  <li>Earned Run Average</li>
  <li>Number of Base on Balls ( by this pitcher )</li>
  </ol>
  <p>I am extremely new to statistical programming, and have researched this topic quite a bit. I cannot figure out how to add these new stats into the equation and have their values affect the result.</p>
  <p>This project is for learning purposes only. Can anyone help me with these two new data fields?</p>
  <p>Thank you! I am eager to see your suggestions.</p>
  <p>J</p>