My son now 13, went through a very similar problem when he was about 3 years old. It has a name but of course I cannot remember it. I think they consider it an emotional problem that could have stemmed from a painful bowel movment so that the child is afraid o go again. My son also held it in for days until it was very painful and hard to move his bowels. We had to put him on a modification program with a calendar giving him stickers and prizes for every time he had a bowel movement to encourage him to keep trying. The doctor I saw then also said it was associated with early potty training. My son was potty trained early but I didn't believe that theorey. Good luck and remember-it will get better.