[R] Two-way linear model with interaction but without one main effect

Helios de Rosario helios.derosario at ibv.upv.es
Tue Jun 12 13:35:26 CEST 2012


Hi,

I know that the type of model described in the subject line violates
the principle of marginality and it is rare in practice, but there may
be some circumstances where it has sense. Let's take this imaginary
example (not homework, just a silly made-up case for illustrating the
rare situation):

I'm measuring the energy absorption of sports footwear in jumping. I
have three models (S1, S2, S3), that are known by their having the same
average value of this variable for different types of ground, but I want
to model the energy absorption for specific ground types (grass, sand,
and pavement).

To fit the model I take 90 independent measures (different shoes,
different users for each observation), with 10 samples per footwear
model and ground type.

# Example data:
shoe <- gl(3,30,labels=c("S1","S2","S3"))
ground <- rep(gl(3,10,labels=c("grass","sand","pavement")),3)
Y <- rnorm(90,120,20)

My model may include a main effect of the ground type, and the
interaction shoe:ground, but I think that in this peculiar case I could
neglect the main effect of shoe, since my initial hypothesis is that the
average energy absorption is the same for the three models.

My first thought was fitting the following model (with effect coding,
so that the interaction coeffs have zero mean.):

mod1 <- lm(Y ~ ground + ground:shoe,
    contrasts=list(shoe="contr.sum",ground="contr.sum"))

But this model has the same number of coefficients as a full factorial,
and actually represents the same model subspace, isn't it? In fact, the
marginal means are not the same for the three types of shoes:

# Marginal means for my (random) example data
> tapply(predict(mod1),shoe,FUN=mean)
      S1       S2       S3 
116.3581 121.0858 118.3800

If I'm not mistaken, to create the model that I want I can start with
the full factorial model and remove the part associated to the main shoe
effect:

# Full model and its model matrix
mod1 <- lm(Y~shoe*ground,
    contrasts=list(shoe="contr.sum",ground="contr.sum"))
X <- model.matrix(mod1)
# Split X columns by terms
X1 <- X[,1]
X.shoe <- X[,2:3]
X.ground <- X[,4:5]
X.interact <- X[,6:9]
# New model without method main effect
mod2 <- lm(Y~X.ground+X.interact)

For this model the marginal means do coincide:
> tapply(predict(mod2),shoe,FUN=mean)
     S1      S2      S3 
118.608 118.608 118.608 

My questions are:
Is this correct? And is there an easier way of doing this?

Thanks
Helios De Rosario

-- 
Helios de Rosario Martínez
 
 Researcher


INSTITUTO DE BIOMECÁNICA DE VALENCIA
Universidad Politécnica de Valencia • Edificio 9C
Camino de Vera s/n • 46022 VALENCIA (ESPAÑA)
Tel. +34 96 387 91 60 • Fax +34 96 387 91 69
www.ibv.org

  Antes de imprimir este e-mail piense bien si es necesario hacerlo.
En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección
de Datos de Carácter Personal, le informamos de que el presente mensaje
contiene información confidencial, siendo para uso exclusivo del
destinatario arriba indicado. En caso de no ser usted el destinatario
del mismo le informamos que su recepción no le autoriza a su divulgación
o reproducción por cualquier medio, debiendo destruirlo de inmediato,
rogándole lo notifique al remitente.



More information about the R-help mailing list