I am working with data in matlab.
See code:
x = rand(10,1)
y = [1,2,3,4,5,6,7,8,9,10]'
z = [NaN, NaN, NaN, NaN, 1, 2, 3, 4]'
ww = mean(z)-mean(y)
From this, ww = Nan
how can I deal with these NaN values, I would like ww to be,
ww = 8.5-2.5
With the 8.5 coming from the last four numbers in y and the 2.5 the last four digits in z.
I am doing regressions in MATLAB with time series data, for certain series there is missing data NaNs at the start of the series. I am wondering how to deal with them and the above example is a Complete Minimal example.
Edit:
For a slightly more complicated example, trying to use the archtest
clear;
%data
data = xlsread('RETURNS.xlsx',2);
for jj = 2:51
for ii = 1:12
residuals = data(:,jj) - mean(data(:,jj));
h(jj,ii) = archtest(residuals,'Lags',ii);
end
end
Where there are NaNs in some of the columns.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…