% ============
% Description:
% ============
% 
%   Function to model volatility trajectories for high frequency observations
%   in financial markets. 
% 
% Includes the following steps:
% 
% 1) Computing scaled log-returns Z from price observations X.
% 
% 2) Computing Y process from Z, Y(t) = log(Z^2) - q_0.
% 
% 3) Functional principal component analysis for Y process to obtain the functional volatility process V(t),
%    defined as V(t) = log(\sigma(t)^2).
%
% References:  
% M\"uller, H.G., Sen, R., Stadtm\"uller, U. (2011). Functional Data Analysis for Volatility. J. Econometrics 165,
    233--245.
% M\"uller, H.G., Stadtm\"uller, U., Yao, F. (2006). Functional %variance processes. Journal of the American Association, 101, 
%1007-1018. 
% ========
% Usage:
% ========
% 
%     [V,t, yy] = Fvola(X, T, param)
% 
%======
%Input: 
%======
%      X:          n*p matrix, X(i, j) is the price for subject i at time
%                  t(j). X must be positive and in a dense and regular
%                  design. 
%      T:          1*p vector contains t(j), 1<=j<=p. It must be a regular design, 
%                  i.e., delta= t(j+1) - t(j)are the same for all j.  
%      param:          a struct obtained from setOptions.m sets the rest of arguments for PCA.m
%                  ex:
%                  >> param = setOptions();
%=======
%Output:  
%=======  
%     V(t):        The estimated functional volatility process V(t) = log(\sigma(t)^2).
%     t:           the corresponding time grid for V(t);
%     yy:          a cell array that contains all returned values from
%                  PCA.m for the process Y(t) = V(t) + U(t); 
%      
%
%   To see the names for yy, type names(yy)
%   To get individual values back, type getVal(yy,varname)
%   To see an example, check with example.m
%   See also FPCA, PCA, example, names
%
% Note: Squared Z are adjusted by adding the 10th percentile of % the pooled sample before taking log.