We develop a procedure to identify latent group structures in linear panel data models that exploits a grouping in the error variances of cross-sectional units. To accommodate such grouping, we introduce an objective function that avoids a singularity that arises in a pseudolikelihood approach. We provide theoretical and numerical evidence showing when allowing for variance groups improves classification. The developed procedure provides new evidence on the relation between firm-level research and development (R&D) investments and the business cycle. We find a well-defined group structure in the variances that ex-post can be related to firm size. Our estimates indicate stronger procyclical investment patterns at medium-size firms compared to large firms.