In biomedical studies, it is often of interest to estimate how the risk profile of an adverse event is related to the timing of an intervention. For example, in randomized controlled clinical trials of bivalent human papillomavirus (HPV) vaccine, investigators are interested to know how miscarriage rate relates to the timing of HPV vaccination. A risk window is defined as an interval for the covariate where the risk of adverse event is elevated. Existing methods cannot make simultaneous inference on both the risk window and the magnitude of the risk. A hierarchical Bayesian logistic regression model is developed to estimate the risk window of miscarriage on the time of conception with respect to vaccination. Hierarchical priors are proposed and used in Markov Chain Monte Carlo for statistical inference. The performance of the Bayesian model and two existing methods is evaluated in simulation settings with varying risk windows and relative risks. The proposed model provides both point and interval estimates for the risk window regarding to vaccination, and captures its effect modification on miscarriage risk in pregnancy. Analysis of the vaccine trial using the proposed model shows no significant evidence of an association between the HPV vaccine and miscarriage risk. The hierarchical Bayesian model is useful in general in analyzing a randomized trial or an epidemiological study in which the effect of an agent is potentially modified by a temporal factor.