You are on page 1of 4

R : Copyright 2004, The R Foundation for Statistical Computing

Version 2.0.1 (2004-11-15), ISBN 3-900051-07-0


R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for a HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
> x<-rnorm(30,20,2)
> x
[1] 17.70787 18.36494 19.76379 15.32266 18.33381 19.56135 22.55147 21.06310
[9] 19.01102 19.77616 20.44206 19.14374 17.82409 18.11484 18.80575 18.44472
[17] 17.07817 21.96821 20.86922 17.43792 21.42877 18.55134 18.19470 19.30544
[25] 20.65530 22.70166 21.82626 21.23498 19.18127 18.43730
> t.test(x,mu=21)
One Sample t-test
data: x
t = -4.9054, df = 29, p-value = 3.299e-05
alternative hypothesis: true mean is not equal to 21
95 percent confidence interval:
18.78496 20.08851
sample estimates:
mean of x
19.43673
> t.test(x,mu=21,alternative="less",conf.level=0,95)
Error in t.test.default(x, mu = 21, alternative = "less", conf.level = 0, :
not enough y observations
> y<-rnorm(30,19,2)
> y
[1] 19.49602 22.92851 19.03241 17.29664 17.85011 19.68130 19.58183 19.33451
[9] 17.89899 20.59308 18.84846 20.45176 19.07477 16.76093 19.10048 16.89003
[17] 21.18696 26.58693 19.32073 19.10453 19.60106 16.93542 20.64074 24.64046
[25] 20.89558 17.41832 20.24576 19.42613 14.23127 21.56446
> t.test(x,y)
Welch Two Sample t-test
data: x and y
t = -0.2169, df = 53.08, p-value = 0.8291
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.201068 0.966650
sample estimates:
mean of x mean of y
19.43673 19.55394
> t.test (x,y,var,equal=T,conf.level=0.99)
Error in arg == choices : comparison (1) is possible only for atomic and list ty
pes
> > t.test (x,y,var.equal=T,conf.level=0.99)
Error: syntax error
> t.test(x,y,var.equal=T,conf.level=0.99)
Two Sample t-test
data: x and y
t = -0.2169, df = 58, p-value = 0.829
alternative hypothesis: true difference in means is not equal to 0
99 percent confidence interval:
-1.556438 1.322020
sample estimates:
mean of x mean of y
19.43673 19.55394
> x<-rnorm(30,20,2)
> e<-rnorm(30,0,2)
> y<-12+2*x+e
> a<-lm(y-x)
Error in terms.default(formula, data = data) :
no terms component
> a<-lm(y~x)
> summary(a)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-4.984374 -1.448165 0.008225 1.890099 3.010747
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.5337 5.3847 1.399 0.173
x 2.1970 0.2659 8.263 5.43e-09 ***
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 2.269 on 28 degrees of freedom
Multiple R-Squared: 0.7092, Adjusted R-squared: 0.6988
F-statistic: 68.27 on 1 and 28 DF, p-value: 5.426e-09
> coef(a)
(Intercept) x
7.533725 2.197026
> x1<-rnorm(30,20,2)
> x2<-rnorm(30,17,2)
> e<-rnorm(30,0,2)
> y<-12+2*x1-3*x2
> a<-lm(y~x1+x2)
> summary(a)
Call:
lm(formula = y ~ x1 + x2)
Residuals:
Min 1Q Median 3Q Max
-4.320e-15 -8.365e-16 -2.602e-16 1.150e-15 6.456e-15
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.200e+01 6.885e-15 1.743e+15 <2e-16 ***
x1 2.000e+00 2.588e-16 7.729e+15 <2e-16 ***
x2 -3.000e+00 2.440e-16 -1.230e+16 <2e-16 ***
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 2.598e-15 on 27 degrees of freedom
Multiple R-Squared: 1, Adjusted R-squared: 1
F-statistic: 1.068e+32 on 2 and 27 DF, p-value: < 2.2e-16
> y<-12+2*x1-3*x2+e
> a<-lm(y~x1+x2)
> summary(a)
Call:
lm(formula = y ~ x1 + x2)
Residuals:
Min 1Q Median 3Q Max
-3.11583 -1.66044 0.00672 1.36742 3.42530
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 13.9252 5.1245 2.717 0.0113 *
x1 1.8898 0.1926 9.812 2.13e-10 ***
x2 -2.9756 0.1816 -16.387 1.49e-15 ***
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 1.934 on 27 degrees of freedom
Multiple R-Squared: 0.9318, Adjusted R-squared: 0.9268
F-statistic: 184.6 on 2 and 27 DF, p-value: < 2.2e-16
> analisis variansi satu arah
Error: syntax error
> y<-c(5,4,8,6,3,9,7,8,6,9,3,5,2,3,7,2,3,4,1,4,7,6,9,4,7)
> x<-factor(c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5))
> aov(y~x)
Call:
aov(formula = y ~ x)
Terms:
x Residuals
Sum of Squares 79.44 57.60
Deg. of Freedom 4 20
Residual standard error: 1.697056
Estimated effects may be unbalanced
> summary(aov(y~x))
Df Sum Sq Mean Sq F value Pr(>F)
x 4 79.44 19.86 6.8958 0.001170 **
Residuals 20 57.60 2.88
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
> TukeyHSD(a,conf.level=0.975)
Error in TukeyHSD(a, conf.level = 0.975) :
no applicable method for "TukeyHSD"
> summary(a)
Call:
lm(formula = y ~ x1 + x2)
Residuals:
Min 1Q Median 3Q Max
-3.11583 -1.66044 0.00672 1.36742 3.42530
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 13.9252 5.1245 2.717 0.0113 *
x1 1.8898 0.1926 9.812 2.13e-10 ***
x2 -2.9756 0.1816 -16.387 1.49e-15 ***
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Residual standard error: 1.934 on 27 degrees of freedom
Multiple R-Squared: 0.9318, Adjusted R-squared: 0.9268
F-statistic: 184.6 on 2 and 27 DF, p-value: < 2.2e-16
> a<-aov(y`x)
+ summary(a)
+
+
+ y<-c(5,4,8,6,3,9,7,8,6,9,3,5,2,3,7,2,3,4,1,4,7,6,9,4,7)
+

You might also like