Parse CI-fit to fitsignal
laenan8466 opened this issue · 2 comments
Current Design
Currently the CI is only given as CI parameters as return value of fitsignal
:
[Vfit,Pfit,Bfit,parfit,parci,stats] = fitsignal(V,t,r,dd,bg,ex,par0)
parci
contains the CI of background (depends on selected model, e.g. concentration), experiment (e.g. modulation depth) and distance distribution (none in case of regularization).
As far as I understood, fitsignal calls fitregmodel
or fitparamodel
internally, also using several performance boosters. (Does a great job btw. Amazing work!) Output of these functions are fitci or Pci (same thing I guess). This output goes without performance loss. These parameters aren't passed as output of fitsignal
. More important in my point of view would be the CI for regularization methods, as parametrized models have CI for the dd-parameters included.
Proposed behavior
When my assumptions above are valid (are they? 😄 ), these could easily passed as output. This is clearly connected to Issue #90 and would be propably solved by the reffered issue.
Adding the output on a short notice would be a workaround and should only be implemented, if it doesn't take a long time.
Further missing outputs
I didn't found an output for alpha
as well.
My current Workaround
Warning: Will not work with current version. See as outdated.
Here is my current workaround for this. Clearly this yields different CI than the original fitsignal (tested for a parametrized model with the parci.dd) but the difference is only small.
Parametrized models
As I'm mainly intersted in the parameters, I use the from fitsignal
given ci-parameters. This is fine so far. If this is not enough, one could use this:
%% Confidence interval
% Calculate Kernel with background from fitsignal
K = dipolarkernel(t,r,parfit.ex(1),bg_hom3d(t,parfit.bg,parfit.ex(1)));
% Do another fit with start parameters from fitsignal (parfit.dd).
[~,~,~,fitci,~] = fitparamodel(V,gausswlc,r,K,parfit.dd');
Regularization models
%% Confidence interval
% Calculate Kernel with background from fitsignal
K = dipolarkernel(t,r,parfit.ex(1),bg_hom3d(t,parfit.bg,parfit.ex(1)));
% Do another fit with background fit from fitsignal.
[~,fitci,alpha,~] = fitregmodel(V,K,r,'tikhonov','aic');
Downside in this case could be the visible increase in calculation time.
Update:
In the current version 0.9.1 (7cc4f30), the parci
-output of fitsignal
gives back the upper and lower limit of Vfit
, Bfit
and Pfit
. Thank's for implementing this!
Two things I noticed:
fitsignal
is now missing the parameter CIs. So for background, experiment, distance model (distance model only with parametric fit) uncertainties we do not get the upper and lower limit fromfitsignal
. That would be great to reimplement.
Update: This is now in an additional output haven't looked there.[Vfit,Pfit,Bfit,parfit,modfitci,parci,stats]
. Related to #92- The cell structure is a bit nested. Whereas
Pfit
is a 1x2 cell for upper and lower,Vfit
andBfit
are within a 1x1 cell, containing a 1x2 cell. I would prefer thePfit
-version with a 1x2-cell on top. - In the cell structure there are two nx2 arrays contained. Both containing upper/lower limits, I guess with different confident intervalls. Not sure which one is which. Related to #92
Update: Having looked into the source:ConfidenceLevel = [0.95 0.5];
With the new system for confidence intervals and al the changes in fitsignal
these issues have been solved.