当前位置: 动力学知识库 > 问答 > 编程问答 >

r - testing difference of means by group

问题描述:

I have a dataset consisting of x number of variables, var1, var2, ..., varx

I am interested in variable 1, var1, a factor with three levels;"a","b","c", and how this is affected by the other variables.

I have done some descriptive statistics with

describeBy(dataset, group=var1)

and now I want to look at each variable and see if the means for varj in the different grops "a","b","c".

EDIT 1:

Sorry for not being as clear as I thought I was..

Actually my problem is this, cause I do know that I want to use a two-sided t-test

t.test(varj, alternative="two.sided",conf.level = 0.95,

subset=var1)

I do get a result, but only for the mean of varj, and not for the difference in the different groups.

What am I doing wrong?

EDIT 2:

Think I am a bit to tired for this.

But this is what I have figured out I have to do

anova(lm(var1 ~ varj))

And it seems to work out just fine.

网友答案:

It sounds like a One-Way ANOVA!?

Try this:

model1 = aov(var1 ~ varj)

summary(model1)

If you want to know which pairs/groups are significantly different from each other you can use for instance Bonferroni

pairwise.t.test(var1, varj, p.adj = "bonf")

分享给朋友:
您可能感兴趣的文章:
随机阅读: