Unverified Commit 4974adb8 authored by Meryem Ayşe Yücel's avatar Meryem Ayşe Yücel Committed by GitHub
Browse files

Dev may2 (#167)

* Update ar_fit.m

Fixing bug in filename stepwise->stepwisefit, and the relevant extracted output.

* Update ar_glm_final.m

Reducing the number of max iterations to 10 for the sake of computational time.

* Update ar_glm_final.m

fix
Pmax 10->100

* AR p order

Order was hardcoded, changed it be 2 X sampling frequency.
parent d0fac4b2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ for iBlk = 1:length(data_y)
    tInc = tIncAuto{iBlk};
    
    dt = t(2) - t(1);
    fq = 1/dt;
    nPre = round(trange(1)/dt);
    nPost = round(trange(2)/dt);
    nTpts = size(y,1);
@@ -600,7 +601,7 @@ for iBlk = 1:length(data_y)
                    ytmp = y(lstInc,conc,lstML);
                    for chanIdx=1:length(lstML)
                        ytmp2 = y(lstInc,conc,lstML(chanIdx));
                        [dmoco, beta, tstat(:,lstML(chanIdx),conc), pval(:,lstML(chanIdx),conc), sigma, CovB(:,:,lstML(chanIdx),conc), dfe, w, P, f] = ar_glm_final(squeeze(ytmp2),At(lstInc,:));
                        [dmoco, beta, tstat(:,lstML(chanIdx),conc), pval(:,lstML(chanIdx),conc), sigma, CovB(:,:,lstML(chanIdx),conc), dfe, w, P, f] = ar_glm_final(squeeze(ytmp2),At(lstInc,:), round(fq*2));

                        foo(:,lstML(chanIdx),conc)=beta;
                        ytmp(:,1,chanIdx) = dmoco; %We also need to keep my version of "Yvar" and "Bvar"                    
+4 −1
Original line number Diff line number Diff line
@@ -26,7 +26,10 @@ if(nosearch)
    coef = invR * Q'*yy(lstValid);
    res = yy(lstValid) - X(lstValid,:)*coef;
else
    [coef, res] = stepwise(X(lstValid,:), yy(lstValid));
    [B,SE,PVAL,in,stats,nextstep,history] = stepwisefit(X(lstValid,:), yy(lstValid),'Display','off');
    coef = B;
    res = stats.yr; 
%     [coef, res] = stepwisefit(X(lstValid,:), yy(lstValid));
end
res = res(1:n);
yhat = y - res;
+1 −2
Original line number Diff line number Diff line
function [dmoco, beta, tstat, pval, sigma, CovB, dfe, w, P, f] = ar_glm_final( d,X,tune )
function [dmoco, beta, tstat, pval, sigma, CovB, dfe, w, P, f] = ar_glm_final( d,X,Pmax )

    % preallocation
    dmoco = zeros(size(d));
@@ -22,7 +22,6 @@ function [dmoco, beta, tstat, pval, sigma, CovB, dfe, w, P, f] = ar_glm_final( d
            
            res = y-X*B;
            
            Pmax = 100;
            a = robust_ar_fit(res, Pmax);
            f = [1; -a(2:end)];