请高手帮我看看在检验数据完整性的那部分,每行程序的作用,我没明白他是怎么找到数据缺失位置的,以及end后面的那几句有什么用?
Y=data(:,1); % Endogeneous Variable 内生变量(数据第一列)
Q=data(:,2); % Threshold Variable (Identical for all threshold variables)转换变量(数据第2列)
X=data(:,3:end); % Matrix of Explicative Variables 解释变量矩阵(数据第3列以后所有行)??
N=N0; % Number of Individual 变量个数
T=length(Y)/N; % Time Dimension 时间域
NT=N*T; % Total number of observations 观测值总数
K=size(X,2); % Number of Explicative Variables 解释变量个数
%-------------------------
%---- Balanced Sample ----(样本完整性)
%-------------------------
balanced=1; % balanced=1 if the sample is balanced 当样本值完整时,balance=1
if sum(sum(isnan(data)))>0 % Not Balanced Sample(
disp(' '),disp(' WARNING: The sample is not balanced'),disp(' ') %显示 WARNING: The sample is not balanced
balanced=0; % balanced=0 if the sample is not balanced 当样本数值不完整,balance=0;
end
missing=sum(isnan(data)')'; % Location of Missing Values 丢失数据的位置
sample(:,1)=ones(length(Y),1); %使数据第一列全部等于1
sample(missing>0)=0; % Sample of Complete Data ???
balanced_indi=repmat((1:N),T,1);sample(:,2)=balanced_indi(:); % Index of Individuals??
sample(:,3)=repmat((1:T),1,N)'; % Index of Time??
Qadj=Q(sample(:,1)==1); % Values of Qit on the Adjuted Sample??
Xadj=X(sample(:,1)==1,:); % Values of Xit on the Adjuted Sample??
sampleAdj=sample(sample(:,1)==1,:); % Adjusted Sample??
NT=sum(sample(:,1)); % Total number of observations??