Harmonic impedance estimation based on improved rank estimation

In response to the issue of harmonic data anomalies affecting harmonic impedance estimation, a method based on improved rank regression is proposed, building upon the foundation of rank estimation. This method utilizes harmonic data sampled from the point of common coupling, treating harmonic impedance as regression parameters. Initially, the least squares method is employed to solve for regression parameters. Subsequently, Bayesian optimization is applied to refine these parameters. The optimized parameters are then incorporated into the rank estimation function derived from the residual rank matrix for weighted iteration. The final calculation results are determined through this iterative process. Simulation analysis demonstrates that this method can effectively mitigate the impact of outliers, yielding more accurate harmonic impedance values.


Introduction
The high proportion of new energy sources, such as wind power and photovoltaics, connected to the power grid has led to increasingly prominent power quality issues.Accurate measurement of system harmonic impedance is the primary prerequisite for solving this problem, including issues such as harmonic responsibility division [1,2], harmonic tracing, and harmonic governance.Voltage source inverters with strong controllability and fast dynamic response are widely used in the grid connection of new energy generation.However, their control system is complex, nonlinear, and strongly coupled, which brings a series of oscillation and instability problems [3].Accurate measurement of harmonic impedance is an important means of stability analysis.
Currently, methods for estimating system harmonic impedance can be broadly classified into two categories: "interventional" and "non-interventional." Interventional methods involve injecting artificially generated harmonic disturbances into the system for harmonic impedance estimation.However, this approach has a significant impact on the normal operation of the system and is less commonly used.In contrast, non-interventional methods rely on collected harmonic data for estimation without affecting the system's normal operation.This category includes methods such as fluctuation quantity, covariance, independent component analysis, and regression analysis.Among them, fluctuation quantity is simple but sensitive to background harmonic fluctuations [4]; covariance eliminates background harmonic fluctuations using the approximate independence between harmonic current at PCC and background harmonic voltage but may lead to increased estimation errors when impedances on both sides are similar [5]; independent component analysis estimates harmonic impedance based on blind source separation, effectively reducing interference from harmonic variations IOP Publishing doi:10.1088/1742-6596/2771/1/012034 2 on the system side but has longer computation times and challenges in obtaining optimal solutions, impacting estimation accuracy [6].Moreover, the mentioned methods do not consider the influence of outlier data in the samples, resulting in a lack of robustness in the results.Regression analysis solves harmonic impedance by forming equations based on the linear relationship between voltage and current at the PCC.However, it becomes ineffective when the voltage-current relationship is not linear, and most solutions for this equation use the least squares method, which amplifies the impact of outlier data on estimation accuracy [7].
Analyzing the shortcomings of existing methods, it is evident that mitigating the influence of outliers is crucial for obtaining accurate harmonic impedance estimates.This paper proposes a harmonic impedance estimation method based on improved rank regression, considering the impact of outliers from a data-driven perspective.Initially, harmonic data is sampled from the point of common coupling, and regression parameters are obtained using the least squares method.Subsequently, Bayesian optimization is applied to refine these parameters.The optimized parameters are then incorporated into the rank estimation function derived from the residual rank matrix for weighted iteration, ultimately yielding harmonic impedance values on the system side.Finally, the feasibility and accuracy of the proposed harmonic impedance estimation method based on improved rank regression are validated through MATLAB simulations.
This method involves obtaining regression parameters by minimizing the sum of squared residuals, įi(ȕ), which tends to amplify the impact of outliers on residuals.As a result, the estimation results may lack stability.
The matrices Xc=x '  ij , residual matrix r m i =yi -xciȕ m , and rank matrix u m i =R(r m i )-(n+1)/2.The specific steps are as follows: 1) Equation ( 2) is solved using the least squares method to obtain the regression parameters ȕ m , where m represents the iteration count; 2) The direction vector , the weighted median t m is obtained by taking the weighted median of ( The estimated value ȕ m+1 =ȕ m +t m d m is iterated, and the convergence threshold is set as is the sought estimate.If it does not meet the convergence condition, it is returned to step 2) and iterates until convergence.

Bayesian optimization algorithm
To improve the accuracy of the rank regression algorithm in estimating harmonic impedance, upon obtaining initial iterations, the regression parameters obtained by the least squares method are optimized to seek the optimal parameter combination for better adaptation of the algorithm, thereby maximizing the accuracy of the estimation.The optimization of parameters through the Bayesian algorithm in this paper primarily involves the following steps: 1) The original objective function of the to-be-evaluated model is replaced with a probability model, and the information is continuously increased through iterations and correct tests.A Gaussian process with high flexibility is selected for solving the probability model.
It is assumed that the training set is M, the set of unknown target functions is {g(Ș1), g(Ș2),..., g(Șn-1)}, where Și is a sample in the training set M, and the hyperparameter is ș.In the presence of observation noise İ and assuming that the noise follows an independent and identically distributed Gaussian distribution P(İ)=(0, ı 2 ) (with ı 2 as the prior model's predictive variance), the marginal likelihood distribution is obtained as: where șbest is the optimal solution for observed values.By maximizing the marginal likelihood distribution through maximum likelihood estimation, șbest is obtained.
2) An acquisition function is chosen.A utility function is constructed from the posterior model and the next acquisition point is determined.This paper uses the commonly used expected improvement function to find the maximum expected increment under the current optimal conditions [10].The acquisition function is given by: where ȝ is the predictive mean of the prior model, and E(•) is the current expectation under optimal conditions.

Harmonic analysis model and improved rank estimation method
The system harmonic analysis equivalent circuit for impedance measurement using linear regression is illustrated in Figure 1.Us represents the harmonic voltage source equivalent to the system-side Thevenin, Zs is the harmonic impedance on the system side, Upcc and Ipcc are the voltage and current at the Point of Common Coupling (PCC) respectively, Zc is the harmonic impedance on the user side, and Ic is the harmonic current source on the user side.The voltage-current relationship can be expressed as follows based on Figure 1: Expanding the above expression into real and imaginary parts and rearranging, we obtain: The variables with subscripts x and y represent their respective real and imaginary parts.The basic expression can be written as: The expression (y, x1, x2) represents the data samples which can be sampled.Meanwhile, (ȕ0, ȕ1, ȕ2) are the corresponding regression parameters.If there are a total of m sets of data samples, and we need to estimate the regression parameters for n sets of (ȕ1, ȕ2), typically, the least squares method is employed for estimation.The number of solutions for the regression parameters is denoted as p=C n m .A new p-dimensional vector Bi =[ȕ 1 i , ȕ 2 i , ..., ȕ p i ] is defiined, where i=1, 2. The elements in Bi are taken from the regression solution vector ȕi.
The specific estimation process is as follows: 1) The harmonic analysis model is built in MATLAB.Harmonic data is obtained at PCC and is organized into the form of Equation ( 7); 2) The processed data is imported into the rank estimation algorithm.The regression parameters are calculated according to Equation (2), and then the target optimization function and parameter optimization range are set for the Bayesian algorithm.The initial point and number of iterations are set to adjust the regression parameters; 3) It is checked whether the maximum number of iterations is reached.If yes, the iteration is stopped, and the parameter combination that optimizes the algorithm's performance metrics is output.Otherwise, it is returned to step 2) to continue adjusting the parameters; 4) Store the current optimal parameter combination, substitute it into the rank estimation algorithm, and obtain the final harmonic impedance through algorithmic iteration.

Simulation analysis
A simulation circuit is built in Matlab, as shown in Figure 1.The simulation frequency is set to 150 Hz.The simulation parameters are set as follows: Us=50‫°1.35ס‬V,Zs=5+j4 ȍ, Ic=15‫°84ס‬A, Zc=380+j296 ȍ.Sinusoidal random perturbations of 10% amplitude and 20% phase angle are added to the voltage source.For the current source, perturbations of 20% amplitude and 30% phase angle are added.20% sinusoidal random perturbations are added to the real and imaginary parts of Zc.The parameters estimated subsequently in the paper are the 3rd harmonic impedance on the system side, represented as 5+j4 ȍ.  n=1440 samples of PCC harmonic voltage and current are collected as samples, where anomalies occur at n=400, n=700, and n=1000.The sampled real and imaginary parts of the voltage are shown in Figure 2.
In groups of continuous 60 samples, i.e., 1~60, 2~61, ..., 1381~1440, totaling 1381 groups, a comparison is made using binary regression, rank regression estimation, and the method proposed in this paper.In Figure 3, TV represents the theoretical value, BRV stands for the binary regression value, RRV indicates the rank regression value, and IRRV corresponds to the improved rank regression value.
Since each group involves the calculation of 60 data samples in a segmented form, theoretically, the influence of outliers should not extend beyond the 60 data samples before the outlier setting point.For example, the impact range of the outlier set at sample point 400 should be 341~400.Therefore, for the three sets of outliers, segments 280~460, 580~760, and 880~1060 are respectively taken as intervals A, B, and C for comparative analysis.
From the comparison of the estimated real and imaginary parts of the harmonic impedance on the system side in Figure 3, it can be observed that within the interval affected by outliers, the estimation results of the binary regression method are influenced to varying degrees by the outliers.Some data points' estimated results deviate significantly from the theoretical values, with maximum errors exceeding 100%.In contrast, the rank regression method can reduce some estimation errors compared to binary linear regression.The improved rank regression method shows even stronger capabilities in reducing estimation errors.
Taking the interval of 341 to 400, the average and mean error of the harmonic impedance estimated by the three methods are calculated (the mean error here does not correspond to the mean value; instead, it is obtained by calculating the estimation error for each data point and then taking the average).The results are shown in Table 1 In the presence of outliers in the data samples, the accuracy of the binary linear regression method in estimating the harmonic impedance on the system side is significantly affected, especially when the estimated harmonic impedance coincides with the outlier points in the samples.
Within the interval of outlier settings, both the rank regression method and the proposed method in this paper can reduce the errors in estimating harmonic impedance compared to the binary regression method.The improved rank regression method exhibits even smaller errors in estimating the real and imaginary parts of the harmonic impedance on the system side, highlighting the advantages of Bayesian algorithm optimization in estimating parameters.

Conclusion
This paper proposes a harmonic impedance estimation method based on improved rank regression.When the data sample contains outliers, the improved rank regression method shows a more significant improvement in estimation accuracy, with a minor degree of computational bias in the segment with abnormal data samples.This validates the effectiveness and accuracy of the proposed method.

Figure 2 .
Figure 2. The real and imaginary parts of the harmonic voltage of abnormal values in PCC points.

Table 1 .
: Comparison of system side harmonic impedance estimation methods.