Dogs will sometimes do this as a form of protest for being left alone, especially if they are high strung. Try taking your dog to the vet and see if he will prescribe something like valium to calm her anxiety. Behavioral drugs like this sometimes work in these cases.
Perhaps your dog is testing it's limits. Some dogs will defecate in areas that there have not been proper bounries set for them. They tend to try and "claim" the house as their own. You must establish yourself as the master of your domain or your dog will.