matlab - Predict missing values from given data -


i have data of 120 points. of them missing. have predict missing values these points. have use linear regression models. basis function should use predict values , how think of such basis function? linear regression model linear in parameters w0,w1,...,wn. not linear in x.
used datenum convert date data type number. used polyfit. getting nan values of array it. doing wrong? taking polynomials of different degrees , take polynomial have least testing error. data points scattered think polynomial regression not work. so, think should use gaussian function basis function. haven't tried yet. want know, things have said correct? if can show me output great.
code:

close format long g fileid = fopen('real_ts.csv'); c = textscan(fileid,'%s %n','delimiter',',','treatasempty',{'.'}); x = datenum(c{1},'mm/dd/yyyy'); t = c{2}; find = isnan(t); f = x(find); x = x(~find); t = t(~find); plot(x,t,'*'); hold on; %mu = 732000:100:736500; k = 5; n = length(x); p = n/k; me = inf; points = (p-1)*k; lambda = 10000; m = 1:50     av_tee = 0;     av_tre = 0;     av_w = zeros(m+1,1);     av_y = zeros(points,1);     av_var = 0;     = 1:p         x = [];         t = [];         j = 1:p             if j~=i                 x = [x;x((j-1)*k+1:j*k)];                 t = [t;t((j-1)*k+1:j*k)];             end         end         phi = [];         l = 0:m             phi = [phi x.^l];         end         w = (lambda*eye(m+1)+phi'*phi)\(phi'*t);         av_w = av_w + w;         y = phi*w;         av_y = av_y + y;         av_tre = av_tre + (1/points)*sum(abs(y-t));         av_var = av_var + sum(t-phi*w)/points;         phi = [];         l = 0:m             phi = [phi x((i-1)*k+1:i*k).^l];         end         av_tee = av_tee + (1/k)*sum(abs((phi*w)-t((i-1)*k+1:i*k)));     end     m     av_tee = av_tee/p     av_tre = av_tre/p     if av_tee<me         me = av_tee;         w = av_w./p;         m = m;         var = av_var./p;     end end m me var phi = []; l = 0:m     phi = [phi x.^l]; end y = phi*w; plot(x,t,'*'); hold on; plot(x,y,'r'); hold off; 

i using least squares regression in code cross validation , regularization.
please tell me in comments if need other info.

i using matlab. given data: data points


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -