Classical density functional theory is applied to investigate the validity of a phenomenological force-balance description of the stability of the Cassie state of liquids on substrates with nanoscale corrugation. A bulk free-energy functional of third order in local density is combined with a square-gradient term, describing the liquid-vapor interface. The bulk free energy is parameterized to reproduce the liquid density and the compressibility of water. The square-gradient term is adjusted to model the width of the water-vapor interface. The substrate is modeled by an external potential, based upon the Lennard-Jones interactions. The three-dimensional calculation focuses on substrates patterned with nanostripes and square-shaped nanopillars. Using both the force-balance relation and density-functional theory, we locate the Cassie-to-Wenzel transition as a function of the corrugation parameters. We demonstrate that the force-balance relation gives a qualitatively reasonable description of the transition even on the nanoscale. The force balance utilizes an effective contact angle between the fluid and the vertical wall of the corrugation to parameterize the impalement pressure. This effective angle is found to have values smaller than the Young contact angle. This observation corresponds to an impalement pressure that is smaller than the value predicted by macroscopic theory. Therefore, this effective angle embodies effects specific to nanoscopically corrugated surfaces, including the finite range of the liquid-solid potential (which has both repulsive and attractive parts), line tension, and the finite interface thickness. Consistently with this picture, both patterns (stripes and pillars) yield the same effective contact angles for large periods of corrugation.