Is there a way to automatically calculate the batch mean standard error of the training perplexity of fitlda?

조회 수: 2 (최근 30일)
It is standard practice to calculate the standard error of the training perplexity from an algorithm like fitlda using the method of batch means. See Jones, et al (2006) for detail.
I can do this calculation by hand using fitlda's verbose output. However, the verbose output only gives the training perplexity out to 3 digits. It would be much easier (for me) and more accurate if there were a way to do this automatically.
Is there a way to automatically calculate the batch mean standard error of the training perplexity of fitlda?
Reference:
Jones, Galin L, Murali Haran, Brian S Caffo, and Ronald Neath, "Fixed-width output analysis for Markov chain Monte Carlo," Journal of the American Statistical Association, 2006, 101 (476), 1537-1547.

채택된 답변

Stephen Bruestle
Stephen Bruestle 2019년 1월 24일
I answered this question myself.
While I have found no precise way to calculate batch mean standard error, I have found that you can get precise measurements of perplexity in "mdl.FitInfo.History.Perplexity"
Therefore to calculate batch mean standard error:
% Input Initial Burn
burn = 100;
% Calculate Batch Size (b), number of batches (a), and true burn (whatever is left from a*b)
Matrix = mdl.FitInfo.History.Perplexity;
[m,n] = size(Matrix);
b = floor(sqrt(m-burn));
a = floor((m-burn)/b);
burn = m - a*b;
% Burn initial values
Matrix(1:burn,:)=[];
% Create Groups (G)
G = [];
for t=1:a
temp=t*ones(b,1);
G=[G;temp];
end
% Calculate Batch Means
Y = splitapply(@mean,Matrix,G);
% Calculate Batch Mean Standard Error (stdev)
Ybar = mean(Y) * ones(a,1)
Err = Y-Ybar;
VAR = b/(a-1) * sum(Err.^2);
stdev = sqrt(VAR);
  댓글 수: 2
Wei Wong
Wei Wong 2019년 7월 26일
Hey there! May I know how do we determine the burn value? As setting different burn values will yield different results. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by