well from what i understand its because hes missing you. i have a border terrier and he used to do the same, well he still does. He used to be kept in the spare room when we went out and he used to chew so we told him off and he stopped, then he started goin 2 the toilet everywhere even though he was house broken. From what iv been told its because he knows he cant chew so he does this, its not to be naughty its because he thinks that you are his subbordants and is makes him panic that you have left him and so the soiling is to let you know that he wants you to stay in that area with him. shouting hasn't done anything to our dog and he now gets kept outside, but if you want him to stay inside then the only option i can think of is to make him understand that your not leaving him ex. leave a tape of your voice running so he thinks your still there, put old clothes that smell of you in his bed so he can feel reasured etc. things like that.
hope this helps
