Please view this page from a desktop browser, since the table/graphics output is too wide to view from a mobile browser
> describe(wine)
vars n mean sd median trimmed mad min max range skew kurtosis se
Alcohol 1 178 13.00 0.81 13.05 13.01 1.01 11.03 14.83 3.80 -0.05 -0.89 0.06
Malic acid 2 178 2.34 1.12 1.87 2.21 0.77 0.74 5.80 5.06 1.02 0.22 0.08
Ash 3 178 2.37 0.27 2.36 2.37 0.24 1.36 3.23 1.87 -0.17 1.03 0.02
Alcalinity of ash 4 178 19.49 3.34 19.50 19.42 3.04 10.60 30.00 19.40 0.21 0.40 0.25
Magnesium 5 178 99.74 14.28 98.00 98.44 14.83 70.00 162.00 92.00 1.08 1.96 1.07
Total phenols 6 178 2.30 0.63 2.36 2.29 0.75 0.98 3.88 2.90 0.09 -0.87 0.05
Flavanoids 7 178 2.03 1.00 2.13 2.02 1.24 0.34 5.08 4.74 0.02 -0.91 0.07
Nonflavanoid phenols 8 178 0.36 0.12 0.34 0.36 0.13 0.13 0.66 0.53 0.44 -0.68 0.01
Proanthocyanins 9 178 1.59 0.57 1.56 1.56 0.56 0.41 3.58 3.17 0.51 0.47 0.04
Color intensity 10 178 5.06 2.32 4.69 4.83 2.24 1.28 13.00 11.72 0.85 0.30 0.17
Hue 11 178 0.96 0.23 0.96 0.96 0.24 0.48 1.71 1.23 0.02 -0.40 0.02
OD280/OD315 of diluted wines 12 178 2.61 0.71 2.78 2.63 0.77 1.27 4.00 2.73 -0.30 -1.11 0.05
Proline 13 178 746.89 314.91 673.50 719.30 300.23 278.00 1680.00 1402.00 0.75 -0.31 23.60
class 14 178 1.94 0.78 2.00 1.92 1.48 1.00 3.00 2.00 0.11 -1.34 0.06
AGE
> bartlett.test(AGE ~ SEX, data = ret)
Bartlett's K-squared = 0.14884, df = 1, p-value = 0.6996
> t.test(AGE ~ SEX,data=ret,var.equal = T)
t = 5.1474, df = 312, p-value = 4.684e-07
mean in group 1 mean in group 2
60.54762 48.57721
> MWa = wilcox.test(AGE ~ SEX, data = ret, exact=FALSE)
> MWa
W = 8306, p-value = 2.164e-06
> Za = qnorm(MWa$p.value/2)
> Za
[1] -4.737439
>
QUETELET
> bartlett.test(QUETELET ~ SEX, data = ret)
Bartlett's K-squared = 9.4539, df = 1, p-value = 0.002107
> t.test(QUETELET ~ SEX,data=ret,var.equal = F)
t = 0.20089, df = 72.998, p-value = 0.8413
mean in group 1 mean in group 2
26.27136 26.12108
> MWa = wilcox.test(QUETELET ~ SEX, data = ret, exact=FALSE)
> MWa
W = 6469.5, p-value = 0.1669
> Za = qnorm(MWa$p.value/2)
> Za
[1] -1.382375
> t.test(ret$FIBER,ret$CALORIES,paired = TRUE)
Paired t-test
data: ret$FIBER and ret$CALORIES
t = -46.696, df = 313, p-value < 2.2e-16
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
-1854.992 -1704.990
sample estimates:
mean difference
-1779.991
> MWa = wilcox.test(ret$FIBER,ret$CALORIES, paired=TRUE)
> MWa
Wilcoxon signed rank test with continuity correction
data: ret$FIBER and ret$CALORIES
V = 0, p-value < 2.2e-16
alternative hypothesis: true location shift is not equal to 0
> Za = qnorm(MWa$p.value/2)
> Za
[1] -15.35789
> mcnemar.test(mcn$before,mcn$after, correct = FALSE)
McNemar's Chi-squared test
data: mcn$before and mcn$after
McNemar's chi-squared = 1.8519, df = 1, p-value = 0.1736
> test <- prop.test(freqtable,correct = FALSE)
> print(test)
2-sample test for equality of proportions without continuity correction
data: freqtable
X-squared = 0.55682, df = 1, p-value = 0.4555
Note: for df=1, Z=SQRT(X-squared), so SQRT(0.55682)=0.7462
alternative hypothesis: two.sided
95 percent confidence interval:
-0.2669889 0.1195530
sample estimates:
prop 1 prop 2
0.5416667 0.6153846
Note: R uses #zeroes as the numerator in p1, p2
Alcohol
> df[ ,list(mean=mean(Alcohol)), by=class]
class mean
1: 1 13.74475
2: 2 12.27873
3: 3 13.15375
> bartlett.test(Alcohol ~ class.f, data = wine)
Bartlett test of homogeneity of variances
data: Alcohol by class.f
Bartlett's K-squared = 1.5988, df = 2, p-value = 0.4496
> summary(aov(wine$Alcohol~class.f))
Df Sum Sq Mean Sq F value Pr(>F)
class.f 2 70.79 35.40 135.1 <2e-16 ***
Residuals 175 45.86 0.26
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> kruskal.test(Alcohol ~ class.f, data = wine)
Kruskal-Wallis rank sum test
data: Alcohol by class.f
Kruskal-Wallis chi-squared = 109.51, df = 2, p-value < 2.2e-16
>
>
Magnesium
> df[ ,list(mean=mean(Magnesium)), by=class]
class mean
1: 1 106.3390
2: 2 94.5493
3: 3 99.3125
> bartlett.test(Magnesium ~ class.f, data = wine)
Bartlett test of homogeneity of variances
data: Magnesium by class.f
Bartlett's K-squared = 17.454, df = 2, p-value = 0.0001621
> oneway.test(wine$Magnesium~class.f)
One-way analysis of means (not assuming equal variances)
data: wine$Magnesium and class.f
F = 13.267, num df = 2.00, denom df = 113.97, p-value = 6.612e-06
> kruskal.test(Magnesium ~ class.f, data = wine)
Kruskal-Wallis rank sum test
data: Magnesium by class.f
Kruskal-Wallis chi-squared = 40.576, df = 2, p-value = 1.545e-09
> library(Hmisc)
> rcorr(as.matrix(wine))
> rcorr(as.matrix(wine),type="pearson")
Alcohol Malic acid Ash Alcalinity of ash Magnesium Total phenols Flavanoids Nonflavanoid phenols Proanthocyanins Color intensity Hue OD280/OD315 of diluted wines Proline class
Alcohol 1.00 0.09 0.21 -0.31 0.27 0.29 0.24 -0.16 0.14 0.55 -0.07 0.07 0.64 -0.33
Malic acid 0.09 1.00 0.16 0.29 -0.05 -0.34 -0.41 0.29 -0.22 0.25 -0.56 -0.37 -0.19 0.44
Ash 0.21 0.16 1.00 0.44 0.29 0.13 0.12 0.19 0.01 0.26 -0.07 0.00 0.22 -0.05
Alcalinity of ash -0.31 0.29 0.44 1.00 -0.08 -0.32 -0.35 0.36 -0.20 0.02 -0.27 -0.28 -0.44 0.52
Magnesium 0.27 -0.05 0.29 -0.08 1.00 0.21 0.20 -0.26 0.24 0.20 0.06 0.07 0.39 -0.21
Total phenols 0.29 -0.34 0.13 -0.32 0.21 1.00 0.86 -0.45 0.61 -0.06 0.43 0.70 0.50 -0.72
Flavanoids 0.24 -0.41 0.12 -0.35 0.20 0.86 1.00 -0.54 0.65 -0.17 0.54 0.79 0.49 -0.85
Nonflavanoid phenols -0.16 0.29 0.19 0.36 -0.26 -0.45 -0.54 1.00 -0.37 0.14 -0.26 -0.50 -0.31 0.49
Proanthocyanins 0.14 -0.22 0.01 -0.20 0.24 0.61 0.65 -0.37 1.00 -0.03 0.30 0.52 0.33 -0.50
Color intensity 0.55 0.25 0.26 0.02 0.20 -0.06 -0.17 0.14 -0.03 1.00 -0.52 -0.43 0.32 0.27
Hue -0.07 -0.56 -0.07 -0.27 0.06 0.43 0.54 -0.26 0.30 -0.52 1.00 0.57 0.24 -0.62
OD280/OD315 of diluted wines 0.07 -0.37 0.00 -0.28 0.07 0.70 0.79 -0.50 0.52 -0.43 0.57 1.00 0.31 -0.79
Proline 0.64 -0.19 0.22 -0.44 0.39 0.50 0.49 -0.31 0.33 0.32 0.24 0.31 1.00 -0.63
class -0.33 0.44 -0.05 0.52 -0.21 -0.72 -0.85 0.49 -0.50 0.27 -0.62 -0.79 -0.63 1.00
n= 178
P
Alcohol Malic acid Ash Alcalinity of ash Magnesium Total phenols Flavanoids Nonflavanoid phenols Proanthocyanins Color intensity Hue OD280/OD315 of diluted wines Proline class
Alcohol 0.2101 0.0046 0.0000 0.0003 0.0000 0.0015 0.0377 0.0688 0.0000 0.3412 0.3372 0.0000 0.0000
Malic acid 0.2101 0.0287 0.0000 0.4694 0.0000 0.0000 0.0000 0.0031 0.0008 0.0000 0.0000 0.0102 0.0000
Ash 0.0046 0.0287 0.0000 0.0001 0.0862 0.1261 0.0128 0.8983 0.0005 0.3219 0.9587 0.0027 0.5105
Alcalinity of ash 0.0000 0.0000 0.0000 0.2688 0.0000 0.0000 0.0000 0.0083 0.8040 0.0002 0.0002 0.0000 0.0000
Magnesium 0.0003 0.4694 0.0001 0.2688 0.0041 0.0088 0.0006 0.0015 0.0075 0.4627 0.3814 0.0000 0.0051
Total phenols 0.0000 0.0000 0.0862 0.0000 0.0041 0.0000 0.0000 0.0000 0.4648 0.0000 0.0000 0.0000 0.0000
Flavanoids 0.0015 0.0000 0.1261 0.0000 0.0088 0.0000 0.0000 0.0000 0.0214 0.0000 0.0000 0.0000 0.0000
Nonflavanoid phenols 0.0377 0.0000 0.0128 0.0000 0.0006 0.0000 0.0000 0.0000 0.0641 0.0004 0.0000 0.0000 0.0000
Proanthocyanins 0.0688 0.0031 0.8983 0.0083 0.0015 0.0000 0.0000 0.0000 0.7380 0.0000 0.0000 0.0000 0.0000
Color intensity 0.0000 0.0008 0.0005 0.8040 0.0075 0.4648 0.0214 0.0641 0.7380 0.0000 0.0000 0.0000 0.0003
Hue 0.3412 0.0000 0.3219 0.0002 0.4627 0.0000 0.0000 0.0004 0.0000 0.0000 0.0000 0.0015 0.0000
OD280/OD315 of diluted wines 0.3372 0.0000 0.9587 0.0002 0.3814 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Proline 0.0000 0.0102 0.0027 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0015 0.0000 0.0000
class 0.0000 0.0000 0.5105 0.0000 0.0051 0.0000 0.0000 0.0000 0.0000 0.0003 0.0000 0.0000 0.0000
> rcorr(as.matrix(wine),type="spearman")
Alcohol Malic acid Ash Alcalinity of ash Magnesium Total phenols Flavanoids Nonflavanoid phenols Proanthocyanins Color intensity Hue OD280/OD315 of diluted wines Proline class
Alcohol 1.00 0.14 0.24 -0.31 0.37 0.31 0.29 -0.16 0.19 0.64 -0.02 0.10 0.63 -0.35
Malic acid 0.14 1.00 0.23 0.30 0.08 -0.28 -0.33 0.26 -0.24 0.29 -0.56 -0.26 -0.06 0.35
Ash 0.24 0.23 1.00 0.37 0.36 0.13 0.08 0.15 0.02 0.28 -0.05 -0.01 0.25 -0.05
Alcalinity of ash -0.31 0.30 0.37 1.00 -0.17 -0.38 -0.44 0.39 -0.25 -0.07 -0.35 -0.33 -0.46 0.57
Magnesium 0.37 0.08 0.36 -0.17 1.00 0.25 0.23 -0.24 0.17 0.36 0.04 0.06 0.51 -0.25
Total phenols 0.31 -0.28 0.13 -0.38 0.25 1.00 0.88 -0.45 0.67 0.01 0.44 0.69 0.42 -0.73
Flavanoids 0.29 -0.33 0.08 -0.44 0.23 0.88 1.00 -0.54 0.73 -0.04 0.54 0.74 0.43 -0.85
Nonflavanoid phenols -0.16 0.26 0.15 0.39 -0.24 -0.45 -0.54 1.00 -0.38 0.06 -0.27 -0.49 -0.27 0.47
Proanthocyanins 0.19 -0.24 0.02 -0.25 0.17 0.67 0.73 -0.38 1.00 -0.03 0.34 0.55 0.31 -0.57
Color intensity 0.64 0.29 0.28 -0.07 0.36 0.01 -0.04 0.06 -0.03 1.00 -0.42 -0.32 0.46 0.13
Hue -0.02 -0.56 -0.05 -0.35 0.04 0.44 0.54 -0.27 0.34 -0.42 1.00 0.49 0.21 -0.62
OD280/OD315 of diluted wines 0.10 -0.26 -0.01 -0.33 0.06 0.69 0.74 -0.49 0.55 -0.32 0.49 1.00 0.25 -0.74
Proline 0.63 -0.06 0.25 -0.46 0.51 0.42 0.43 -0.27 0.31 0.46 0.21 0.25 1.00 -0.58
class -0.35 0.35 -0.05 0.57 -0.25 -0.73 -0.85 0.47 -0.57 0.13 -0.62 -0.74 -0.58 1.00
n= 178
P
Alcohol Malic acid Ash Alcalinity of ash Magnesium Total phenols Flavanoids Nonflavanoid phenols Proanthocyanins Color intensity Hue OD280/OD315 of diluted wines Proline class
Alcohol 0.0615 0.0010 0.0000 0.0000 0.0000 0.0000 0.0305 0.0100 0.0000 0.7485 0.1711 0.0000 0.0000
Malic acid 0.0615 0.0019 0.0000 0.2873 0.0002 0.0000 0.0006 0.0010 0.0000 0.0000 0.0006 0.4461 0.0000
Ash 0.0010 0.0019 0.0000 0.0000 0.0786 0.2958 0.0525 0.7466 0.0001 0.5059 0.9209 0.0007 0.4742
Alcalinity of ash 0.0000 0.0000 0.0000 0.0237 0.0000 0.0000 0.0000 0.0006 0.3277 0.0000 0.0000 0.0000 0.0000
Magnesium 0.0000 0.2873 0.0000 0.0237 0.0009 0.0017 0.0015 0.0204 0.0000 0.6324 0.4501 0.0000 0.0007
Total phenols 0.0000 0.0002 0.0786 0.0000 0.0009 0.0000 0.0000 0.0000 0.8824 0.0000 0.0000 0.0000 0.0000
Flavanoids 0.0000 0.0000 0.2958 0.0000 0.0017 0.0000 0.0000 0.0000 0.5695 0.0000 0.0000 0.0000 0.0000
Nonflavanoid phenols 0.0305 0.0006 0.0525 0.0000 0.0015 0.0000 0.0000 0.0000 0.4291 0.0003 0.0000 0.0003 0.0000
Proanthocyanins 0.0100 0.0010 0.7466 0.0006 0.0204 0.0000 0.0000 0.0000 0.6818 0.0000 0.0000 0.0000 0.0000
Color intensity 0.0000 0.0000 0.0001 0.3277 0.0000 0.8824 0.5695 0.4291 0.6818 0.0000 0.0000 0.0000 0.0809
Hue 0.7485 0.0000 0.5059 0.0000 0.6324 0.0000 0.0000 0.0003 0.0000 0.0000 0.0000 0.0054 0.0000
OD280/OD315 of diluted wines 0.1711 0.0006 0.9209 0.0000 0.4501 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0006 0.0000
Proline 0.0000 0.4461 0.0007 0.0000 0.0000 0.0000 0.0000 0.0003 0.0000 0.0000 0.0054 0.0006 0.0000
class 0.0000 0.0000 0.4742 0.0000 0.0007 0.0000 0.0000 0.0000 0.0000 0.0809 0.0000 0.0000 0.0000
Call:
lm(formula = BETADIET ~ AGE + QUETELET + FIBER + CHOLESTEROL +
SEX.f + SMOKSTAT.f + VITUSE.f, data = retinol)
Residuals:
Min 1Q Median 3Q Max
-2973.1 -738.4 -214.5 460.2 6875.7
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -413.9490 611.4867 -0.677 0.499
AGE 6.7644 5.4450 1.242 0.215
QUETELET 8.4531 12.4726 0.678 0.498
FIBER 127.4014 14.2699 8.928 <2e-16 ***
CHOLESTEROL 0.9844 0.6278 1.568 0.118
SEX.f2 270.6962 240.6600 1.125 0.262
SMOKSTAT.f2 192.1146 162.1146 1.185 0.237
SMOKSTAT.f3 -92.5647 235.8433 -0.392 0.695
VITUSE.f2 -166.0685 188.4348 -0.881 0.379
VITUSE.f3 -201.4484 174.9086 -1.152 0.250
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1293 on 304 degrees of freedom
Multiple R-squared: 0.2539, Adjusted R-squared: 0.2318
F-statistic: 11.5 on 9 and 304 DF, p-value: 1.596e-15
Response BETADIET :
Call:
lm(formula = BETADIET ~ AGE + QUETELET + FIBER + CHOLESTEROL +
SEX.f + SMOKSTAT.f + VITUSE.f, data = retinol)
Residuals:
Min 1Q Median 3Q Max
-2973.1 -738.4 -214.5 460.2 6875.7
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -413.9490 611.4867 -0.677 0.499
AGE 6.7644 5.4450 1.242 0.215
QUETELET 8.4531 12.4726 0.678 0.498
FIBER 127.4014 14.2699 8.928 <2e-16 ***
CHOLESTEROL 0.9844 0.6278 1.568 0.118
SEX.f2 270.6962 240.6600 1.125 0.262
SMOKSTAT.f2 192.1146 162.1146 1.185 0.237
SMOKSTAT.f3 -92.5647 235.8433 -0.392 0.695
VITUSE.f2 -166.0685 188.4348 -0.881 0.379
VITUSE.f3 -201.4484 174.9086 -1.152 0.250
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1293 on 304 degrees of freedom
Multiple R-squared: 0.2539, Adjusted R-squared: 0.2318
F-statistic: 11.5 on 9 and 304 DF, p-value: 1.596e-15
Response RETDIET :
Call:
lm(formula = RETDIET ~ AGE + QUETELET + FIBER + CHOLESTEROL +
SEX.f + SMOKSTAT.f + VITUSE.f, data = retinol)
Residuals:
Min 1Q Median 3Q Max
-1387.7 -279.4 -68.4 188.4 5604.1
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 64.3354 248.2140 0.259 0.79566
AGE 1.6250 2.2102 0.735 0.46279
QUETELET -0.8842 5.0629 -0.175 0.86147
FIBER 15.8974 5.7924 2.745 0.00642 **
CHOLESTEROL 1.8620 0.2549 7.306 2.43e-12 ***
SEX.f2 81.2877 97.6884 0.832 0.40600
SMOKSTAT.f2 -26.2273 65.8054 -0.399 0.69050
SMOKSTAT.f3 -66.4360 95.7333 -0.694 0.48823
VITUSE.f2 -15.3422 76.4892 -0.201 0.84116
VITUSE.f3 12.3660 70.9987 0.174 0.86185
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 524.7 on 304 degrees of freedom
Multiple R-squared: 0.1958, Adjusted R-squared: 0.1719
F-statistic: 8.222 on 9 and 304 DF, p-value: 5.953e-11
Call:
glm(formula = low ~ age + lwt + smoke + ht + ui + race.f, family = "binomial",
data = lowbirth)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.7323 -0.8328 -0.5345 0.9868 2.1673
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.437240 1.191931 0.367 0.71374
age -0.018256 0.035354 -0.516 0.60559
lwt -0.016285 0.006859 -2.374 0.01758 *
smoke 1.027571 0.393931 2.609 0.00909 **
ht 1.857617 0.688848 2.697 0.00700 **
ui 0.895387 0.448494 1.996 0.04589 *
race.f2 1.280641 0.526695 2.431 0.01504 *
race.f3 0.901880 0.434362 2.076 0.03786 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 234.67 on 188 degrees of freedom
Residual deviance: 203.95 on 181 degrees of freedom
AIC: 219.95
Number of Fisher Scoring iterations: 4
Call:
coxph(formula = Surv(fudays, dead) ~ treatment + age + sexfem +
ascites + hepatom + spider + bili + alb + copper + alkphos +
sgot + platelet + protime + edema.f + stage.f, data = pbc)
n= 287, number of events= 123
coef exp(coef) se(coef) z Pr(>|z|)
treatment 0.10607125 1.11190109 0.19817672 0.535 0.59249
age 0.02441253 1.02471295 0.01078290 2.264 0.02357 *
sexfem -0.29934133 0.74130634 0.29179064 -1.026 0.30495
ascites 0.02502930 1.02534517 0.33161557 0.075 0.93984
hepatom 0.25943048 1.29619166 0.24100574 1.076 0.28173
spider -0.02735376 0.97301697 0.23658744 -0.116 0.90796
bili 0.08399058 1.08761865 0.02108828 3.983 0.0000681 ***
alb -0.82085129 0.44005688 0.28419903 -2.888 0.00387 **
copper 0.00273872 1.00274247 0.00110076 2.488 0.01285 *
alkphos -0.00003423 0.99996577 0.00003873 -0.884 0.37681
sgot 0.00399131 1.00399928 0.00181019 2.205 0.02746 *
platelet 0.00054388 1.00054403 0.00107875 0.504 0.61413
protime 0.31575126 1.37128912 0.10782621 2.928 0.00341 **
edema.f2 0.13467764 1.14416789 0.30748362 0.438 0.66139
edema.f3 0.96173307 2.61622666 0.34130181 2.818 0.00483 **
stage.f2 1.63028998 5.10535493 1.07833064 1.512 0.13057
stage.f3 1.86094248 6.42979388 1.05318637 1.767 0.07723 .
stage.f4 2.09704403 8.14206663 1.05977277 1.979 0.04784 *