A method of calibrating an antenna system comprising a number of antenna elements, the method being performed in a control device and comprising: - transmitting a signal from a first reference antenna element selected among the number of antenna elements, - measuring the signal in two or more calibration antenna elements selected among the remaining antenna elements of the number of antenna elements, and obtaining a first set of corresponding number of measurement values, - repeating the transmitting and the measuring at least for a second reference antenna element different than the first reference antenna element, thereby obtaining a second set of corresponding number of measurement values, - calculating, for a first type of beamforming and for each calibration antenna element j, a correction value Δ R ij k, Type 1, based on at least the first and second sets of corresponding number of measurement values, thereby obtaining a first part of a correction matrix comprising for row i correction values for calibration antenna elements j relative to antenna element k selected among the remaining antenna elements with antenna element i as one of the first or the second reference antenna element, - calculating, for a second type of beamforming and for each branch j of the antenna system, a correction value ΔR i, j Type 2, based on at least the first and second sets of corresponding number of measurement values, thereby obtaining a second part of the correction matrix comprising for row i correction values for branch j of the antenna system with the antenna element i as the one of the first or the second reference antenna element, - performing an optimization procedure using as input the correction matrix, wherein each column of the first part of the correction matrix, except one, is multiplied with a respective constant c i, i={1,.., N} and each column of the second part of the correction matrix is multiplied with a respective constant c i, i={N+1,.., 2N}, thereby obtaining, for each row of the correction matrix, a respective optimized constant c i opt, wherein N is a number of branches corresponding to the number of antenna elements in the antenna system, and - calculating a compensation value Δ r i for each antenna element based on the respective optimized constant c i opt. - transmitting a signal from a first reference antenna element selected among the number of antenna elements, - measuring the signal in two or more calibration antenna elements selected among the remaining antenna elements of the number of antenna elements, and obtaining a first set of corresponding number of measurement values, - repeating the transmitting and the measuring at least for a second reference antenna element different than the first reference antenna element, thereby obtaining a second set of corresponding number of measurement values, - calculating, for a first type of beamforming and for each calibration antenna element j, a correction value Δ R ij k, Type 1, based on at least the first and second sets of corresponding number of measurement values, thereby obtaining a first part of a correction matrix comprising for row i correction values for calibration antenna elements j relative to antenna element k selected among the remaining antenna elements with antenna element i as one of the first or the second reference antenna element, - calculating, for a second type of beamforming and for each branch j of the antenna system, a correction value ΔR i, j Type 2, based on at least the first and second sets of corresponding number of measurement values, thereby obtaining a second part of the correction matrix comprising for row i correction values for branch j of the antenna system with the antenna element i as the one of the first or the second reference antenna element, - performing an optimization procedure using as input the correction matrix, wherein each column of the first part of the correction matrix, except one, is multiplied with a respective constant c i, i={1,.., N} and each column of the second part of the correction matrix is multiplied with a respective constant c i, i={N+1,.., 2N}, thereby obtaining, for each row of the correction matrix, a respective optimized constant c i opt, wherein N is a number of branches corresponding to the number of antenna elements in the antenna system, and - calculating a compensation value Δ r i for each antenna element based on the respective optimized constant c i opt.