A modem can theoretically affect ping. This is because a modem or router can affect your overall latency connection to a game server, however, this will only be as long as the data packets are traversing the device. As the packets are being processed by the modem, they are being buffered and then sent on to the router. The latency seen by your connection is measured from your router to that game server.