FAQ‎ > ‎

Tangent

How to get the tangent vector for a selected time point?

How to get the direction of the curve at time t ?


[pc,net]=nlpca(data, 1) % might be meaningful only for extracting one (k=1) nonlinear component (time series),
                        % or in some special cases, k=2, of extracting the tangent on a point of a curved surface

pc=linspace(min(pc),max(pc),100);
% define 100 points (positions) along the curve (first component)
[data,dz] = nlpca_get_data(net,pc);   % get data and gradient/tangent dz for all component values 'pc'

t = 5; % select a (time) point of interest
pc(:,t); % get component value (PC score) at time t
 
v = dz(:,t); % get tangent/gradient vector v, representing the change over time of all original variables. The largest absolute values tell you which variables have the strongest dynamic (highest change) at the selected point. This can be used to rank the variables by importance: highest impact, reaction, or response at this time (for example: find the genes of highest increase or decrease in activity at time t).


plot selected point (to see the position p of time t on the curve)
nlpca_plot(net);  % plot data and component curve
p = data(:,t)  % get position in original data space
hold on;
plot(p(1,:),p(2,:),'kx','MarkerSize',20,'LineWidth',3);
hold off;