Files
GMPECalculation/src/createReport.m

53 lines
1.5 KiB
Mathematica
Raw Normal View History

2025-06-02 15:38:37 +02:00
function report=createReport(mdl, pp)
% Produces report from GMPE calculation product (LinearModel)
% (c) Dorota Olszewska 2017.03.10
report = struct();
report.linRegModel=mdl.Formula.char;
report.h=pp.h
report.obsNo=mdl.NumObservations;
report.dfe=mdl.DFE;
report.rmse=mdl.RMSE;
report.r2=mdl.Rsquared.Ordinary;
a1=anova(mdl,'summary');
report.p=a1{2,5};
report.coefficients=mdl.Coefficients;
report.coeffsStatisticallyInsignificant=mdl.CoefficientNames(mdl.Coefficients.pValue(1:end)>0.05);
report.coeffsSourceNonPositive={};
report.coeffsDistNonNegative={};
if pp.N.eventN~=0
if pp.N.eventN==2
mm=(strcmp(mdl.PredictorNames,pp.event_set{1}))+(strcmp(mdl.PredictorNames,pp.event_set{2}));
elseif pp.N.eventN==1
mm=(strcmp(mdl.PredictorNames,pp.event_set{1}));
end
M.test=sum(mm);
M.Names=mdl.PredictorNames(mm==1);
M.var=mdl.Coefficients.Estimate(M.Names);
M.znak=mdl.Coefficients.Estimate(M.Names)>0;
if sum(M.znak)~=M.test
report.coeffsSourceNonPositive=M.Names(M.znak==0);
end
end
if pp.N.distN~=0
if pp.N.distN==2
rr=(strcmp(mdl.PredictorNames,pp.dist_set{1}))+(strcmp(mdl.PredictorNames,pp.dist_set{2}));
elseif pp.N.distN==1
rr=(strcmp(mdl.PredictorNames,pp.dist_set{1}));
end
R.test=sum(rr);
R.Names=mdl.PredictorNames(rr==1);
R.var=mdl.Coefficients.Estimate(R.Names);
R.znak=mdl.Coefficients.Estimate(R.Names)<0;
R.exc=R.Names(R.znak==0);
if sum(R.znak)~=R.test
report.coeffsDistNonNegative=R.exc;
end
end
end