Surging idle in Subaru legacy

I have a 99 legacy, When I start it when the engine is cold, the engine revs up to around 3000 rpms for about five seconds. When the car warms up a little the engine will rev up a little and then drop down, rev up a little then drop down, I believe it is called loping. When it is doing this surging it is only changing a few hundred rpms.

Is this a vacuum leak? I cannot find the Egr valve to test it and the pcv valve clicks. Any suggestions?

It may be, indeed, a vacuum leak. A good way to find them is to wave an unlit propane torch around close to the places a leak might be occuring.

Yes it could be a vacuum leak.( You may also use soapy water to detect a leak)

Perhaps one or more of these too:

A fault in the fuel or ignition systems
A plugged PCV valve or hose (if it rattles it’s good)
Air filter clogged
Leaking head gasket (compression check)
Camshaft lobes worn.

Thank you for your suggestions. I will work on it this weekend and let you all know how it works out. Thanks again.