How to detect the probability of a shift in mean value when number of variables increases?
Mostra commenti meno recenti
Probability of a shift in mean value of a multivariate normal vector decreases as the number of variables increaes in case of Hotelling T2 chart. How can I prove this with the help of matlab code.
for example: we are monitoring p variables. The shift in one variable x1 with magnitude 1 and no shift in other (p-1) variable. There is identity correlation matrix. I need to detect the shift in x1 for achieving the same level of false alarm probability when dimension of p increases from 1 to 20.
Set false alarm probability as 0.002.
Risposta accettata
Più risposte (1)
Hi Nainsi,
MATLAB code for the asked problem -->
% Set the parameters
p = 20; % Number of variables
n = 1000; % Number of samples
shift_magnitude = 1; % Magnitude of shift in x1 variable
false_alarm_prob = 0.002; % Desired false alarm probability
% Generate the multivariate normal data
mu = zeros(1, p); % Mean vector for no shift
mu_shifted = [shift_magnitude, zeros(1, p-1)]; % Mean vector with shift in x1 variable
sigma = eye(p); % Identity correlation matrix
data_no_shift = mvnrnd(mu, sigma, n); % Generate data with no shift
data_shifted = mvnrnd(mu_shifted, sigma, n); % Generate data with shift
% Calculate the Hotelling's T2 statistic for each sample
T2_no_shift = sum((data_no_shift - mu).^2, 2);
T2_shifted = sum((data_shifted - mu).^2, 2);
% Calculate the threshold for the Hotelling's T2 statistic
threshold = chi2inv(1 - false_alarm_prob, p);
% Count the number of false alarms for each scenario
false_alarms_no_shift = sum(T2_no_shift > threshold);
false_alarms_shifted = sum(T2_shifted > threshold);
% Display the results
fprintf('Number of variables (p): %d\n', p);
fprintf('False alarm probability: %.4f\n', false_alarm_prob);
fprintf('Number of false alarms (no shift): %d\n', false_alarms_no_shift);
fprintf('Number of false alarms (shifted): %d\n', false_alarms_shifted);
I first set the parameters for the code above, including the intended false alarm probability (false_alarm_prob), the desired number of variables (p), the required number of samples (n), the magnitude of the shift in the x1 variable (shift_magnitude), and so on.
I then use the mvnrnd function from the Statistics and Machine Learning Toolbox to create the multivariate normal data. I produce two sets of data: one with no shift in the x1 variable (data_no_shift), and the other with a shift in that variable (data_shifted).
Then, using the equation `T2 = sum((x - mu).^2, 2)`, I determine the Hotelling's T2 statistic for each sample.2), where mu is the mean vector and x is the data matrix.
Using the intended false alarm probability and the number of variables, I use the chi-square inverse function chi2inv to compute the threshold for the Hotelling's T2 statistic.
Finally, I compare the estimated T2 statistic with the threshold to determine how many false alarms there were for each scenario. The findings are shown, along with the total number of false alarms for both the case with and without the shifted variable.
You can see that as the number of variables increases, the number of false alarms for detecting the shift in the x1 variable likewise increases, showing a drop in the chance of detecting the shift, by running this code for various values of p.
Categorie
Scopri di più su Multivariate t Distribution in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
