| Both sides previous revisionPrevious revisionNext revision | Previous revision | 
| c:ms:2017:schedule:week15 [2017/06/14 09:09]  –  hkimscil | c:ms:2017:schedule:week15 [2017/06/15 09:02] (current)  –  hkimscil | 
|---|
| ====== t-test ======  | https://goo.gl/forms/x7NUmOxm2DxKmpd62  | 
| <code>x <- rnorm(10, mean=100, sd=15)  |   | 
| x  | ====== two sample t-test ======  | 
| t.test(x, mu=95) | <code>x1 <- rnorm(10, mean=100, sd=15)  | 
|   | x1  | 
|   | t.test(x1, mu=95) | 
| </code> | </code> | 
|   |   - What is the std error value? | 
|   |   - What if you have a sample with a large size? | 
|   |     * How do you get your se? | 
|   |  | 
|   | <code>ster <- sd(x1)/sqrt(length(x1)) | 
|   | difx <- mean(x1)-95 | 
|   | tvalue <- difx/ster | 
|   |  | 
|   | difx | 
|   | ster | 
|   | tvalue | 
|   |  | 
|   | </code> | 
|   |  | 
|   | <code>x2 <- rnorm(100, mean=100, sd=15) | 
|   | head(x2) | 
|   | tail(x2) | 
|   | t.test(x2, mu=95) | 
|   |  | 
|   | ster <- sd(x2)/sqrt(length(x2)) | 
|   | difx <- mean(x2)-95 | 
|   | tvalue <- difx/ster | 
|   |  | 
|   | difx | 
|   | ster | 
|   | tvalue | 
|   |  | 
|   | </code> | 
|   |  | 
|   | <code>mtcars | 
|   | mtcars$mpg | 
|   | mtcars$am | 
|   |  | 
|   | t.test(mtcars$mpg~mtcars$am) | 
|   | </code> | 
|   |  | 
|   | ====== one sample t-test 2 ====== | 
|   |  | 
|   | <code>a = c(65, 78, 88, 55, 48, 95, 66, 57, 79, 81) | 
|   | mean(a) | 
|   | sd(a) | 
|   |  | 
|   | t.test(a, mu=60) | 
|   | </code> | 
|   | ====== Faired sample t-test ====== | 
|   |  | 
|   | <code>sleep | 
|   |  | 
|   | sleep.wide <- data.frame( | 
|   |     ID=1:10, | 
|   |     group1=sleep$extra[1:10], | 
|   |     group2=sleep$extra[11:20] | 
|   | ) | 
|   | sleep.wide | 
|   |  | 
|   | t.test(sleep.wide$group1 - sleep.wide$group2, mu=0, var.equal=TRUE) | 
|   | t.test(sleep.wide$group1, sleep.wide$group2, paired=TRUE) | 
|   | </code> | 
|   |  | 
|   | {{:survey_ms_2017.sav}} | 
|   | ---- | 
|   | gender: male vs. female | 
|   |  | 
|   | <code>T-TEST GROUPS=tend(1 2) | 
|   |   /MISSING=ANALYSIS | 
|   |   /VARIABLES=bigco smallco likeprog | 
|   |   /CRITERIA=CI(.95). | 
|   | </code> | 
|   |  | 
|   | <code>T-TEST GROUPS=tend(1 2) | 
|   |   /MISSING=ANALYSIS | 
|   |   /VARIABLES=selfprom ethalright | 
|   |   /CRITERIA=CI(.95). | 
|   | </code> | 
|   |  | 
|   | ---- | 
|   | tendency - hum/soc vs. natsc/eng | 
|   |  | 
|   | <code>T-TEST GROUPS=gender(1 2) | 
|   |   /MISSING=ANALYSIS | 
|   |   /VARIABLES=bigco smallco likeprog | 
|   |   /CRITERIA=CI(.95). | 
|   | </code> | 
|   |  | 
|   | <code>T-TEST GROUPS=gender(1 2) | 
|   |   /MISSING=ANALYSIS | 
|   |   /VARIABLES=selfprom ethalright | 
|   |   /CRITERIA=CI(.95). | 
|   | </code> | 
|   | ====== ANOVA ====== | 
|   | [[:r/oneway_anova|Oneway ANOVA]] | 
|   | [[:r/twoway_anova|Twoway ANOVA]] | 
|   | ====== Regression ====== | 
|   | [[:/r/linear_regression|Linear Regression]] | 
|   | [[:r/multiple_regression|Multiple Regression]] | 
|   |  | 
|   | ====== class survey ====== | 
|   |  | 
|   | <code> | 
|   | UNIANOVA bigco BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA smallco BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA allowance BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA workhr BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA selfprom BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA ethalright BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA phmin BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA phpeo BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA textmin BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   |  | 
|   | UNIANOVA textpeo BY gender year2 | 
|   |   /METHOD=SSTYPE(3) | 
|   |   /INTERCEPT=INCLUDE | 
|   |   /PLOT=PROFILE(gender*year2) | 
|   |   /EMMEANS=TABLES(gender) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(year2) COMPARE ADJ(LSD) | 
|   |   /EMMEANS=TABLES(gender*year2)  | 
|   |   /PRINT=OPOWER ETASQ DESCRIPTIVE | 
|   |   /CRITERIA=ALPHA(.05) | 
|   |   /DESIGN=gender year2 gender*year2. | 
|   | </code> | 
|   |  | 
 |  |