A method for measuring anatomical dead space in a lung, the method comprising: (a) providing, in a supply of inspired gas, at least one indicator gas for inhalation by a patient during a test, the concentration of the indicator gas being controlled such as to follow a sinewave pattern over successive breaths; (b) measuring, over successive breaths, the flow rate and concentration of the indicator gas during both inspiration and exhalation of the patient; (c) fitting sinewave envelopes to the measured concentration values of the indicator gas over the successive breaths and, from the fitted sinewave envelopes, determining the inspired concentration, the mixed expired concentration, and the end expired concentration in respect of the indicator gas for each breath; and (d) calculating the anatomical dead space for each of a plurality of inspirations based on a conservation-of-mass principle. Also provided is a test apparatus for carrying out such a method, and a computer program or set of instruction code which, when executed, causes a processor to implement such a method.