function [alpha] = hillols(x, kfrac,sign) % function alpha = hillols(x, kfrac, sign) % x = time series (univariate) % kfrac = fraction in tail (can be vector for comparison) % sign = +1 right, -1 left tail, 0 pool left and right % Returns: alpha (the tail index) = 1/gamma (the shape parameter) % % Requires: hill.m % % This code is based on the estimator developed in: % Huisman, R., Koedijk, K. G., Kool, C. J. M. & Palm, F. (2001), % Tail-index estimates in small samples, % Journal of Business and Economic Statistics 19, pages 208-216 % n = length(x); % set range sizes - double for pooled tails if (sign ~= 0) kvec = fix(kfrac*n); else kvec = fix(2*kfrac*n); end h = zeros(length(kvec),1); % first do hills % set up recommended regression points at 5 to kvec fullk = 5:1:kvec(end); % now get vector of hills - this is costly, so do it once h = hill(x,fullk,sign); % Now implement the OLS part for each length for j = 1:length(kvec) hreg = h(1:kvec(j)-4); kreg = 5:1:kvec(j); % weighting for WLS wt = sqrt(kreg); hreg = hreg.*wt; kx = kreg.*wt; xx = [wt' kx']; % standard OLS estimator (this is WLS from wt weights) beta = inv(xx'*xx)*(xx'*hreg'); % bias adjusted hill estimate is in constant term % estimate is for, gamma, the shape parameter % tail index (alpha) = 1/gamma alpha(j) = 1/beta(1); end