How to asses interaction in a Poisson Generalized Linear Model?

4 views (last 30 days)
Hi all,
I am running a poisson Generalized linear model using fitglm, but I am still having issues interpreting the interactions. In particular, I am trying to asses the interaction terms using the plotInteraction function but then I get an error:
Undefined function or variable 'plotInteraction'.
I am having more than one interactions the response I am looking at is quite complex so I would like to categorize my data based on the different interactions I am looking at. When I am running the example with the linear regression, things run smoothly. Is it because the function doesn't support inputs from a Generalized Linear model?
Best,
Konstantinos
  3 Comments
Adam Danz
Adam Danz on 4 Mar 2021
plotInteraction is a method defined in the LinearModel & CompactLinearModel classes. fitglm produces a GeneralizedLinearModel object which is why it's not accepted/recognized in plotInteraction.
Kostantinos Koukoutselos
Kostantinos Koukoutselos on 4 Mar 2021
Edited: Kostantinos Koukoutselos on 4 Mar 2021
Thanks a lot guys. This is what I suspected that the issue comes from the GenralizedLinearModel. Would you have any suggestion on how to come around this? I thought of creating a table with "conditional first differences'' that I read on this paper. The idea here is to keep the X predictors of no interest at a constant value (mean value of the X predictor) while changing the value of the predictor which we would like to assess by setting 2 values (in my case I get the min and max). Thus, I can create a table which can depict the ''effect'' of each interaction.
My code:
modelspec = 'Var1 ~ Trial_Nr + Time_within + cls_opn + Trial_Nr:cls_opn + Trial_Nr:Time_within + cls_opn:Time_within';
  • I want to asses the activity respose of neurons in a task based on the above X predictors. The cls_opn is categorical variable
i_idx = 1;
for i_idx = 1:size(Y,2) % Y is a matrix containinng the activity of the neurons in bins of one sec
ytable = array2table(Y(:,i_idx)); vartable = [X_ess_table ytable];
PoissonGLMessential_TEST1(i_idx).Neurons = fitglm(vartable,modelspec,'Distribution','poisson','CategoricalVars',[3]);
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!