The sentence should read:
"Marcella thinks it childish to wave at the engineer of a train, but she does it anyway."
The comma is needed to separate the two independent clauses in the sentence: "Marcella thinks it childish to wave at the engineer of a train" and "but she does it anyway".