Anova, sttatistics, predictmeans

Hello team,

I have a Anova related question and would really appreciate some help.

I am trying to great a table with:
The estimate differences between means,
Standard error of the differences (SED), and the 95% confidence intervals for the differences between means.

I can generate some results using predict means but this does not give me the pairwise comparisons needed above.

Does anyone know of a way to do this?

Thank you heaps!!

I am using Iris as some mock code.

IRISLM<- lm(`Sepal.Width`~`Species`, data = iris)
# you may need to install the predictmeans packadge
library(predictmeans)
predictIRIS<-predictmeans(IRISLM, modelterm = "Species",  pairwise = TRUE)
suppressPackageStartupMessages({
  library(predictmeans)
})

IRISLM <- lm(`Sepal.Width` ~ `Species`, data = iris)
predictIRIS <- predictmeans(IRISLM, modelterm = "Species", pairwise = TRUE)
predictIRIS[3] # or predictIRIS$`Standard Error of Differences`
#> $`Standard Error of Differences`
#>    Max.SED    Min.SED   Aveg.SED 
#> 0.06793755 0.06793755 0.06793755
predictIRIS$mean_table
#>      Species Predicted means Standard error  Df LL of 95% CI UL of 95% CI
#> 1     setosa           3.428      0.0480391 147     3.333064     3.522936
#> 2 versicolor           2.770      0.0480391 147     2.675064     2.864936
#> 3  virginica           2.974      0.0480391 147     2.879064     3.068936
1 Like

Thank you for you answer!

I mean, how to get information for the difference between the means e.g.
SED of setosa - versicolor = ?
SED of versicolor - virginica =?

95% CI of setosa - versicolor = ?
ect.

sorry for the confusion

I'm going to go back to this tomorrow. I think it can be done, but I don't this predictmeans is the right tool.

1 Like

OK, standard error of the differences is just a paired t.test.

suppressPackageStartupMessages({
  library(dplyr)
})

iris1 <- iris %>% filter(Species != "virginica")
iris2 <- iris %>% filter(Species != "versicolor")
iris3 <- iris %>% filter(Species != "setosa")

s_ver <- t.test(Sepal.Width ~ Species, paired = TRUE, data = iris1)
s_vir <- t.test(Sepal.Width ~ Species, paired = TRUE, data = iris2)
ver_vir <- t.test(Sepal.Width ~ Species, paired = TRUE, data = iris3)

s_ver
#> 
#>  Paired t-test
#> 
#> data:  Sepal.Width by Species
#> t = 8.8506, df = 49, p-value = 9.857e-12
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#>  0.508597 0.807403
#> sample estimates:
#> mean of the differences 
#>                   0.658
s_ver$stderr
#> [1] 0.07434558
s_vir
#> 
#>  Paired t-test
#> 
#> data:  Sepal.Width by Species
#> t = 6.4698, df = 49, p-value = 4.399e-08
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#>  0.3129833 0.5950167
#> sample estimates:
#> mean of the differences 
#>                   0.454
s_vir$stderr
#> [1] 0.07017238
ver_vir
#> 
#>  Paired t-test
#> 
#> data:  Sepal.Width by Species
#> t = -3.0755, df = 49, p-value = 0.003432
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#>  -0.33729519 -0.07070481
#> sample estimates:
#> mean of the differences 
#>                  -0.204
ver_vir$stderr
#> [1] 0.06633003

Thank you!!
I really appreciate you taking the time to do this

1 Like