since it happens more with wet or high humidity, start with the wires being tight and wtaer proofed and the MAF and any MAP sensors, a dirty or bad MAF sensor will act up when ot os wet or very humid, and check ALL wire connections, especially fro MAF and MAP and the ECU subarus are known for bad/.loose/.corroded or wet weather subjected connections, check, clean them all, and consider that you are getting bad gas too, add a good cleaner to the gas tank, B12 or mmo or Techron/.regane with PEA