The role of coronal mass ejections and interplanetary shocks in interplanetary magnetic field statistics and solar magnetic flux ejection