A novel statistical method for assessing effective adherence to medication and calculating optimal drug dosages