You are on page 1of 9

Nama : Friscilia Fridayanti Pita Romauli

NPM :140610140036

i i i
N(0,0.1) N(0,1) N(0,10)
n=10

b0= 0.84298 b0= 1.3475 b0= 1.8716


b1= 1.01654 b1= 0.9356 b1= 0.8856
n=30

b0= 1.101293 b0= -1.0104 b0= -20.4455


b1= 0.989743 b1= 1.1798 b1= 3.1715

n=100

b0= 1.22820 b0= 15.8016


b0= 0.969716 b1= 0.98649
b1= 1.002397 b1= -0.4396
Analisis:
Semakin besar standard error kekeliruannya maka data akan semakin menyebar(menajauhi garis
regresinya) dan menentukan kemiringan garis regresinya.

Syntax:

reg<-function(n,s){

x<-rnorm(n,10,2)

e<-rnorm(n,0,s)

y<-1+1*x+e

fit<-lm(y~x)

plot(y~x)

abline(fit)

summary(fit)}

> reg(10,0.1)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-0.10157 -0.06564 -0.04562 0.07259 0.18004

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 0.84298 0.17271 4.881 0.00122 **

x 1.01654 0.01637 62.108 5.02e-12 ***

---
Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 0.1024 on 8 degrees of freedom

Multiple R-squared: 0.9979, Adjusted R-squared: 0.9977

F-statistic: 3857 on 1 and 8 DF, p-value: 5.021e-12

> reg(10,1)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-2.1980 -0.6650 0.4494 0.6089 1.1453

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 1.3475 1.9801 0.681 0.5154

x 0.9356 0.2023 4.624 0.0017 **

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 1.096 on 8 degrees of freedom

Multiple R-squared: 0.7277, Adjusted R-squared: 0.6937

F-statistic: 21.38 on 1 and 8 DF, p-value: 0.001702

> reg(10,10)
Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-11.461 -6.465 -1.315 6.955 12.014

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 1.8716 18.1874 0.103 0.921

x 0.8856 1.8391 0.482 0.643

Residual standard error: 8.44 on 8 degrees of freedom

Multiple R-squared: 0.02817, Adjusted R-squared: -0.09331

F-statistic: 0.2319 on 1 and 8 DF, p-value: 0.643

> reg(30,0.1)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-0.23018 -0.08235 0.01209 0.07138 0.18511

Coefficients:
Estimate Std. Error t value Pr(>|t|)

(Intercept) 1.101293 0.096627 11.4 4.97e-12 ***

x 0.989743 0.009284 106.6 < 2e-16 ***

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 0.1071 on 28 degrees of freedom

Multiple R-squared: 0.9975, Adjusted R-squared: 0.9975

F-statistic: 1.137e+04 on 1 and 28 DF, p-value: < 2.2e-16

> reg(30,1)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-2.1745 -0.6620 -0.1372 0.4557 2.5052

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) -1.0104 1.0770 -0.938 0.356

x 1.1798 0.1001 11.788 2.27e-12 ***

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 1.094 on 28 degrees of freedom


Multiple R-squared: 0.8323, Adjusted R-squared: 0.8263

F-statistic: 138.9 on 1 and 28 DF, p-value: 2.267e-12

> reg(30,10)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-21.6534 -3.2052 0.4117 6.4438 13.0054

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) -20.4455 9.2333 -2.214 0.03512 *

x 3.1715 0.9581 3.310 0.00257 **

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 8.303 on 28 degrees of freedom

Multiple R-squared: 0.2813, Adjusted R-squared: 0.2556

F-statistic: 10.96 on 1 and 28 DF, p-value: 0.002573

> reg(100,0.1)

Call:

lm(formula = y ~ x)
Residuals:

Min 1Q Median 3Q Max

-0.295475 -0.050545 -0.001547 0.053584 0.311032

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 0.969716 0.045533 21.3 <2e-16 ***

x 1.002397 0.004328 231.6 <2e-16 ***

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 0.09159 on 98 degrees of freedom

Multiple R-squared: 0.9982, Adjusted R-squared: 0.9982

F-statistic: 5.365e+04 on 1 and 98 DF, p-value: < 2.2e-16

> reg(100,1)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-3.02925 -0.54062 -0.00567 0.73214 2.09909

Coefficients:

Estimate Std. Error t value Pr(>|t|)


(Intercept) 1.22820 0.49802 2.466 0.0154 *

x 0.98649 0.04781 20.635 <2e-16 ***

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 1.01 on 98 degrees of freedom

Multiple R-squared: 0.8129, Adjusted R-squared: 0.811

F-statistic: 425.8 on 1 and 98 DF, p-value: < 2.2e-16

> reg(100,10)

Call:

lm(formula = y ~ x)

Residuals:

Min 1Q Median 3Q Max

-19.1772 -6.1681 -0.6694 5.7792 22.5588

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 15.8016 4.9658 3.182 0.00196 **

x -0.4396 0.4843 -0.908 0.36632

---

Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

Residual standard error: 9.43 on 98 degrees of freedom

Multiple R-squared: 0.008335, Adjusted R-squared: -0.001784


F-statistic: 0.8237 on 1 and 98 DF, p-value: 0.3663

You might also like