Yes, the EGR can cause pinging and yes, it can be tested like almostclueless said.
However, a commonly overlooked cause of pinging is mild oil consumption. You can try to put synthetic in the crankcase and see if it cures it.
Inspect your spark plugs. You might see ash from mild oil consumption or oil fouling from severe oil consumption. Maybe some glazing from lean mixtures.
Do make sure it's actually pinging. Other taps -- especially valve noises -- can sound like pinging. Pinging is characteristically worse at high engine load. Valvetrain noises are strictly RPM dependent. Note that pinging is in some sense normal when the tach is too low (on a 4.0L, below about 1500 RPM -- note the engine will run much better over 2000 RPM) and the throttle is high.