Try the knock sensor.
My other car, a Subaru Forester had a flaky check engine light. Turned out to be the knock sensor. It would intermittently flake out, then start working again..
I have also seen goofy ingition coils and distributor cause such flaky behavior. Somehow I expect the vehicle computer would have a specific error code for such problems. Even for the knock sensor.
A number of things in the vehicle could be causing this though.. but like others are suggesting.. probably a sensor or something in the emissions system.
Maybe try borrowing/buying someone's "Scangauge" and try to observe the error codes for a while? Search google for that device. For the price, one or two $80 'diagnostic' runs at your local garage would pay for one of these devices. I have it on my 'to buy' list.
As I recall..my mechanic said a faulty/intermittent knock sensor can cause weird problems.. such as misfiring, power issues, and such in a vehicle. I had a bit of engine hesitation and less power. Obviously it can hurt your fuel economy.
On a rather different line of thought.. but as we are on the topic of emsisions systems. I read somewhere that changing the PCV valvue evey so often (30k miles?) helps maintain fuel economy. Old valves can get gunked up or jammed. I never changed this on my Subaru.. though I did buy one. I just need to figure out where the heck the sucker is to change it!
My understanding is that excess gasses from the combustion process can be released through the PCV value on the engine block and gets recirculated into the combustion chamber again. In older cars a tube would simply eject uncombusted material/gas.. and was lost.
Anyway.. I diverged from the topic a bit there.