Replica approach to the generalized Rosenzweig-Porter model