# Specifying constant as intercept in logistic regression using R

I am trying to replicate a logistic regression analysis from a paper using R in lme4 (the specific analysis in the paper uses the glmfit function in Matlab). In it, they conduct a logistic regression on a binary outcome (0 or 1) to determine the beta coefficients of 8 predictors (using the betas as evidence for how much weight that predictor had over the outcome) over multiple trials for each subject.

They describe the coding of their dataset as:

The predictors were coded as a vector of dimensions (trials x 9) matrix where 1-8 constituted relevant values for the outcome, and vector 9 was a constant term to estimate the intercept.

Additionally, subject was a random variable.

In my R code (using lme4), I interpreted this as forcing a zero intercept, thus I wrote the regression model like so:

logr.model <- glmer(outcome ~ -1 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + (1|subject),


• That description seems labored and therefore unnecessarily confusing, but I wouldn't have interpreted that as forcing a zero intercept. – The Laconic Sep 23 '17 at 22:15

This description:

The predictors were coded as a vector of dimensions (trials x 9) matrix where 1-8 constituted relevant values for the outcome, and vector 9 was a constant term to estimate the intercept.

Doesn't sound like a zero-intercept model.

What they are saying here is that they used a constant (1) for the intercept which R likely does by default.

A bit of explanation below.

If you have a model like so:

y = b0 + b1x1 + b2x2 + ... + b8x8 + e


Here bi are coefficients.

You can write it as:

y = 1b0 + b1x1 + b2x2 + ... + b8x8 + e


Note the "1" before the 'b0'. That's the constant they were talking about. When they arrange their data into a matrix format, so that all x1 ... x8 form 8 columns - they add that constant column of 1s for the intercept.

R does this by default (at least the lm() function) but you can also specify it by explicitly adding it:

lm(1 + x1 + x2 + ..., data=data)