Description
Hello there. This is such a great package - thank you for the work in creating it. I am curious about best practices for calculating average marginal effects for interaction terms while using errorsarlm model objects. Standard packages that do this with many other model objects do not work with Sarlm model objects created by the errorsarlm model prediction.
Consider the model Y ~ X1 + X2 + X1*X2, where Y is continuous, X1 is continuous, and X2 is categorical. I calculate this basic OLS interaction model within the errorsarlm command to consider the role of correlated errors in the OLS, and the roll of spillover from the model Xs. I use the impacts command to view the total effects (direct + indirect + lamda), total SE, and total p-value for each coefficient.
I am trying to calculate the beta coefficient and standard error/p-value for the interaction term at various levels of X1. Typically, one uses the margins package or ggeffects package to do this. However, they do not handle errorsarlm model objects. I have inquiries into ggeffects and margins about expanding thier model capabilities, but the issue of considering the spatail weights matrixes when calculating SE I think will prevent these packages from considering a solution.
I have "brute forced" the total effects beta coefficients from the impacts command into the nested lm regression model object in order to use ggeffects and margins, but the standard errors are wrong, of course. The lm model object does not use the weights matrix for accounting for Rho, lamda, etc.
I can also easily calculate point estimates at different levels of the continuous X variable, but I am unsure how to calculate correct SEs. ad different X1 values.
Are there best practices for considering marginal effects at various levels of the interaction model terms? Or is this completed within the impacts command and I am misunderstanding the output or flexibility of impacts? Alternatively, can I use the impacts output and model object to do the work manually? (stated another way: Is the impacts function flexible to predict beta, SE, and p at various levels?)
Seems like others have similar issues, and I have found no real workaround in the Stack communities. See here.
Attached is a short script with a toy example (nonsense model), but the issue exists for all errorsarlm model objects, I believe.
Thank you for you attention and help. Apologies if this question has been considered already, or if I am misunderstanding or underutilizing the impacts output.