Documentation of regress_dan


Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)


Function Synopsis

fld=regress(tm,dat,lag);

Help text


  fld=regress(tm,dat);

  This function returns the field <fld> that is a vector consisting
  of the regression coefficient of the time series <tm> onto the 
  time series of data (columns of dat) for each point.  It can be 
  made into a spatial map by the reshape command.


Listing of function regress_dan

function fld=regress(tm,dat,lag);
if nargin < 3; lag=0; end;

[m,n]=size(tm); 
if m~=1; tm=tm'; [m,n]=size(tm); end;

[l,k]=size(dat);
if l ~= n; dat=dat'; end;

if lag < 0;
  tm=tm((1-lag):n);
  dat=dat(1:(n+lag),:);
end;
if lag > 0;
  tm=tm(1:(n-lag));
  dat=dat((1+lag):n,:);
end;

for i=1:k
  wt(i)=sqrt(dat(:,i)'*dat(:,i));
end

fld=(tm*dat/sqrt(tm*tm'))./wt;