class: center, middle, inverse, title-slide .title[ # Which test statistics is better? for two-sample hypothesis test ] .subtitle[ ## a simulation study ] .author[ ### Lin Yu ] .date[ ### 2023-03-28 ] --- # Distributions we considered **normal ** and **nonnormal ** (uniform, weibull) distributions <img src="data:image/png;base64,#statistical_inference_simulation_study_files/figure-html/unnamed-chunk-1-1.png" style="display: block; margin: auto;" /> --- # Scenarios We simulated different settings, simply put, - sample size varies from 10(small) to 1000(large); - different magnitude of diff between `\(\mu_1\)` and `\(\mu_2\)`, `\(sd_1\)` and `\(sd_2\)`; - finally, both normal and nonnormal distribution were tested. Details are noted in the following table: |parameter|description|setting| |---------|-----------|-------| | `\(\mu_1\)` |mean of population 1|c(0.1,1,3,5)| | `\(\mu_2\)` |mean of population 2|c(1,3,10)| | `\(sd_1\)` |standard deviation of ppl 1|c(1,5,10)| | `\(sd_2\)` |standard deviation of ppl 2|c(0.1,1,10) | `\(nsample_1\)` |sample size of ppl 1 |c(10,20,30,50,100,1000) | `\(nsample_2\)` |sample size of ppl 2 |c(10,20,30,100,1000) | `\(dist\)`| study population distribution|normal, uniform, and weibull --- # Pseudo-code ```r function(seed,mu1,mu2,sd1,sd2,nsample1,nsample2,dist,Nsim){ #### for loop over all paramaters for (parameter in 1:length(mu1)){ ------------------------------------------------------- #### calculate the test stats and pval for Nsim times for(i in 1:Nsim){ dat1 = dat2 = test_stats = pval = } -------------------------------------------------------- #### calculate type I error and power by counting pval/Nsim } } ``` --- # Results ```r ##wide table to long table library(tidyr) ``` ``` ## Warning: 程辑包'tidyr'是用R版本4.1.3 来建造的 ``` ```r long <- final_res %>% pivot_longer( cols = `t_equal`:`wilcox`, names_to = "test_stat", values_to = "value", ) ```
---
--- class: center, reverse, middle # Type I error --- ![](data:image/png;base64,#statistical_inference_simulation_study_files/figure-html/unnamed-chunk-10-1.png)<!-- --> --- class: center, reverse, middle # Statistical power --- ![](data:image/png;base64,#statistical_inference_simulation_study_files/figure-html/unnamed-chunk-11-1.png)<!-- -->