Have you probed the engine with a stethoscope or a long handled screwdriver to the ear to try and pinpoint the loc of the noise? Similar thing happened to me a few weeks ago. At first I thought the engine was in "death mode" by the sound of the rattle. It only occurred after engine got warm & higher rpm's reduced the noise or made it disappear. And the check engine light was on. Fudge!
Crawled around underneath and determined something inside the CAT was rattling. Got the code read, turned out to be "Cat Conv operating below threshold"... or something to that effect.
Cat is warranted 7 or 8 yrs (I forget which) or upto 80,000 miles. So I need to get it into the shop to have it looked at. Mines a 2011 w/ 59,000 miles.
See this thread... 2011 Ranger 4.0 Engine Rattle?
Good luck, hope your situation is something similar rather than timing chain issues.