function mv = mvavg(tsobj, lag)

% tsobj: input variables T by N
% lag: simple moving average with K lags
% MatLab's tsmovavg set the first K-1 mv to be zeros.
[T N] = size(tsobj);
mv = tsmovavg(tsobj, 's', lag, 1);
for t = 1:lag-1
 mv(t,:) = mean(tsobj(1:t,:),1);
end
