function [pc1,W]=getpc(yieldsx,NFACT)
yieldsm=nanmean(yieldsx);
yields=yieldsx-yieldsm;
cov_mat = cov(yields);
[eig_vec,eig_val] = eig(cov_mat);
eig_vec = eig_vec(:,end:-1:1);
W = eig_vec(:,1:NFACT)';
pc1 = yields*W';