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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Helios de Rosario
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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Two-way linear model with interaction but without one main effect

Thierry Onkelinx
Dear Helios,

I think you rather want a mixed model with shoe as random effect.

library(lme4)
lmer(Y ~ Ground + (1|Shoe)) #the effect of shoe is independent of the ground effect
or
lmer(Y ~ Ground + (0 + Ground|Shoe)) #the effect of shoe is different per ground.

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
[hidden email]
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-----Oorspronkelijk bericht-----
Van: [hidden email] [mailto:[hidden email]] Namens Helios de Rosario
Verzonden: dinsdag 12 juni 2012 13:35
Aan: [hidden email]
Onderwerp: [R] Two-way linear model with interaction but without one main effect

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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Two-way linear model with interaction but without one main effect

Helios de Rosario
Thanks for the suggestion, Thierry.

Nevertheless, in this example I'm not considering "shoe" as a random,
nuisance factor with zero mean. I'm considering three specific shoe
models, and I'm interested in modelling how the output changes between
the different shoes for those grounds, given that the average output is
the same for all shoes. That's not the type of question addressed by a
mixed model, I'm afraid.

Helios

>>> El día 12/06/2012 a las 14:17, "ONKELINX, Thierry"
<[hidden email]>
escribió:
> Dear Helios,
>
> I think you rather want a mixed model with shoe as random effect.
>
> library(lme4)
> lmer(Y ~ Ground + (1|Shoe)) #the effect of shoe is independent of the
ground
> effect
> or
> lmer(Y ~ Ground + (0 + Ground|Shoe)) #the effect of shoe is different
per
> ground.
>
> Best regards,
>
> Thierry
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for
Nature and
> Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality
Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> [hidden email]
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no
more than
> asking him to perform a post-mortem examination: he may be able to
say what
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does
not
> ensure that a reasonable answer can be extracted from a given body of
data.
> ~ John Tukey
>
>
> -----Oorspronkelijk bericht-----
> Van: [hidden email]
[mailto:[hidden email]]
> Namens Helios de Rosario
> Verzonden: dinsdag 12 juni 2012 13:35
> Aan: [hidden email]
> Onderwerp: [R] Two-way linear model with interaction but without one
main
> effect
>
> 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.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help 
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code.
> * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * *
*
> Dit bericht en eventuele bijlagen geven enkel de visie van de
schrijver weer
> en binden het INBO onder geen enkel beding, zolang dit bericht niet
bevestigd
> is door een geldig ondertekend document.
> The views expressed in this message and any annex are purely those of
the
> writer and may not be regarded as stating an official position of
INBO, as
> long as the message is not confirmed by a duly signed document.

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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.