Statistical thermodynamics for metaequilibrium or metastable states