function [pc1x,W]=getpc_nan(yields,NFACT)
id=~isnan(yields(:,1));
yields1=packr(yields);
cov_mat = cov(yields1);
[eig_vec,eig_val] = eig(cov_mat);
eig_vec = eig_vec(:,end:-1:1);
W = eig_vec(:,1:NFACT)';
pc1 = yields1*W';
pc1x=nan(rows(yields),NFACT);
for j=1:NFACT
    pc1x(id,j)=pc1(:,j);
end
    