Preheat the oven to 350 degrees F (175 degrees C).
Melt butter in a saucepan over medium-low heat. Add pineapple juice, white sugar, brown sugar, cinnamon, and nutmeg; stir to combine and cook until sugars have dissolved, 2 to 3 minutes.
Meanwhile, place drained yams in a casserole dish. Add pineapple chunks. Pour sauce over top.
Bake in the preheated oven for 1 hour. Add marshmallows to the top and continue to bake until golden and melted, 10 to 15 minutes more. Let stand for 15 minutes before serving so sauce can thicken.