function Boots  = SaveBoots(Boots,paramBOOT,betaIntBoot,omegaboot,sigma,Xn,ZUSA,RemoveIndex,rep)
% Function to save bootstrap estimates in Matlab Structures

Xdev = Xn -mean(Xn);
thetaBoot = paramBOOT(1);
X = [ones(length(Xn),1) Xn];
withUS = 2:length(Xn);


        qboot = sum((omegaboot(withUS,1)).*(Xdev(withUS)))/sum(Xdev(withUS).^2);
        PHIboot =   qboot/((thetaBoot+Xn(1))*var(ZUSA)) - omegaboot(1,1)/((thetaBoot+Xn(1))^2*var(ZUSA));
                
        
        betaCorrect(1,1)=  (betaIntBoot + (betaIntBoot^2 - 4*PHIboot)^.5)/2;
        
        betaCorrect(2,1)=  (betaIntBoot - (betaIntBoot^2 - 4*PHIboot)^.5)/2;
        
        
        
        if imag(betaCorrect(1)) ~= 0
            betaCorrect(:) = NaN;
        end
        
        Boots.PHI(:,rep) = PHIboot;

        
        Boots.beta(:,rep) = betaCorrect;
        Boots.param(:,rep) = paramBOOT;
        Boots.sigmaUSA(:,rep) = omegaboot(1,1)./((betaCorrect.^2)*(Xn(1)+thetaBoot)^2);
                
        

        X = X(withUS,:);
        
        Boots.AA(:,rep) = (X'*X)\X'*(sigma(withUS,1));
        Boots.BB(:,rep) = (X'*X)\X'*(sigma(withUS,1).*(Xn(withUS)));
        
        Boots.delta(:,rep) = Boots.BB(2,rep) + Boots.AA(2,rep)*thetaBoot; 
        
           
end