2011/6/22 M2
1*1+2*2
79
2F
Y YY 0.0 0.2 0.4 0.6 0.8 0.000 0.002 0.004 0.006 0.008 0.010 0.012 1.0 1.5 2.0 2.5 3.0 3.5 4.0 Y 0 50 100 150 200 250 YY A (Y = X + e A ) B (YY = X + e B ) X 0.00 0.05 0.10 0.15-5 0 5 10 X
A (Y = X + e A ) B (YY = X + e B ) Y 1.0 1.5 2.0 2.5 3.0 3.5 4.0 YY 0 50 100 150 200 250-5 0 5 10 X -5 0 5 10 X
0 ( 0) A 0SD1 0.0 0.2 0.4 0.6 0.8-1.5-1.0-0.5 0.0 0.5 1.0 1.5 resid(calm)
B 0.000 0.005 0.010 0.015-50 0 50 100 150 200 resid(calm)
y(x) Sample Quantiles A -1.5-1.0-0.5 0.0 0.5 1.0 1.5 Normal Q-Q Plot -3-2 -1 0 1 2 3 Theoretical Quantiles
Normal Q-Q Plot B Sample Quantiles -50 0 50 100 150 200-3 -2-1 0 1 2 3 Theoretical Quantiles
xy x = 0 x = 0 resid(calm) A -1.5-1.0-0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 fitted(calm)
B resid(dalm) -50 0 50 100 150 200 0 20 40 60 80 100 fitted(dalm)
Blog(YY) = X + e B Sample Quantiles -3-2 -1 0 1 2 3 Normal Q-Q Plot -3-2 -1 0 1 2 3 Theoretical Quantiles
Y()A()B() Y = A + B + A*B AY B B
Y()A()B() Y = A + B + A*B AYB +1SD-1SD 1
Cook
19 goto.csv FAT WEIGHT kg SEX 1 =, 2 =
R > FATdata <- read.csv( /goto.csv ) > FATdata > attach(fatdata)
R > fat.lm <- lm(fat ~ WEIGHT) > # lm(y ~ X) XY > # fat.lm > summary(fat.lm) > # summary() > # anova()()
R Residuals: Min 1Q Median 3Q Max -5.2715-2.7508 0.1906 1.9699 6.6871 Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) 26.88558 4.67036 5.757 2.33e-05 *** WEIGHT 0.02069 0.06414 0.323 0.751 --- Residual standard error: 3.574 on 17 degrees of freedom Multiple R-squared: 0.006081, Adjusted R-squared: - 0.05238 R 2 F-statistic: 0.104 on 1 and 17 DF, p-value: 0.751
R =.02, p =.75
> qqnorm(resid(fat.lm)) > qqline(resid(fat.lm)) > # resid()() > # qqnorm()qqline() Normal Q-Q Plot Sample Quantiles -4-2 0 2 4 6-2 -1 0 1 2 Theoretical Quantiles
> plot(fitted(fat.lm), resid(fat.lm)) > abline(h = 0) > # fitted()() > # plot(x, y) > # abline(h = 0) y = 0 2 resid(fat.lm) -4-2 0 2 4 6 28.2 28.4 28.6 28.8 fitted(fat.lm)
R > fatx.lm <- lm(fat ~ WEIGHT + SEX + WEIGHT*SEX) > # lm(y ~ X1 + X2 + ) > # X1*X2 > # (lm(fat ~ (WEIGHT + SEX)^2)) fatx.lm > summary(fatx.lm) > anova(fatx.lm)
R Response: FAT Df Sum Sq Mean Sq F value Pr(>F) WEIGHT 1 1.328 1.328 0.6611 0.42889 SEX 1 176.098 176.098 87.6467 1.181e-07 *** WEIGHT:SEX 1 10.857 10.857 5.4039 0.03454 * Residuals 15 30.138 2.009 --- (F (1, 15) = 5.40, p <.05)
> qqnorm(resid(fatx.lm)) > qqline(resid(fatx.lm)) Sample Quantiles -3-2 -1 0 1 2 Normal Q-Q Plot -2-1 0 1 2 Theoretical Quantiles
> plot(fitted(fatx.lm), resid(fatx.lm)) > abline(h = 0) resid(fatx.lm) -3-2 -1 0 1 2 24 26 28 30 32 34 fitted(fatx.lm)
R > female <- subset(fatdata, SEX == "1") > male <- subset(fatdata, SEX == "2 ) > # subset(df, )DF > # === > attach(female) # attach(male) > fatf.lm <- lm(fat ~ WEIGHT) > coef(fatf.lm) > # coef()
R > coef(fatf.lm) (Intercept) WEIGHT 5.2396694 0.4028926 > coef(fatm.lm) (Intercept) WEIGHT 11.5709579 0.1855043 = 0.40 * + 5.24 = 0.19 * + 11.57
R > layout(matrix(1:4, 2, 2, byrow=true)) > plot(fatx.lm) > # plot() Residuals -3-2 -1 0 1 2 Residuals vs Fitted 7 14 16 24 26 28 30 32 34 Standardized residuals -2-1 0 1 2 Normal Q-Q 13 7 16-2 -1 0 1 2 Cook Standardized residuals 0.0 0.5 1.0 1.5 Fitted values Scale-Location 16 7 13 24 26 28 30 32 34 Fitted values Standardized residuals -2-1 0 1 2 Theoretical Quantiles Residuals vs Leverage 13 0.5 19 0.5 Cook's distance 16 1 0.0 0.1 0.2 0.3 0.4 Leverage
SPSS ZRESID ZPRED > &
SPSS REGRESSION /DESCRIPTIVES MEAN STDDEV CORR SIG N /MISSING LISTWISE /STATISTICS COEFF OUTS R ANOVA CHANGE ZPP /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT FAT /METHOD=ENTER WEIGHT /SCATTERPLOT=(*ZRESID,*ZPRED) /RESIDUALS HIST(ZRESID) NORM(ZRESID).
SPSS compute INTERACTION = WEIGHT * SEX. variable labels INTERACTION ''. REGRESSION /DESCRIPTIVES MEAN STDDEV CORR SIG N /MISSING LISTWISE /STATISTICS COEFF OUTS R ANOVA CHANGE ZPP /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT FAT /METHOD=ENTER WEIGHT SEX INTERACTION
, A. &, R. (2007).., ().. [Grafen, A. & Hails, R. (2002). Modern Statistics For The Life Sciences. Oxford University Press.] : ( http://www.oup.com/uk/orc/bin/9780199252312/ ). (2009). R.. R-Tips (http://cse.naro.affrc.go.jp/takezawa/r-tips/r.html )