function [ beta_star, beta_std, rsqr, nobs ] = star_regression( result, x )


% PURPOSE: ASSIGN STARS TO DIFFERENT SIGNIFICANCE LEVELS OF THE REGRESSION
% COEFFICIENTS OF THE OLS ESTIMATION. REPORT THE BETA STANDARD DEVIATION,
% RSQUARED AND NUMEBR OF OBSERVATION

% INPUT:
%     -result:REGRESSION RESULTS (NUMERIC FORMAT)
%     -x:INDEPENDENT REGRESSOR
%     
% OUTPUT:
%     -beta_star: STAR FOR THE SIGNIFICANCE LEVEL OF BETA
%     -beta_std:STANDARD DEVIATION FOR BETA
%     -rsqr:RSQUARED
%     -nobs: NUMBER OF OBSERVATIONS


%Approximate betas, deviation of betas and rsquared at two decimals
%positions
result.beta=roundTo(result.beta,2);
result.bstd=roundTo(result.bstd,2);
result.rsqr=roundTo(result.rsqr,2);

%Convert betas in string
beta1=num2str(result.beta);

%Create stars vector for betas
for i=1:size(x,2)
    if result.tstat(i,1)<=-2.575
        star_reg(i,1)={'***'};
    elseif result.tstat(i,1)>=2.575 
        star_reg(i,1)={'***'};
    elseif  and(result.tstat(i,1)<2.575, result.tstat(i,1)>=1.96)
        star_reg(i,1)={'**'};
    elseif and(result.tstat(i,1)<=-1.96, result.tstat(i,1)>-2.575)
        star_reg(i,1)={'**'};
    elseif and(result.tstat(i,1)<1.96,result.tstat(i,1)>=1.645)
        star_reg(i,1)={'*'};
    elseif and(result.tstat(i,1)<=-1.645,result.tstat(i,1)>-1.96)
        star_reg(i,1)={'*'};
    else
        star_reg(i,1)={''};
    end
end

%Concatenate betas and stars
beta_star=strcat(beta1,star_reg);

%Convert standard deviation of betas in string
bstd1=num2str(result.bstd);

%Create brackets for standard deviation
for i=1:size(x,2)
    open_bracket(i,1)={'['};
end

for i=1:size(x,2)
    close_bracket(i,1)={']'};
end

%Concatenate brackets and standard deviations
beta_std=strcat(open_bracket, bstd1, close_bracket);

%Convert R-squared in string
rsqr=num2str(result.rsqr);

%Convert # of observations in string
nobs=num2str(result.nobs);


end

