Karma is affected by the choices you make during the "confession" segments in the game, by replying to text messages on your phone, and even dialogue choices. There are three possible main routes with different variations of good and bad endings for each, which are achieved by being nice to either Catherine (Pink Side) or Katherine (Blue Side), or being mean to both (keeping your Karma meter in the middle).
The ending variations are actually affected by the Confession questions in the final stage (9th Night).
The last couple questions and your standing on the Karma meter up to that point determine the ending.
During the 9th Night, the first question actually doesn't affect your ending, but the following two determine your fourth question and ending. Here's how to get all the different variations:
Katherine (True) Ending Meter Position - Extreme Blue Question 1 - Yes Question 2 - No Question 3 - I'm Ready
Catherine (True) Ending Meter Position - Extreme Pink Question 1 - No Question 2 - Yes Question 3 - Yes
Freedom (True) Ending Meter Position - Middle Question 1 - No Question 2 - No Question 3 - Yes
Katherine (Good) Ending Meter Position - Extreme Blue Question 1 - Yes Question 2 - Yes Question 3 - I'm Ready