[R] calculating an interaction statistic from stratified data

Alvarez, Joann Marie joann.alvarez at Vanderbilt.Edu
Mon Apr 5 00:12:40 CEST 2010

Hi Georg,

Instead of stratifying by sex, use all your data together to fit one model that controls for sex. This gives you more power because of the increased sample size. Also, this way you can add an interaction term, which is what you are looking for. The gender variable should be defined as a factor. Here's an example:

dataframe$sex <- factor(dataframe$sex)

awesomemodel <- lm(outcomevariable ~ sex + x + sex*x, data = dataframe)

Hope this helps,

From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Georg Ehret [georgehret at gmail.com]
Sent: Sunday, April 04, 2010 5:01 PM
To: r-help
Subject: [R] calculating an interaction statistic from stratified data

Dear R community,
   I have data on beta&standard error (for the main effect of variable x),
stratified by sex for my dataset. I wish to calculate the sex-interaction
effect (as beta&se) from these two stratified datasets. Is there a package
to do this? If not, any advice how to do it manually?
Thank you very much and best regards, Georg.
Georg Ehret, JHU, Baltimore

        [[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list