Degrees of freedom in a kernel density estimation

조회 수: 7 (최근 30일)
Francisco de Castro
Francisco de Castro 2020년 2월 25일
답변: Francisco de Castro 2023년 6월 20일
Is there any way to estimate the degrees of freedom from a kernel density estimator?
Background: I want to compare the fitting I get with a parametric distribution with that of a kernel density estimation (with ksdensity). By 'compare' I mean to use the Akaike IC. I can calculate the loglikelihood with the info that ksdensity returns, but what about the number of parameters (or degrees of freedom)? How many parameters does ksdensity actually estimates? According to the literature the trace of the smoothing matrix is a good estimate of the DOF, but this matrix is not returned by ksdensity.
Any ideas?
Thanks

채택된 답변

Francisco de Castro
Francisco de Castro 2023년 6월 20일
I found a solution for my own question. The degrees of freedom can be can be estimated as the trace of the smoothing matrix. This matrix is not returned by ksdensity, but it can be calculated as detailed below. Assume: 'data' is the vector of data and mormalf is the value of a Normal dist. at x= 1st argument, with mean= 2nd argument, and std= 3rd argument.
[Kpdf,mesh,bandw]= ksdensity(data,data);
N= numel(data);
S= zeros(N);
for k= 1:N
S(k,:)= normalf(data,data(k),bandw);
end
degreesfreedom= trace(S);

추가 답변 (0개)

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by