Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANOVA in R using summary data

Tags:

r

lm

summary

anova

is it possible to run an ANOVA in r with only means, standard deviation and n-value? Here is my data frame:

q2data.mean <- c(90,85,92,100,102,106)
q2data.sd <- c(9.035613,11.479667,9.760268,7.662572,9.830258,9.111457)
q2data.n <- c(9,9,9,9,9,9)
q2data.frame <- data.frame(q2data.mean,q2data.sq,q2data.n)

I am trying to find the means square residual, so I want to take a look at the ANOVA table.

Any help would be really appreciated! :)

like image 295
y3trgfhsfgr Avatar asked Mar 19 '23 07:03

y3trgfhsfgr


1 Answers

Here you go, using ind.oneway.second from the rspychi package:

library(rpsychi)
with(q2data.frame, ind.oneway.second(q2data.mean,q2data.sd,q2data.n) )

#$anova.table
#                SS df     MS     F
#Between (A) 2923.5  5 584.70 6.413
#Within      4376.4 48  91.18      
#Total       7299.9 53   
# etc etc

Update: the rpsychi package was archived in March 2022 but the function is still available here: http://github.com/cran/rpsychi/blob/master/R/ind.oneway.second.R (hat-tip to @jrcalabrese in the comments)


As an unrelated side note, your data could do with some renaming. q2data.frame is a data.frame, no need to put it in the title. Also, no need to specify q2data.mean inside q2data.frame - surely mean would suffice. It just means you end up with complex code like:

q2data.frame$q2data.mean

when:

q2$mean

would give you all the info you need.

like image 50
thelatemail Avatar answered Mar 28 '23 07:03

thelatemail