%load inputslp
clear all; close all;
z=rand(100,10);
z(1:50,1:4)=NaN;
save('zz','z','-ascii')

clear all; close all;
load zz
X=zz;
%
% Options for regem
%
a=[1 2 5 10 20 30]
ipcs=a(4)

%OPTIONS.regress = 'mridge';
OPTIONS.regress = 'ttls';
OPTIONS.regpar = ipcs
OPTIONS.stagtol = 5e-3;
%OPTIONS.stagtol = 5e-6;
OPTIONS.maxit = 30;
OPTIONS.inflation = 1.0;
OPTIONS.disp = 1;
OPTIONS.relvar_res = 0.05;
%OPTIONS.minvarfrac=0.95; %change that in case it hit the limit
OPTIONS.minvarfrac=0.85;
%OPTIONS.Xcmp = stt;
%------ case 1 ----------
weight=[]; % normalize
%------ case 2 ----------
%weight(1:1121)=1; % use actual values (no weights, no normalization)
%------ case 3 ----------
%weight(1:155)=1; % weight pdsi instrumental
%weight(156:1121)=966/155; % weight proxies
%weight(156:1121)=.3; % weight proxies

%weight=diag(weight);
%-----------------------

[X, M, C, Xerr, Xmis, dXmis,peff] = newregem(X, OPTIONS, weight);

%[X, M, C, Xerr] = regem(X, options);
%save filled

save('XX','X','-ascii')

%save('gcslp71X','X','-ascii')
%save('gcslp71Xerr','Xerr','-ascii')
%save('gcslp71Xmis','Xmis','-ascii')
%save('gcslp71dXmis','dXmis','-ascii')
%save('gcslp71peff','peff','-ascii')



