Results 1 to 7 of 7

Thread: how to do simple main effect in R?

  1. #1
    Join Date
    Oct 2007
    Beans
    336

    how to do simple main effect in R?

    I know its not a specific R forum but I just wasn't able to find an answer anywhere.
    I'd like to know how can I check for simple main effect using R.
    I did ANOVA (mixed model) and found an interaction, now I need to analyse the interaction. how can I do that?

  2. #2
    Join Date
    Oct 2005
    Location
    Wyoming, USA
    Beans
    488
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: how to do simple main effect in R?

    Quote Originally Posted by orduek View Post
    I know its not a specific R forum but I just wasn't able to find an answer anywhere.
    I'd like to know how can I check for simple main effect using R.
    I did ANOVA (mixed model) and found an interaction, now I need to analyse the interaction. how can I do that?
    If you can provide a simple example, that would help. What do you mean "analyse the interaction"? Mean separation?

    You might try:
    Code:
    ?model.tables
    This looks nothing like my signature...
    My Page

  3. #3
    Join Date
    Nov 2006
    Location
    New Zealand
    Beans
    422

    Re: how to do simple main effect in R?

    Yes, it is very hard to know what you are talking about. It sounds like you need basic statistics help to determine what you actually intend to do - and you don't need anyone to know anything about R to give you that.

    Are you a student? If so, take your problem to a lecturer / teacher who can explain the statistical issue to you. Then if they don't know anything about R, come back here and explain what you want to do a bit better so we can help you.

    I presume you ran a linear model, then ran anova(model). Have you tried summary(model)? That will give you some more information, including contrasts.

  4. #4
    Join Date
    Oct 2007
    Beans
    336

    Re: how to do simple main effect in R?

    I'll explain a bit more:
    I have a mixed model with 2 between subject variable (A and B) each has 2 levels. and one within variable (C) also with two levels.
    When I run ANOVA (using aov or something like that) I get a significant interaction, lets say A*B was significant.
    now I need to further analyse the simple main effect, for example A at b1 and A at b2. these are the simple main effect the compromise (i think this is the right word) the interaction.
    an example table will look like that in R:

    A B C value
    1 1 1 20
    2 1 1 23
    1 2 1 23.5
    2 2 1 32
    1 1 2 37
    etc.

    I hope now its better?
    thanks.

  5. #5
    Join Date
    Nov 2006
    Location
    New Zealand
    Beans
    422

    Re: how to do simple main effect in R?

    Note: I'm no statistics expert, this is just something to try until someone suggests a better solution. It should give you an idea of the effects anyway.

    Considering there are only two levels in the variable, try dividing the dataset into B=1 and B=2, ie:
    B = 1:
    A C value
    1 1 20
    2 1 23

    B = 2:
    A C value
    1 1 23.5
    2 1 32
    etc.

    You could then run a linear model on each of the reduced datasets and see what results you get.
    model <- lm(value ~ A + C + A*C)
    anova(model)

    I am sure there will be a better way of doing this however, and I will watch this thread for a better suggestion, as I'd find it useful myself.

  6. #6
    Join Date
    Oct 2007
    Beans
    336

    Re: how to do simple main effect in R?

    how do I divide the data?
    if I have the list with the two levels, how can I tell R to list the data only with B=1?

    and BTW - this method is OK for within subject variable but when you do a simple main effect on a between variable you should use the error term you of the entire model (based on the fact that larger N is better)

  7. #7
    Join Date
    Sep 2005
    Location
    Los Baños, Laguna
    Beans
    396
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: how to do simple main effect in R?

    Quote Originally Posted by orduek View Post
    how do I divide the data?
    if I have the list with the two levels, how can I tell R to list the data only with B=1?

    and BTW - this method is OK for within subject variable but when you do a simple main effect on a between variable you should use the error term you of the entire model (based on the fact that larger N is better)
    Could create a new subset of the data where B=1

    Code:
    x <- subset(data, data$B==1)
    That way you only have the data you want in a new object. I'm sure there are other ways, this is R after all.
    Earlycj5

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •