The generalized linear model (GLM) is a statistical model which has been widely used in actuarial practices, especially for insurance ratemaking. Due to the inherent longitudinality of property and casualty insurance claim datasets, there have been some trials of incorporating unobserved heterogeneity of each policyholder from the repeated observations. To achieve this goal, random effects models have been proposed, but theoretical discussions of the methods to test the presence of random effects in GLM framework are still scarce. In this article, the concept of Bregman divergence is explored, which has some good properties for statistical modeling and can be connected to diverse model selection diagnostics as in Goh and Dey [(2014) Journal of Multivariate Analysis, 124, 371–383]. We can apply model diagnostics derived from the Bregman divergence for testing robustness of a chosen prior by the modeler to possible misspecification of prior distribution both on the naive model, which assumes that random effects follow a point mass distribution as its prior distribution, and the proposed model, which assumes a continuous prior density of random effects. This approach provides insurance companies a concrete framework for testing the presence of nonconstant random effects in both claim frequency and severity and furthermore appropriate hierarchical model which can explain both observed and unobserved heterogeneity of the policyholders for insurance ratemaking. Both models are calibrated using a claim dataset from the Wisconsin Local Government Property Insurance Fund which includes both observed claim counts and amounts from a portfolio of policyholders.