Documente Academic
Documente Profesional
Documente Cultură
Castillo Fabircio
30 de enero de 2018
NRC 3281
Ejercicio 7
## Df Sum Sq Mean Sq
## A 1 0.00 0.00
## B 1 3.00 3.00
## C 1 73.21 73.21
## A:B 1 0.00 0.00
## A:C 1 2.00 2.00
## B:C 1 7.03 7.03
## A:B:C 1 1.71 1.71
#grafica de efectos principales
library(FrF2)
1
## The following objects are masked from 'package:stats':
##
## aov, lm
## The following object is masked from 'package:graphics':
##
## plot.design
## The following object is masked from 'package:base':
##
## lengths
MEPlot(eje7)
81
80
79
78
−1 1 −1 1 −1 1
#grafica de interacciones
interaction.plot( A,C,Porc, xlab = "Temperatura", ylab = "Tamaño de particula",
main="Efecto de interaccion AC para fabricación de dientes")
2
Efecto de interaccion AC para fabricación de dientes
78 79 80 81 82 83 84 85
C
1
Tamaño de particula
−1
−1 1
Temperatura
3
Efecto de interaccion AB para fabricación de dientes
81.8
B
1
−1
81.4
Tiempo
81.0
80.6
−1 1
Temperatura
4
Efecto de interaccion BC para fabricación de dientes
C
84
1
Tamaño de particula
−1
82
80
78
−1 1
Tiempo
Ejercicio 8
Datos<-read.csv("Ejerc8.csv",sep=";",dec=",")
names(Datos)
#regresion
b<-lm(viscosidad~ingA*ingB*ingC)
eje8<-aov(b)
summary(eje8)
5
## Residuals 8 0.50 0.06
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#grafica de efectos principales
library(FrF2)
MEPlot(eje8)
15.5
15
14.5
14
−1 1 −1 1 −1 1
#grafica de interacciones
interaction.plot( ingA,ingC,viscosidad, xlab = "Ingrediente A", ylab = "Ingrediente C",
main="Efecto de interaccion AC para viscosidad de bebida de chocolate")
6
Efecto de interaccion AC para viscosidad de bebida de chocolate
ingC
1
16.5
−1
Ingrediente C
15.5
14.5
−1 1
Ingrediente A
7
Efecto de interaccion AB para viscosidad de bebida de chocolate
16.5
ingB
1
−1
Ingrediente B
16.0
15.5
15.0
−1 1
Ingrediente A
8
Efecto de interaccion BC para viscosidad de bebida de chocolate
18
ingC
1
−1
17
Ingrediente C
16
15
14
−1 1
Ingrediente B
9
Residuals vs Fitted
0.3
9
0.1
Residuals
−0.1
14
−0.3
14 15 16 17 18 19
Fitted values
aov.default(b)
10
Normal Q−Q
2
9
Standardized residuals
1
0
−1
14
−2 −1 0 1 2
Theoretical Quantiles
aov.default(b)
11
Scale−Location
9
1
0.0 0.2 0.4 0.6 0.8 1.0 1.2
Standardized residuals
14
14 15 16 17 18 19
Fitted values
aov.default(b)
12
Constant Leverage:
Residuals vs Factor Levels
2
9
Standardized residuals
1
0
−1
14
1
−2
ingA :
−1 1
EJERCICIO 9
13
21 -1 -1 1 -1 35 35
22 1 -1 1 -1 22 22
23 -1 1 1 -1 37 37
24 1 1 1 -1 71 71
25 -1 -1 -1 1 19 19
26 1 -1 -1 1 57 57
27 -1 1 -1 1 19 19
28 1 1 -1 1 61 61
29 -1 -1 1 1 0 0
30 1 -1 1 1 1 1
31 -1 1 1 1 7 7
32 1 1 1 1 15 15
> ejer_9$A <-factor(ejer_9$factorA)
> ejer_9$B <-factor(ejer_9$factorB)
> ejer_9$C <-factor(ejer_9$factorC)
> ejer_9$D <-factor(ejer_9$factorD)
> ejer_9$Replicas <-factor(ejer_9$y2)
> str(ejer_9)
'data.frame': 32 obs. of 11 variables:
$ factorA : int -1 1 -1 1 -1 1 -1 1 -1 1 ...
$ factorB : int -1 -1 1 1 -1 -1 1 1 -1 -1 ...
$ factorC : int -1 -1 -1 -1 1 1 1 1 -1 -1 ...
$ factorD : int -1 -1 -1 -1 -1 -1 -1 -1 1 1 ...
$ y1 : int 61 105 61 104 0 35 50 57 12 60 ...
$ y2 : int 88 78 82 73 88 84 89 79 77 66 ...
$ A : Factor w/ 2 levels "-1","1": 1 2 1 2 1 2 1 2 1 2 ...
$ B : Factor w/ 2 levels "-1","1": 1 1 2 2 1 1 2 2 1 1 ...
$ C : Factor w/ 2 levels "-1","1": 1 1 1 1 2 2 2 2 1 1 ...
$ D : Factor w/ 2 levels "-1","1": 1 1 1 1 1 1 1 1 2 2 ...
$ Replicas: Factor w/ 28 levels "0","1","7","15",..: 24 19 21 15 24 22 25 20 18 13 ...
> ejer_9.lm=lm(ejer_9$y1~Replicas+A*B*C*D,data=ejer_9)
> a<-anova(ejer_9.lm)
Warning message:
In anova.lm(ejer_9.lm) :
ANOVA F-tests on an essentially perfect fit are unreliable
> a
Analysis of Variance Table
Response: ejer_9$y1
Df Sum Sq Mean Sq F value Pr(>F)
Replicas 27 38615 1430.17
A 1 561 560.67
B 1 0 0.00
C 1 1122 1122.25
B:C 1 756 756.25
Residuals 0 0
> attach(ejer_9)
The following objects are masked from ejer_9 (pos = 3):
14
A, B, C, D, factorA, factorB, factorC, factorD,
Replicas, y1, y2
> modelo<-lm(y1~A*B*C*D,data=ejer_9)
> library(pid)
> param_orig<-par(col.lab="black",pch=16,col="blue")
> paretoPlot(modelo,xlab="Efecto",ylab="Escala original",main="Gr?fica de Pareto")
> interaction.plot(ejer_9$A,ejer_9$C,ejer_9$Rendimiento1)
Error in tapply(response, list(x.factor, trace.factor), fun) :
arguments must have same length
> anova<-aov(ejer_9.lm)
> TukeyHSD(anova)
Tukey multiple comparisons of means
95% family-wise confidence level
$Replicas
diff lwr upr p adj
1-0 1.000000e+00 NaN NaN NaN
7-0 7.000000e+00 NaN NaN NaN
15-0 1.500000e+01 NaN NaN NaN
19-0 1.900000e+01 NaN NaN NaN
22-0 2.200000e+01 NaN NaN NaN
35-0 3.500000e+01 NaN NaN NaN
37-0 3.700000e+01 NaN NaN NaN
40-0 4.000000e+01 NaN NaN NaN
50-0 5.000000e+01 NaN NaN NaN
57-0 5.700000e+01 NaN NaN NaN
61-0 6.100000e+01 NaN NaN NaN
66-0 6.000000e+01 NaN NaN NaN
71-0 7.100000e+01 NaN NaN NaN
73-0 1.040000e+02 NaN NaN NaN
75-0 1.500000e+01 NaN NaN NaN
76-0 1.000000e+01 NaN NaN NaN
77-0 1.200000e+01 NaN NaN NaN
78-0 1.050000e+02 NaN NaN NaN
79-0 5.700000e+01 NaN NaN NaN
82-0 6.100000e+01 NaN NaN NaN
84-0 1.566667e+01 NaN NaN NaN
86-0 -1.136868e-13 NaN NaN NaN
88-0 3.050000e+01 NaN NaN NaN
89-0 5.000000e+01 NaN NaN NaN
93-0 7.200000e+01 NaN NaN NaN
98-0 9.800000e+01 NaN NaN NaN
145-0 1.450000e+02 NaN NaN NaN
7-1 6.000000e+00 NaN NaN NaN
15-1 1.400000e+01 NaN NaN NaN
19-1 1.800000e+01 NaN NaN NaN
15
22-1 2.100000e+01 NaN NaN NaN
35-1 3.400000e+01 NaN NaN NaN
37-1 3.600000e+01 NaN NaN NaN
40-1 3.900000e+01 NaN NaN NaN
50-1 4.900000e+01 NaN NaN NaN
57-1 5.600000e+01 NaN NaN NaN
61-1 6.000000e+01 NaN NaN NaN
66-1 5.900000e+01 NaN NaN NaN
71-1 7.000000e+01 NaN NaN NaN
73-1 1.030000e+02 NaN NaN NaN
75-1 1.400000e+01 NaN NaN NaN
76-1 9.000000e+00 NaN NaN NaN
77-1 1.100000e+01 NaN NaN NaN
78-1 1.040000e+02 NaN NaN NaN
79-1 5.600000e+01 NaN NaN NaN
82-1 6.000000e+01 NaN NaN NaN
84-1 1.466667e+01 NaN NaN NaN
86-1 -1.000000e+00 NaN NaN NaN
$A
diff lwr upr p adj
1--1 2.416667 NaN NaN NaN
$B
diff lwr upr p adj
1--1 0 NaN NaN NaN
$C
diff lwr upr p adj
1--1 -4.1875 NaN NaN NaN
$`B:C`
diff lwr upr p adj
1:-1--1:-1 -3.4375 NaN NaN NaN
-1:1--1:-1 -7.6250 NaN NaN NaN
1:1--1:-1 -4.1875 NaN NaN NaN
-1:1-1:-1 -4.1875 NaN NaN NaN
1:1-1:-1 -0.7500 NaN NaN NaN
1:1--1:1 3.4375 NaN NaN NaN
Warning messages:
1: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
2: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
3: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
4: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
5: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
> ejer_9_2.lm=lm(ejer_9$y2~Replicas+A*B*C*D,data=ejer_9)
> a<-anova(ejer_9_2.lm)
Warning message:
In anova.lm(ejer_9_2.lm) :
ANOVA F-tests on an essentially perfect fit are unreliable
> a
16
Analysis of Variance Table
Response: ejer_9$y2
Df Sum Sq Mean Sq F value Pr(>F)
Replicas 27 35112 1300.5
A 1 0 0.0
B 1 0 0.0
C 1 0 0.0
B:C 1 0 0.0
Residuals 0 0
> anova<-aov(ejer_9_2.lm)
> TukeyHSD(anova)
Tukey multiple comparisons of means
95% family-wise confidence level
$Replicas
diff lwr upr p adj
1-0 1 NaN NaN NaN
7-0 7 NaN NaN NaN
15-0 15 NaN NaN NaN
19-0 19 NaN NaN NaN
$A
diff lwr upr p adj
1--1 0 NaN NaN NaN
$B
diff lwr upr p adj
1--1 -7.105427e-15 NaN NaN NaN
$C
diff lwr upr p adj
1--1 -7.105427e-15 NaN NaN NaN
$`B:C`
diff lwr upr p adj
1:-1--1:-1 -1.421085e-14 NaN NaN NaN
-1:1--1:-1 -1.421085e-14 NaN NaN NaN
1:1--1:-1 -1.421085e-14 NaN NaN NaN
-1:1-1:-1 0.000000e+00 NaN NaN NaN
1:1-1:-1 0.000000e+00 NaN NaN NaN
1:1--1:1 0.000000e+00 NaN NaN NaN
Warning messages:
1: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
2: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
3: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
4: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
5: In qtukey(conf.level, length(means), x$df.residual) : NaNs produced
> R1=(38840-2197)*100/38840
17
> R1
[1] 94.34346
> R2=(1316.2-531.97)*100/1316.2
> R2
[1] 59.58289
> residuos <- rstandard(ejer_9.lm)
EJERCICIO 10
## x1 x2 x3 resistencia
## 1 -1 -1 -1 3.8
## 2 1 -1 -1 6.6
## 3 -1 1 -1 3.4
## 4 1 1 -1 6.8
## 5 -1 -1 1 2.3
## 6 1 -1 1 4.7
## 7 -1 1 1 2.1
## 8 1 1 1 4.2
## 9 -1 -1 -1 3.1
## 10 1 -1 -1 8.0
## 11 -1 1 -1 1.7
## 12 1 1 -1 8.2
## 13 -1 -1 1 3.1
## 14 1 -1 1 3.5
## 15 -1 1 1 1.1
## 16 1 1 1 4.7
## 17 -1 -1 -1 2.2
## 18 1 -1 -1 6.8
## 19 -1 1 -1 3.8
## 20 1 1 -1 6.0
## 21 -1 -1 1 0.7
## 22 1 -1 1 4.4
## 23 -1 1 1 3.6
## 24 1 1 1 2.9
names(Datos10)
regresion
a<-lm(resistencia~x1*x2*x3)
eje10<-aov(a)
summary(eje10)
18
## Df Sum Sq Mean Sq F value Pr(>F)
## x1 1 53.70 53.70 53.500 1.74e-06 ***
## x2 1 0.02 0.02 0.020 0.888371
## x3 1 22.23 22.23 22.151 0.000238 ***
## x1:x2 1 0.12 0.12 0.120 0.733583
## x1:x3 1 6.93 6.93 6.908 0.018260 *
## x2:x3 1 0.01 0.01 0.010 0.920125
## x1:x2:x3 1 0.07 0.07 0.070 0.794495
## Residuals 16 16.06 1.00
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(FrF2)
MEPlot(eje10)
−1 1 −1 1 −1 1
grafica de interacciones
19
Efecto de interaccion AC para la resistencia al rasgamiento
7
x3
Direccion del rasgu?o
−1
6
1
5
4
3
2
−1 1
Papel
x2
−1
1
4.5
Humedad
3.5
2.5
−1 1
Papel
20
Efecto de interaccion BC para la resistencia al rasgamiento
5.0
x3
Direccion del rasgu?o
−1
4.5
1
4.0
3.5
−1 1
Humedad
plot(eje10)
23 23
1.5
Standardized residuals
0.5
Residuals
0.5
−0.5
−0.5
−1.5
11
−1.5
21
21 11
2 3 4 5 6 7 −2 −1 0 1 2
21
Constant Leverage:
Scale−Location Residuals vs Factor Levels
2
21
23
11
1.2
23
Standardized residuals
Standardized residuals
1
0.8
0
0.4
−1
21 11
0.0
−2
x1 :
2 3 4 5 6 7 −1 1
22