|
回归分析:返回值最齐全的回归函数:
- function para = regress_para(x1,y1,year)
- % year为年份
- alpha = 0.05; % 置信区间
- if ~isempty( x1 ) % 行数 不为 空集
- b=[];bint=[];r=[];rint=[];states=[];
- [b,bint,r,rint,states] = regress(y1,x1,alpha); % 回归
- para(1).b = b; para(1).bint = bint; para(1).r = r; para(1).rint = rint; para(1).states = states;
- para(1).num = size(x1,1); para(1).year = cell2mat(year); % 同一年份,参与回归的企业数量
- para(1).my = mean(y1); % 均值
- para(1).mx = mean(x1,1); % 均值
- dft=[]; dft=length(y1)-1;
- dfe=[]; dfe=length(y1)-length(b);
- para(1).adjR2 = 1-(1-states(1,1))*(dft./dfe); % 调整R2
- else
- para(1).b = NaN; para(1).bint = NaN;
- para(1).r = NaN; para(1).rint = NaN; para(1).states = NaN;
- para(1).num = 0; para(1).year = cell2mat(year); % 同一年份,参与回归的企业数量
- para(1).my = NaN; % 均值
- para(1).mx = NaN; % 均值
- para(1).adjR2 = NaN;
- end
复制代码
|
|