genomicsclass / labs

Rmd source files for the HarvardX series PH525x
http://genomicsclass.github.io/book
MIT License
2.01k stars 1.95k forks source link

Different t.test result in type II error simulation #95

Open isaid-hi opened 4 years ago

isaid-hi commented 4 years ago

Hi, Prof. Rafa! I'm using R 3.6.3 version and doing some false negative demonstration based on edX PH525x course. i'm using exactly same code with the lecture video and the book. Here is it ` dat <- read.csv("mice_pheno.csv")

controlPopulation <- filter(dat,Sex == "F" & Diet == "chow") %>% select(Bodyweight) %>% unlist

hfPopulation <- filter(dat,Sex == "F" & Diet == "hf") %>% select(Bodyweight) %>% unlist

mu_hf <- mean(hfPopulation) mu_control <- mean(controlPopulation)

mu_hf - mu_control [1] 2.375517 (mu_hf - mu_control)/mu_control * 100 # percent increase [1] 9.942157 ' So far the result still the same with the video. After that: ' set.seed(1) N <- 5 hf <- sample(hfPopulation,N) control <- sample(controlPopulation,N) t.test(hf,control)$p.value the result supposed to be0.1410204, but my result is0.5806661`. I retried for several times and several generating value method, but the result hasn't changed.

Seeing that this material was last edited 4 years ago, then I think that there is a logarithmic difference in the 'set.seed()' function.

Glad if you help me

Annechien commented 4 years ago

Hi, did you check the information here: link

I guess you can just play around a bit with the RNG version and/or RNGkind