Processing math: 100%
Saltar al contenido principal
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
LibreTexts Español

11.4: Simulación de ANOVA de un factor

( \newcommand{\kernel}{\mathrm{null}\,}\)

A continuación se construyen datos simulados para un ANOVA de un factor, apropiado para un diseño entre sujetos. Construimos el marco de datos con una columna para los niveles de factor de grupo y una columna para el DV. Entonces, ejecutamos el ANOVA y lo imprimimos.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

library(xtable)
N <- 10
groups <- rep(c("A","B","C"), each=10)
DV <- c(rnorm(100,10,15),   # means for group A
        rnorm(100,10,15),   # means for group B
        rnorm(100,20,15)    # means for group C
        )
sim_df<-data.frame(groups,DV)
aov_results <- summary(aov(DV~groups, sim_df))
knitr::kable(xtable(aov_results))
library(xtable)
N <- 10
groups <- rep(c("A","B","C"), each=10)
DV <- c(rnorm(100,10,15),   # means for group A
        rnorm(100,10,15),   # means for group B
        rnorm(100,20,15)    # means for group C
        )
sim_df<-data.frame(groups,DV)
aov_results <- summary(aov(DV~groups, sim_df))
knitr::kable(xtable(aov_results))
  Df Suma Sq Cuadrados medios Valor F Pr (>F)
grupos 2 1187.127 593.5635 2.683555 F)" style="vertical-align:middle;">0.0699765
Residuales 297 65692.093 221.1855 NA F)" style="vertical-align:middle;">NA

En este siguiente ejemplo, simulamos el mismo diseño 100 veces, guardamosp los valores -y determinamos la proporción de simulaciones significativas.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

N <- 10
save_p<-length(100)
for(i in 1:100){
  groups <- rep(c("A","B","C"), each=10)
  DV <- c(rnorm(100,10,15),   # means for group A
          rnorm(100,10,15),   # means for group B
          rnorm(100,20,15)    # means for group C
          )
  sim_df<-data.frame(groups,DV)
  
  aov_results <- summary(aov(DV~groups, sim_df))
  save_p[i]<-aov_results[[1]]$`Pr(>F)`[1]
}
length(save_p[save_p<0.05])/100
N <- 10
save_p<-length(100)
for(i in 1:100){
  groups <- rep(c("A","B","C"), each=10)
  DV <- c(rnorm(100,10,15),   # means for group A
          rnorm(100,10,15),   # means for group B
          rnorm(100,20,15)    # means for group C
          )
  sim_df<-data.frame(groups,DV)
  
  aov_results <- summary(aov(DV~groups, sim_df))
  save_p[i]<-aov_results[[1]]$`Pr(>F)`[1]
}
length(save_p[save_p<0.05])/100
0.07

This page titled 11.4: Simulación de ANOVA de un factor is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Matthew J. C. Crump via source content that was edited to the style and standards of the LibreTexts platform.

Support Center

How can we help?