# Can you take the mean of risk-free rates in (ex post) portfolio optimization?

I am researching the optimal asset allocations in a portfolio portfolio under different macroeconomic times during the past 50 years. The primary measure I am using is the Sharpe ratio. Because the risk-free rate has fluctuated a lot during the period of interest, is it reasonable to use a mean of the risk-free rate under the respective period for the Sharpe ratio? For example, can I from the (monthly) risk-free rates, pick out the rates that occurred e.g. under contractions, take the mean out of those and use that to Sharpe-optimize a portfolio under contractions? Because I am not interested in e.g. holding period returns per se, but the optimal allocation of assets.