If you have ever felt like your dog knows when you are having a bad day, science suggests you might be right.