If the mud weight is too low, the rock around the hole can fail in shear and cave. If it is too high, the mud can open a fracture and be lost. Between pore pressure, that collapse limit, and the fracture limit is the mud-weight window. Shale that weakens with time, weak bedding, and a high-angle well all move the window, sometimes enough that a vertical well would drill and a horizontal well in the same rock will not.
The calculation uses the earth stresses, the pore pressure, and a rock strength. Poisson's ratio and Young's modulus enter when the stresses around the hole are computed from the far-field stresses. A stability model that uses a vertical depth as if it were a measured depth, or a mud weight as if it were already the circulating density, will bless a well that caves or loses returns.