A method for controlling an engine, the engine including a fuel injection unit, a boost controller that performs limitation on a maximum injection amount of the fuel injection unit, an EGR unit that causes exhaust gas to recirculate in an intake pipe, and a controller that performs control on the boost controller and the EGR unit, the method comprising causing the controller to, based on a control map of an engine speed and a fuel injection amount of the fuel injection unit, calculate the fuel injection amount dependent on the engine speed, calculate an injection amount deviation as a fuel injection amount increase, and determine that the engine is in a transient state if the number of times the injection amount deviation exceeds a reference transient injection amount deviation is larger than or equal to a reference number of times, wherein if it is determined that the engine is in the transient state, the controller is caused to calculate an excess air ratio that is an indicator indicating a state of the engine and perform the control on the EGR unit and the boost controller according to the excess air ratio, and wherein the control on the EGR unit and the boost controller by the controller includes a first step in which the excess air ratio is compared with a first threshold, and a second step in which the excess air ratio is compared with a second threshold if the excess air ratio is smaller than the first threshold, in the first step, if the excess air ratio is larger than or equal to the first threshold, the EGR unit and the boost controller are maintained in a steady operation state, and in the second step, if the excess air ratio is larger than or equal to the second threshold, the limitation of the boost controller is decreased while opening an EGR valve of the EGR unit at an intermediate opening, and if the excess air ratio is smaller than the second threshold, the limitation of the boost controller is increased while fully closing the EGR valve. causing the controller to, based on a control map of an engine speed and a fuel injection amount of the fuel injection unit, calculate the fuel injection amount dependent on the engine speed, calculate an injection amount deviation as a fuel injection amount increase, and determine that the engine is in a transient state if the number of times the injection amount deviation exceeds a reference transient injection amount deviation is larger than or equal to a reference number of times, wherein if it is determined that the engine is in the transient state, the controller is caused to calculate an excess air ratio that is an indicator indicating a state of the engine and perform the control on the EGR unit and the boost controller according to the excess air ratio, and wherein calculate an excess air ratio that is an indicator indicating a state of the engine and perform the control on the EGR unit and the boost controller according to the excess air ratio, and wherein the control on the EGR unit and the boost controller by the controller includes a first step in which the excess air ratio is compared with a first threshold, and a second step in which the excess air ratio is compared with a second threshold if the excess air ratio is smaller than the first threshold, a first step in which the excess air ratio is compared with a first threshold, and a second step in which the excess air ratio is compared with a second threshold if the excess air ratio is smaller than the first threshold, in the first step, if the excess air ratio is larger than or equal to the first threshold, the EGR unit and the boost controller are maintained in a steady operation state, and in the second step, if the excess air ratio is larger than or equal to the second threshold, the limitation of the boost controller is decreased while opening an EGR valve of the EGR unit at an intermediate opening, and if the excess air ratio is smaller than the second threshold, the limitation of the boost controller is increased while fully closing the EGR valve.