Might be the transformer but transformers usually work or they don't work - they seldom develop intermittent faults.
You problem is very probably a bad connection - might be where a wire has been fitted and screwed into a terminal hole without having the insulation properly stripped away but is more likely to be the bulb holder.
In a ceiling void the transformer often falls out through the hole when you tug gently on the wires. Sometimes a transformer runs more than one lamp so you might have to access it from a different spot position.
Peccavi
August 2009