2

Many questions (e.g., Centering in linear regression & How to include a linear and quadratic term when also including interaction with those variables? ) have been asked about mean centering (aka demeaning) higher order terms in linear models. Does anyone know how common statistics packages handle mean centering for these higher order (e.g., quadratic) terms?

Here's an example. Let's say our data table (tbl) includes only an outcome variable, y, and a predictor, x, and we would like to run a GLM that includes an intercept, the linear term, and the quadratic term. Sample syntax (for fitglm in MATLAB):

mdl = fitglm(tbl,'purequadratic')

(Here, I've used modelspec to add the quadratic term to the model.)

In this case, would MATLAB (or another statistics package like SPSS) remove the mean by

  1. mean centering x and then squaring that term or
  2. squaring x and then mean centering x^2

when modeling the quadratic term?

What is the "more correct" method?

shabtastic
  • 21
  • 2
  • MATLAB is proprietary software. We cannot know what procedures are implemented by the underlying code. At any rate, this question is off-topic here. You may want to rephrase this in a non-software specific way, or it may be closed. – gung - Reinstate Monica Jun 02 '15 at 17:32
  • @gung We know that e.g. `mean` computes a mean, which is implemented in the "underlying code." There are a million other questions that refer to specific software packages on .SX, how is this any different? – kyle Jun 02 '15 at 17:43
  • 1
    @kyle, there are many questions on CV that are related to various software, but questions that are purely about software & not about statistics are off-topic here & have been for a long time. 'Would 1 or 2 be better for X?' is a statistical question & would be on-topic here; 'Is MATLAB doing 1 or 2?' is a question about MATLAB, not a question about statistics. It is off-topic here. – gung - Reinstate Monica Jun 02 '15 at 17:51
  • 1
    @gung fair points, but the question asks about general practices of mean centering (which I would answer but I have no idea), then gives MATLAB as an explicit example. The question could easily be rephrased as "What software package should I use to obtain mean-centering method X?" They're functionally isomorphic, and the restatement is a valid expression of "Would 1 or 2 be better for X?", so the question itself should be okay... – kyle Jun 02 '15 at 17:55
  • @kyle, the question does use MATLAB as an explicit example, but the general question is "how [do] common statistics packages handle mean centering for these higher order (e.g., quadratic) terms?", & "would MATLAB (or another statistics package like SPSS) remove the mean by ...?" Those are still off-topic. I do think that a re-phrasing of the Q in software neutral terms may well be on-topic & serve the OP's needs. I advised the OP to try that. – gung - Reinstate Monica Jun 02 '15 at 18:01
  • 2
    @kyle and (@gung probably): MATLAB is "semi-opensource" at times. This is one of those times. Just type `edit fitglm`(and then probably `edit GeneralizedLinearModel.fit`) and see the exact code used. (You can even overwrite it and totally mess up your MATLAB installation! :) ) – usεr11852 Jun 02 '15 at 18:18
  • @gung OK, we disagree but this is a massive clarification in the edit request. – kyle Jun 02 '15 at 18:26
  • @usεr11852 good to know! This is one of the more nefarious MATLAB "hacks" :) – kyle Jun 02 '15 at 18:26

0 Answers0