You are on page 1of 21

R consola:

> datose2
y

x1 x2 x3 x4 x5

1 271.8 783.35 33.53 40.55 16.66 13.20


2 264.0 748.45 36.50 36.19 16.46 14.11
3 238.8 684.45 34.66 37.31 17.66 15.68
4 230.7 827.80 33.13 32.52 17.50 10.53
5 251.6 860.45 35.75 33.71 16.40 11.00
6 257.9 875.15 34.46 34.14 16.28 11.31
7 263.9 909.45 34.60 34.85 16.06 11.96
8 266.5 905.55 35.38 35.89 15.93 12.58
9 229.1 756.00 35.85 33.53 16.60 10.66
10 239.3 769.35 35.68 33.79 16.41 10.85
11 258.0 793.50 35.35 34.72 16.17 11.41
12 257.6 801.65 35.04 35.22 15.92 11.91
13 267.3 819.65 34.07 36.50 16.04 12.85
14 267.0 808.55 32.20 37.60 16.19 13.58
15 259.6 774.95 34.32 37.89 16.62 14.21
16 240.4 711.85 31.08 37.71 17.37 15.56
17 227.2 694.85 35.73 37.00 18.12 15.83
18 196.0 638.10 34.11 36.76 18.53 16.41
19 278.7 774.55 34.79 34.62 15.54 13.10
20 272.3 757.90 35.77 35.40 15.70 13.63
21 267.4 753.35 36.44 35.96 16.45 14.51
22 254.5 704.70 37.82 36.26 17.62 15.38
23 224.7 666.80 35.07 36.34 18.12 16.10

24 181.5 568.55 35.26 35.90 19.05 16.73


25 227.5 653.10 35.56 31.84 16.51 10.58
26 253.6 704.05 35.73 33.16 16.02 11.28
27 263.0 709.60 36.46 33.83 15.89 11.91
28 265.8 726.90 36.26 34.89 15.83 12.65
29 263.8 697.15 37.20 36.27 16.71 14.06
> attach(datose2)
> anova(lm(y~x4))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x4

1 10578.7 10579 69.609 5.935e-09 ***

Residuals 27 4103.2

152

--Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> x0<-data.frame(x4=16.5)
> predic.lm(RegModel.1,x0,interval="confidence",level=0.95)
Error: could not find function "predic.lm"
> predict.lm(RegModel.1,x0,interval="confidence",level=0.95)
fit

lwr

upr

1 253.9627 249.1468 258.7787


> datose1
y x1 x2 x3 x4 x5 x6 x7 x8 x9
1 10 2113 1985 38.9 64.7 4 868 59.7 2205 1917
2 11 2003 2855 38.8 61.3 3 615 55.0 2096 1575

3 11 2957 1737 40.1 60.0 14 914 65.6 1847 2175


4 13 2285 2905 41.6 45.3 -4 957 61.4 1903 2476
5 10 2971 1666 39.2 53.8 15 836 66.1 1457 1866
6 11 2309 2927 39.7 74.1 8 786 61.0 1848 2339
7 10 2528 2341 38.1 65.4 12 754 66.1 1564 2092
8 11 2147 2737 37.0 78.3 -1 761 58.0 1821 1909
9 4 1689 1414 42.1 47.6 -3 714 57.0 2577 2001
10 2 2566 1838 42.3 54.2 -1 797 58.9 2476 2254
11 7 2363 1480 37.3 48.0 19 984 67.5 1984 2217
12 10 2109 2191 39.5 51.9 6 700 57.2 1917 1758
13 9 2295 2229 37.4 53.6 -5 1037 58.8 1761 2032
14 9 1932 2204 35.1 71.4 3 986 58.6 1709 2025
15 6 2213 2140 38.8 58.3 6 819 59.2 1901 1686
16 5 1722 1730 36.6 52.6 -19 791 54.4 2288 1835
17 5 1498 2072 35.3 59.3 -5 776 49.6 2072 1914
18 5 1873 2929 41.1 55.3 10 789 54.3 2861 2496
19 6 2118 2268 38.2 69.6 6 582 58.7 2411 2670
20 4 1775 1983 39.3 78.3 7 901 51.7 2289 2202
21 3 1904 1792 39.7 38.1 -9 734 61.9 2203 1988
22 3 1929 1606 39.7 68.8 -21 627 52.7 2592 2324
23 4 2080 1492 35.5 68.8 -8 722 57.8 2053 2550
24 10 2301 2835 35.3 74.1 2 683 59.7 1979 2110
25 6 2040 2416 38.7 50.0 0 576 54.9 2048 2628
26 8 2447 1638 39.9 57.1 -8 848 65.3 1786 1776
27 2 1416 2649 37.4 56.3 -22 684 43.8 2876 2524
28 0 1503 1503 39.3 47.0 -9 875 53.5 2560 2241

> attach(datose1)
The following objects are masked from datose2:

x1, x2, x3, x4, x5, y


> anova(lm(y~x8))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x8

1 178.09 178.092 31.103 7.381e-06 ***

Residuals 26 148.87 5.726


--Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> x0<-data.frame(x8=2000)
> predict.lm(RegModel.2,x0,interval="confidence", level=0.95)
fit

lwr

upr

1 7.73805 6.765753 8.710348


> x0<-data.frame(x8=1800)
> predict.lm(RegModel.2,x0,interval="predict", level=0.90)
fit

lwr

upr

1 9.14307 4.936392 13.34975


> datose3
y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11
1 18.90 350.0 165 260 8.00 2.56 4 3 200.3 69.9 3910 1
2 17.00 350.0 170 275 8.50 2.56 4 3 199.6 72.9 3860 1
3 20.00 250.0 105 185 8.25 2.73 1 3 196.7 72.2 3510 1

4 18.25 351.0 143 255 8.00 3.00 2 3 199.9 74.0 3890 1


5 20.07 225.0 95 170 8.40 2.76 1 3 194.1 71.8 3365 0
6 11.20 440.0 215 330 8.20 2.88 4 3 184.5 69.0 4215 1
7 22.12 231.0 110 175 8.00 2.56 2 3 179.3 65.4 3020 1
8 21.47 262.0 110 200 8.50 2.56 2 3 179.3 65.4 3180 1
9 34.70 89.7 70 81 8.20 3.90 2 4 155.7 64.0 1905 0
10 30.40 96.9 75 83 9.00 4.30 2 5 165.2 65.0 2320 0
11 16.50 350.0 155 250 8.50 3.08 4 3 195.4 74.4 3885 1
12 36.50 85.3 80 83 8.50 3.89 2 4 160.6 62.2 2009 0
13 21.50 171.0 109 146 8.20 3.22 2 4 170.4 66.9 2655 0
14 19.70 258.0 110 195 8.00 3.08 1 3 171.5 77.0 3375 1
15 20.30 140.0 83 109 8.40 3.40 2 4 168.8 69.4 2700 0
16 17.80 302.0 129 220 8.00 3.00 2 3 199.9 74.0 3890 1
17 14.39 500.0 190 360 8.50 2.73 4 3 224.1 79.8 5290 1
18 14.89 440.0 215 330 8.20 2.71 4 3 231.0 79.7 5185 1
19 17.80 350.0 155 250 8.50 3.08 4 3 196.7 72.2 3910 1
20 16.41 318.0 145 255 8.50 2.45 2 3 197.6 71.0 3660 1
21 23.54 231.0 110 175 8.00 2.56 2 3 179.3 65.4 3050 1
22 21.47 360.0 180 290 8.40 2.45 2 3 214.2 76.3 4250 1
23 16.59 400.0 185 NA 7.60 3.08 4 3 196.0 73.0 3850 1
24 31.90 96.9 75 83 9.00 4.30 2 5 165.2 61.8 2275 0
25 29.40 140.0 86 NA 8.00 2.92 2 4 176.4 65.4 2150 0
26 13.27 460.0 223 366 8.00 3.00 4 3 228.0 79.8 5430 1
27 23.90 133.6 96 120 8.40 3.91 2 5 171.5 63.4 2535 0
28 19.73 318.0 140 255 8.50 2.71 2 3 215.3 76.3 4370 1
29 13.90 351.0 148 243 8.00 3.25 2 3 215.5 78.5 4540 1

30 13.27 351.0 148 243 8.00 3.26 2 3 216.1 78.5 4715 1


31 13.77 360.0 195 295 8.25 3.15 4 3 209.3 77.4 4215 1
32 16.50 360.0 165 255 8.50 2.73 4 3 185.2 69.0 3660 1
> attach(datose3)
The following objects are masked from datose1:

x1, x2, x3, x4, x5, x6, x7, x8, x9, y


The following objects are masked from datose2:

x1, x2, x3, x4, x5, y


> anova(lm(y~x1))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x1

1 955.72 955.72 101.74 3.743e-11 ***

Residuals 30 281.82 9.39


--Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> x0<-data.frame(x1=275)
> predict.lm(RegModel.3,x0,interval"confidence",level=0.95)
Error: unexpected string constant in "predict.lm(RegModel.3,x0,interval"confidence""
> predict.lm(RegModel.3,x0,interval="confidence",level=0.95)
fit

lwr

upr

1 20.69879 19.58807 21.80952


> predict.lm(RegModel.3,x0,interval="predict",level=0.95)

fit

lwr

upr

1 20.69879 14.34147 27.05611


> anova(lm(y~x10))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x10

1 921.53 921.53 87.482 2.121e-10 ***

Residuals 30 316.02 10.53


--Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> datose7
y x
1 86.91 1.02
2 89.85 1.11
3 90.28 1.43
4 86.34 1.11
5 92.58 1.01
6 87.33 0.95
7 86.29 1.11
8 91.86 0.87
9 95.61 1.43
10 89.86 1.02
11 96.73 1.46
12 99.42 1.55
13 98.66 1.55

14 96.07 1.55
15 93.65 1.40
16 87.31 1.15
17 95.00 1.01
18 96.85 0.99
19 85.20 0.95
20 90.56 0.98
> attach(datose7)
The following object is masked from datose3:

y
The following object is masked from datose1:

y
The following object is masked from datose2:

y
> anova(lm(y~x))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x

1 148.31 148.313 11.466 0.003291 **

Residuals 18 232.83 12.935


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

> x0<-data.frame(x=1.00)
> predict.lm(RegModel.4,x0,interval="confidence",level=0.95)
Warning: 'newdata' had 1 row but variables found have 32 rows
fit

lwr

upr

1 18.36355 17.123449 19.60365


2 18.65113 17.430148 19.87212
3 20.66420 19.488508 21.83990
4 18.47858 17.246477 19.71069
5 21.49819 20.293824 22.70256
6 16.60930 15.196635 18.02197
7 23.48250 22.111562 24.85344
8 22.56224 21.284022 23.84046
9 29.89557 27.480320 32.31083
10 27.50865 25.532890 29.48440
11 18.50734 17.277162 19.73752
12 29.29740 26.995488 31.59932
13 25.58185 23.925930 27.23777
14 21.44067 20.239149 22.64220
15 25.32303 23.706545 26.93951
16 18.47858 17.246477 19.71069
17 10.42630 7.987262 12.86533
18 11.03022 8.705972 13.35447
19 18.36355 17.123449 19.60365
20 19.80146 18.626103 20.97681
21 23.30995 21.958187 24.66172
22 16.40800 14.970314 17.84568

23 18.70865 17.491136 19.92616


24 27.76747 25.745932 29.78901
25 28.48642 26.335038 30.63781
26 9.62107 7.026455 12.21568
27 26.27204 24.506414 28.03767
28 15.71780 14.187857 17.24774
29 14.74002 13.064803 16.41524
30 13.73349 11.894761 15.57221
31 16.60930 15.196635 18.02197
32 19.80146 18.626103 20.97681
> x0<-data.frame(x=1)
> predict.lm(RegModel.4,x0,interval="confidence",level=0.95)
Warning: 'newdata' had 1 row but variables found have 32 rows
fit

lwr

upr

1 18.36355 17.123449 19.60365


2 18.65113 17.430148 19.87212
3 20.66420 19.488508 21.83990
4 18.47858 17.246477 19.71069
5 21.49819 20.293824 22.70256
6 16.60930 15.196635 18.02197
7 23.48250 22.111562 24.85344
8 22.56224 21.284022 23.84046
9 29.89557 27.480320 32.31083
10 27.50865 25.532890 29.48440
11 18.50734 17.277162 19.73752
12 29.29740 26.995488 31.59932

13 25.58185 23.925930 27.23777


14 21.44067 20.239149 22.64220
15 25.32303 23.706545 26.93951
16 18.47858 17.246477 19.71069
17 10.42630 7.987262 12.86533
18 11.03022 8.705972 13.35447
19 18.36355 17.123449 19.60365
20 19.80146 18.626103 20.97681
21 23.30995 21.958187 24.66172
22 16.40800 14.970314 17.84568
23 18.70865 17.491136 19.92616
24 27.76747 25.745932 29.78901
25 28.48642 26.335038 30.63781
26 9.62107 7.026455 12.21568
27 26.27204 24.506414 28.03767
28 15.71780 14.187857 17.24774
29 14.74002 13.064803 16.41524
30 13.73349 11.894761 15.57221
31 16.60930 15.196635 18.02197
32 19.80146 18.626103 20.97681
> g0<-data.frame(x=1)
> predict.lm(RegModel.5,g0,interval="confidence",level=0.95)
fit

lwr

upr

1 89.66431 87.51017 91.81845


> datose12
y x

1 185.79 21
2 214.47 24
3 288.03 32
4 424.84 47
5 454.68 50
6 539.03 59
7 621.55 68
8 675.06 74
9 562.03 62
10 452.93 50
11 369.95 41
12 273.98 30
> anova(lm(y,x))
Error in formula.default(object, env = baseenv()) : invalid formula
>
> attach(datose7)
The following objects are masked from datose7 (position 3):

x, y
The following object is masked from datose3:

y
The following object is masked from datose1:

y
The following object is masked from datose2:

y
> anova(lm(y,x)
+ anova(lm(y~x))
Error: unexpected symbol in:
"anova(lm(y,x)
anova"
>
> anova(lm(y~x))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x

1 148.31 148.313 11.466 0.003291 **

Residuals 18 232.83 12.935


--Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> x0<-data.frame(x=58)
> predict.lm(RegModel.6,x0,interval="predict", level=0.99)
fit

lwr

upr

1 527.759 521.2237 534.2944


>

RCMDR

datose2 <- sqlQuery(channel = 1, select * from [Sheet1$])

RegModel.1 <- lm(y~x4, data=datose2)


summary(RegModel.1)
library(MASS, pos=4)
Confint(RegModel.1, level=0.99)
datose1 <- sqlQuery(channel = 2, select * from [Sheet1$])
RegModel.2 <- lm(y~x8, data=datose1)
summary(RegModel.2)
Confint(RegModel.2, level=0.95)
datose3 <- sqlQuery(channel = 3, select * from [Sheet1$])
RegModel.3 <- lm(y~x1, data=datose3)
summary(RegModel.3)
RegModel.4 <- lm(y~x10, data=datose3)
summary(RegModel.4)
datose7 <- sqlQuery(channel = 4, select * from [2,07$])
RegModel.5 <- lm(y~x, data=datose7)
summary(RegModel.5)
Confint(RegModel.5, level=0.95)
datose12 <- sqlQuery(channel = 5, select * from [2,12$])
RegModel.6 <- lm(y~x, data=datose12)
summary(RegModel.6)

RCMDR RESULTADOS
> datose2 <- sqlQuery(channel = 1, select * from [Sheet1$])

> RegModel.1 <- lm(y~x4, data=datose2)

> summary(RegModel.1)

Call:
lm(formula = y ~ x4, data = datose2)

Residuals:
Min

1Q Median

3Q

Max

-26.2487 -4.5029 0.5202 7.9093 24.5080

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

-21.402

42.906 14.150 5.24e-14 ***

2.565 -8.343 5.94e-09 ***

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

Residual standard error: 12.33 on 27 degrees of freedom


Multiple R-squared: 0.7205,

Adjusted R-squared: 0.7102

F-statistic: 69.61 on 1 and 27 DF, p-value: 5.935e-09

> library(MASS, pos=4)

> Confint(RegModel.1, level=0.99)


Estimate

0.5 % 99.5 %

(Intercept) 607.10327 488.22411 725.98242

x4

-21.40246 -28.50995 -14.29497

> datose1 <- sqlQuery(channel = 2, select * from [Sheet1$])

> RegModel.2 <- lm(y~x8, data=datose1)

> summary(RegModel.2)

Call:
lm(formula = y ~ x8, data = datose1)

Residuals:
Min

1Q Median

3Q Max

-3.804 -1.591 -0.647 2.032 4.580

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 21.788251 2.696233 8.081 1.46e-08 ***
x8

-0.007025 0.001260 -5.577 7.38e-06 ***

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

Residual standard error: 2.393 on 26 degrees of freedom


Multiple R-squared: 0.5447,

Adjusted R-squared: 0.5272

F-statistic: 31.1 on 1 and 26 DF, p-value: 7.381e-06

> Confint(RegModel.2, level=0.95)


Estimate

2.5 %

97.5 %

(Intercept) 21.7882509 16.246064040 27.330437725


x8

-0.0070251 -0.009614347 -0.004435854

> datose3 <- sqlQuery(channel = 3, select * from [Sheet1$])

> RegModel.3 <- lm(y~x1, data=datose3)

> summary(RegModel.3)

Call:
lm(formula = y ~ x1, data = datose3)

Residuals:
Min

1Q Median

3Q

Max

-6.7923 -1.9752 0.0044 1.7677 6.8171

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 33.722677 1.443903 23.36 < 2e-16 ***
x1

-0.047360 0.004695 -10.09 3.74e-11 ***

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

Residual standard error: 3.065 on 30 degrees of freedom


Multiple R-squared: 0.7723,

Adjusted R-squared: 0.7647

F-statistic: 101.7 on 1 and 30 DF, p-value: 3.743e-11

> RegModel.4 <- lm(y~x10, data=datose3)

> summary(RegModel.4)

Call:
lm(formula = y ~ x10, data = datose3)

Residuals:
Min

1Q Median

3Q

Max

-5.4093 -2.0352 -0.6714 3.0807 7.2026

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 40.8524315 2.2789916 17.926 < 2e-16 ***
x10

-0.0057516 0.0006149 -9.353 2.12e-10 ***

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

Residual standard error: 3.246 on 30 degrees of freedom


Multiple R-squared: 0.7446,

Adjusted R-squared: 0.7361

F-statistic: 87.48 on 1 and 30 DF, p-value: 2.121e-10

> datose7 <- sqlQuery(channel = 4, select * from [2,07$])

> RegModel.5 <- lm(y~x, data=datose7)

> summary(RegModel.5)

Call:
lm(formula = y ~ x, data = datose7)

Residuals:
Min

1Q Median

3Q

Max

-4.6724 -3.2113 -0.0626 2.5783 7.3037

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

11.801

4.199 18.544 3.54e-13 ***

3.485 3.386 0.00329 **

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

Residual standard error: 3.597 on 18 degrees of freedom


Multiple R-squared: 0.3891,

Adjusted R-squared: 0.3552

F-statistic: 11.47 on 1 and 18 DF, p-value: 0.003291

> Confint(RegModel.5, level=0.95)


Estimate

2.5 % 97.5 %

(Intercept) 77.86328 69.041747 86.68482


x

11.80103 4.479066 19.12299

> datose12 <- sqlQuery(channel = 5, select * from [2,12$])

> RegModel.6 <- lm(y~x, data=datose12)

> summary(RegModel.6)

Call:
lm(formula = y ~ x, data = datose12)

Residuals:
Min

1Q Median

3Q

Max

-2.5629 -1.2581 -0.2550 0.8681 4.0581

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -6.33209 1.67005 -3.792 0.00353 **
x

9.20847 0.03382 272.255 < 2e-16 ***

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

Residual standard error: 1.946 on 10 degrees of freedom


Multiple R-squared: 0.9999,

Adjusted R-squared: 0datos

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

You might also like