필터 지우기
필터 지우기

how can I make goodness of fit test for my calculated AICc for a neuron's spike train

조회 수: 3 (최근 30일)
Hellow everyone
I have a spike information of a neuron based on X and Y coordinates by time (because this data is collected from Place Cells of an aminal). Based on this data I propose a conditional intensity function (CIF) and run the following codes to calculate required information.
Here is my code ;
load('datasetofneuron.mat'); % I am loading the data from file
t=0:1e-3:T; % building the t variable (T is total duration, 1e-3 is the step size
Z=[X,Y,X.*Y]; % my proposed CIF function
et=zeros(size(t)); % my event train (et) filling with zeros
et(round(neuron.spikeTimes*1e3))=1; % replacing 1 for
et=et(1:size(Z,1));
mdl=fitglm(Z,et','distr','Poisson'); % fitting the generalized linearized model by poisson distribution
L = mdl1.LogLikelihood; % finding the loglikelihood
AICc1 = mdl1.ModelCriterion.AICc;
beta_values=mdl.Coefficients.Estimate; % finding the estimated beta coefficients
beta_values_count= mdl1.NumCoefficients; % how many beta values will I have
Ldt=exp(beta_values(1)+XX*beta_values(2)+YY*beta_values(3)+XX.*YY*beta_values(4)); % Lambda*dt
% after then, I need to make a goodness-of-fit test (KS and autocorrelation)
after this line, I need to make a goodness-of-fit (KS and autocorrelation tests). Could you please help me how can I code in Matlab?
Thank you

답변 (1개)

Abhishek
Abhishek 2023년 5월 16일
Hi Mustafa,
I understand that you want to apply certain goodness-of-fit tests, namely Kolmogorov-Smirnov (KS) test and autocorrelation test for your dataset.
For KS test, you could perform Two-sample Kolmogorov-Smirnov test. First simulate a new set of data points based on the model by drawing random numbers from a Poisson distribution with the same mean as the data. Then compare the simulated data to a Poisson distribution with the same mean as the new set using the 'kstest2' function.
Assume that your original dataset is 'x1'. You can simulate a net set if data points based on the model using: -
x2 = poissrnd(Ldt)
Then apply the function 'kstest2' as follows: -
[h,p,ks2stat] = kstest2(x1,x2,'Alpha',0.01)
where 'h' is hypothesis test result, 'p' is Asymptotic p-value and 'ks2stat' is the test statistic. 'Alpha' can be varied between (0,1) based on significance level of desirability.
You can know more about KS tests from these documentation pages: -
  1. One-sample Kolmogorov-Smirnov test - MATLAB kstest (mathworks.com)
  2. Two-sample Kolmogorov-Smirnov test - MATLAB kstest2 (mathworks.com)
For autocorrelation test, you can use 'xcorr' function of MATLAB to compute the autocorrelation function (ACF) of the residuals, where residual = data - fit. Further you can use 'stem' function to plot the ACF.
residuals = et' - Ldt; %Calculate the residual
[acf, lags] = xcorr(residuals,'coeff') %Calculate the autocorrelation
For more information regarding the ACF function, refer to the documentation: Cross-correlation - MATLAB xcorr (mathworks.com).

카테고리

Help CenterFile Exchange에서 Neural Simulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by