Efficient Replication of Factor Returns: Theory and Applications