> showData(ordenadoresrcm, placement='-20+200', font=getRcmdr('logFont'), maxwidth=80, maxheight=30) > summary(ordenadoresrcm) tipo origen origenn proc clock portátil :10 Extranjero:5 Min. :0.00 Min. :0.0 Min. :1.000 sobremesa:10 Mixto :8 1st Qu.:0.75 1st Qu.:0.0 1st Qu.:1.575 Nacional :7 Median :1.00 Median :0.5 Median :2.200 Mean :1.10 Mean :0.5 Mean :2.125 3rd Qu.:2.00 3rd Qu.:1.0 3rd Qu.:2.550 Max. :2.00 Max. :1.0 Max. :3.200 ram tiempo1 tiempo2 valoracion calificación Min. : 10.0 Min. : 2.600 Min. : 4.895 Min. : 0.000 Min. :1.00 1st Qu.: 120.0 1st Qu.: 5.075 1st Qu.: 6.774 1st Qu.: 4.749 1st Qu.:1.75 Median : 256.0 Median : 7.350 Median :10.193 Median : 6.078 Median :2.00 Mean : 512.5 Mean : 7.655 Mean :11.254 Mean : 6.244 Mean :2.15 3rd Qu.: 640.0 3rd Qu.: 9.500 3rd Qu.:14.317 3rd Qu.: 8.954 3rd Qu.:3.00 Max. :2048.0 Max. :15.100 Max. :22.468 Max. :10.000 Max. :3.00 > numSummary(ordenadoresrcm[,"valoracion"], statistics=c("mean", "sd", "quantiles"), quantiles=c( 0,.25,.5,.75,1 )) mean sd 0% 25% 50% 75% 100% n 6.243838 2.863701 0 4.749327 6.078225 8.95419 10 20 > cor.test(ordenadoresrcm$tiempo2, ordenadoresrcm$valoracion, alternative="two.sided", method="pearson") Pearson's product-moment correlation data: ordenadoresrcm$tiempo2 and ordenadoresrcm$valoracion t = -32.3583, df = 18, p-value < 2.2e-16 alternative hypothesis: true correlation is not equal to 0 95 percent confidence interval: -0.9967118 -0.9781882 sample estimates: cor -0.9915138 > cor.test(ordenadoresrcm$tiempo2, ordenadoresrcm$valoracion, alternative="two.sided", method="spearman") Spearman's rank correlation rho data: ordenadoresrcm$tiempo2 and ordenadoresrcm$valoracion S = 2656, p-value = 6.084e-06 alternative hypothesis: true rho is not equal to 0 sample estimates: rho -0.9969925 > cor.test(ordenadoresrcm$tiempo2, ordenadoresrcm$valoracion, alternative="two.sided", method="kendall") Kendall's rank correlation tau data: ordenadoresrcm$tiempo2 and ordenadoresrcm$valoracion T = 2, p-value < 2.2e-16 alternative hypothesis: true tau is not equal to 0 sample estimates: tau -0.9789474 > .Table <- xtabs(~tipo+origen, data=ordenadoresrcm) > .Table origen tipo Extranjero Mixto Nacional portátil 4 1 5 sobremesa 1 7 2 > colPercents(.Table) # Column Percentages origen tipo Extranjero Mixto Nacional portátil 80 12.5 71.4 sobremesa 20 87.5 28.6 Total 100 100.0 100.0 Count 5 8.0 7.0 > .Test <- chisq.test(.Table, correct=FALSE) > .Test Pearson's Chi-squared test data: .Table X-squared = 7.5857, df = 2, p-value = 0.02253 > .Test$expected # Expected Counts origen tipo Extranjero Mixto Nacional portátil 2.5 4 3.5 sobremesa 2.5 4 3.5 > round(.Test$residuals^2, 2) # Chi-square Components origen tipo Extranjero Mixto Nacional portátil 0.90 2.25 0.64 sobremesa 0.90 2.25 0.64 > remove(.Test) > remove(.Table) > shapiro.test(ordenadoresrcm$tiempo1) Shapiro-Wilk normality test data: ordenadoresrcm$tiempo1 W = 0.9625, p-value = 0.5951 > t.test(ordenadoresrcm$tiempo1, alternative='two.sided', mu=0.0, conf.level=.95) One Sample t-test data: ordenadoresrcm$tiempo1 t = 10.4362, df = 19, p-value = 2.634e-09 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 6.119763 9.190237 sample estimates: mean of x 7.655 > .Anova <- lm(valoracion ~ origen, data=ordenadoresrcm) > anova(.Anova) Analysis of Variance Table Response: valoracion Df Sum Sq Mean Sq F value Pr(>F) origen 2 108.997 54.498 19.789 3.642e-05 *** Residuals 17 46.818 2.754 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > tapply(ordenadoresrcm$valoracion, ordenadoresrcm$origen, mean, na.rm=TRUE) # means Extranjero Mixto Nacional 4.805972 9.079848 4.029731 > tapply(ordenadoresrcm$valoracion, ordenadoresrcm$origen, sd, na.rm=TRUE) # std. deviations Extranjero Mixto Nacional 1.5824672 0.9037017 2.2761262 > tapply(ordenadoresrcm$valoracion, ordenadoresrcm$origen, function(x) sum(!is.na(x))) # counts Extranjero Mixto Nacional 5 8 7 > remove(.Anova) > .Table <- xtabs(~ tipo , data= ordenadoresrcm ) > .Table tipo portátil sobremesa 10 10 > prop.test(rbind(.Table), alternative='two.sided', p=.5, conf.level=.95, correct=FALSE) 1-sample proportions test without continuity correction data: rbind(.Table), null probability 0.5 X-squared = 0, df = 1, p-value = 1 alternative hypothesis: true p is not equal to 0.5 95 percent confidence interval: 0.299298 0.700702 sample estimates: p 0.5 > .Table <- xtabs(~ tipo , data= ordenadoresrcm ) > .Table tipo portátil sobremesa 10 10 > prop.test(rbind(.Table), alternative='two.sided', p=.5, conf.level=.95, correct=TRUE) > .Table <- xtabs(~ tipo , data= ordenadoresrcm ) > .Table tipo portátil sobremesa 10 10 > prop.test(rbind(.Table), alternative='two.sided', p=.5, conf.level=.95, correct=TRUE) > .Table <- xtabs(~ tipo , data= ordenadoresrcm ) > .Table tipo portátil sobremesa 10 10 > > tapply(ordenadoresrcm$tiempo1, ordenadoresrcm$tipo, var, na.rm=TRUE) portátil sobremesa 9.011111 6.141000 > var.test(tiempo1 ~ tipo, alternative='two.sided', conf.level=.95, data=ordenadoresrcm) F test to compare two variances data: tiempo1 by tipo F = 1.4674, num df = 9, denom df = 9, p-value = 0.577 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.3644736 5.9076178 sample estimates: ratio of variances 1.467369 > tapply(ordenadoresrcm$tiempo1, ordenadoresrcm$tipo, var, na.rm=TRUE) portátil sobremesa 9.011111 6.141000 > bartlett.test(tiempo1 ~ tipo, data=ordenadoresrcm) Bartlett test of homogeneity of variances data: tiempo1 by tipo Bartlett's K-squared = 0.3115, df = 1, p-value = 0.5767 > tapply(ordenadoresrcm$tiempo1, ordenadoresrcm$tipo, var, na.rm=TRUE) portátil sobremesa 9.011111 6.141000 > levene.test(ordenadoresrcm$tiempo1, ordenadoresrcm$tipo) Levene's Test for Homogeneity of Variance Df F value Pr(>F) group 1 0.3826 0.544 18 > tapply(ordenadoresrcm$valoracion, ordenadoresrcm$origen, median, na.rm=TRUE) Extranjero Mixto Nacional 5.595717 9.145888 5.108580 > kruskal.test(valoracion ~ origen, data=ordenadoresrcm) Kruskal-Wallis rank sum test data: valoracion by origen Kruskal-Wallis chi-squared = 13.8343, df = 2, p-value = 0.0009907 > tapply(ordenadoresrcm$valoracion, ordenadoresrcm$tipo, median, na.rm=TRUE) portátil sobremesa 5.299528 8.951200 > wilcox.test(valoracion ~ tipo, alternative="two.sided", data=ordenadoresrcm) Wilcoxon rank sum test data: valoracion by tipo W = 15, p-value = 0.006841 alternative hypothesis: true location shift is not equal to 0 > plot(ordenadoresrcm$calificación, type="h") > identify(ordenadoresrcm$calificación, labels=rownames(ordenadoresrcm)) > plot(ordenadoresrcm$calificación, type="p") > Hist(ordenadoresrcm$valoracion, scale="density", breaks="Sturges", col="darkgray") > plot(ordenadoresrcm$valoracion, type="p") > abline(h=0, col="gray") > stem.leaf(ordenadoresrcm$valoracion, na.rm=TRUE) 1 | 2: represents 1.2 leaf unit: 0.1 n: 20 1 0 | 0 1 | 4 2 | 668 5 3 | 6 4 | 10 5 | 14589 (2) 6 | 23 8 7 | 1 7 8 | 89 5 9 | 0277 1 10 | 0 > boxplot(valoracion~tipo, ylab="valoracion", xlab="tipo", data=ordenadoresrcm) > barplot(table(ordenadoresrcm$tipo), xlab="tipo", ylab="Frequency") > pie(table(ordenadoresrcm$tipo), labels=levels(ordenadoresrcm$tipo), main="tipo", col=rainbow(length(levels(ordenadoresrcm$tipo)))) > qq.plot(ordenadoresrcm$ram, dist= "norm", labels=FALSE) > qq.plot(ordenadoresrcm$tiempo1, dist= "norm", labels=FALSE) > qq.plot(ordenadoresrcm$tiempo2, dist= "norm", labels=FALSE) > qq.plot(ordenadoresrcm$valoracion, dist= "norm", labels=FALSE) > scatterplot.matrix(~calificación+clock+origenn+proc+ram+tiempo1+tiempo2+valoracion, reg.line=lm, smooth=FALSE, span=0.5, diagonal = 'histogram', data=ordenadoresrcm) > boxplot(tiempo1~origen, ylab="tiempo1", xlab="origen", data=ordenadoresrcm) > scatterplot(valoracion~ram | tipo, reg.line=lm, smooth=FALSE, labels=FALSE, boxplots=FALSE, span=0.5, by.groups=TRUE, data=ordenadoresrcm) > scatterplot(valoracion~ram | tipo, reg.line=lm, smooth=FALSE, labels=FALSE, boxplots='xy', span=0.5, by.groups=TRUE, data=ordenadoresrcm) > > indicessorted = order (ordenadoresrcm$valoracion) > ordenadoresrcm = ordenadoresrcm[indicessorted, ] > matplot(ordenadoresrcm$valoracion, ordenadoresrcm[, c("clock","tiempo1","tiempo2")], type="b", lty=1, ylab="(1) clock, (2) tiempo1, (3) tiempo2") > xyplot(valoracion ~ clock + ram | origen, groups=tipo, pch=16, + auto.key=list(border=TRUE), par.settings = simpleTheme(pch=16), scales=list(x=list(relation='same'), y=list(relation='same')), + data=ordenadoresrcm) > RegModel.1 <- lm(valoracion~clock+ram+tiempo1+tiempo2, data=ordenadoresrcm) > summary(RegModel.1) Call: lm(formula = valoracion ~ clock + ram + tiempo1 + tiempo2, data = ordenadoresrcm) Residuals: Min 1Q Median 3Q Max -0.81709 -0.07221 0.15003 0.21135 0.31801 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 11.2148698 1.2185390 9.204 1.47e-07 *** clock 0.2807308 0.3226055 0.870 0.398 ram 0.0002371 0.0002184 1.086 0.295 tiempo1 0.0087666 0.1676220 0.052 0.959 tiempo2 -0.5114622 0.0934434 -5.473 6.42e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.3892 on 15 degrees of freedom Multiple R-squared: 0.9854, Adjusted R-squared: 0.9815 F-statistic: 253.5 on 4 and 15 DF, p-value: 1.419e-13 > RegModel.2 <- lm(valoracion~clock+ram+tiempo1, data=ordenadoresrcm) > summary(RegModel.2) Call: lm(formula = valoracion ~ clock + ram + tiempo1, data = ordenadoresrcm) Residuals: Min 1Q Median 3Q Max -1.03391 -0.46023 -0.01186 0.42722 1.22025 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 12.2639400 2.0171991 6.080 1.59e-05 *** clock 0.1079765 0.5381860 0.201 0.844 ram 0.0000864 0.0003633 0.238 0.815 tiempo1 -0.8221856 0.1191195 -6.902 3.56e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.6524 on 16 degrees of freedom Multiple R-squared: 0.9563, Adjusted R-squared: 0.9481 F-statistic: 116.7 on 3 and 16 DF, p-value: 4.352e-11 > RegModel.3 <- lm(valoracion~clock+ram, data=ordenadoresrcm) > summary(RegModel.3) Call: lm(formula = valoracion ~ clock + ram, data = ordenadoresrcm) Residuals: Min 1Q Median 3Q Max -2.1147 -0.8083 -0.3051 0.6648 2.5027 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.0649127 1.1280676 -0.944 0.3584 clock 3.1398465 0.6016438 5.219 6.95e-05 *** ram 0.0012421 0.0006237 1.991 0.0628 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.262 on 17 degrees of freedom Multiple R-squared: 0.8262, Adjusted R-squared: 0.8057 F-statistic: 40.4 on 2 and 17 DF, p-value: 3.473e-07 > RegModel.4 <- lm(valoracion~ram, data=ordenadoresrcm) > summary(RegModel.4) Call: lm(formula = valoracion ~ ram, data = ordenadoresrcm) Residuals: Min 1Q Median 3Q Max -4.6063 -1.5492 0.4936 0.9672 3.0027 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4.4972811 0.5793942 7.762 3.76e-07 *** ram 0.0034079 0.0007299 4.669 0.000191 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.979 on 18 degrees of freedom Multiple R-squared: 0.5477, Adjusted R-squared: 0.5226 F-statistic: 21.8 on 1 and 18 DF, p-value: 0.0001911 > summary(RegModel.1, cor=FALSE) Call: lm(formula = valoracion ~ clock + ram + tiempo1 + tiempo2, data = ordenadoresrcm) Residuals: Min 1Q Median 3Q Max -0.81709 -0.07221 0.15003 0.21135 0.31801 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 11.2148698 1.2185390 9.204 1.47e-07 *** clock 0.2807308 0.3226055 0.870 0.398 ram 0.0002371 0.0002184 1.086 0.295 tiempo1 0.0087666 0.1676220 0.052 0.959 tiempo2 -0.5114622 0.0934434 -5.473 6.42e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.3892 on 15 degrees of freedom Multiple R-squared: 0.9854, Adjusted R-squared: 0.9815 F-statistic: 253.5 on 4 and 15 DF, p-value: 1.419e-13 > Confint(RegModel.1, level=.95) 2.5 % 97.5 % (Intercept) 8.6176154687 13.8121241213 clock -0.4068864916 0.9683481472 ram -0.0002284708 0.0007027429 tiempo1 -0.3485112571 0.3660444594 tiempo2 -0.7106321549 -0.3122923118 > .Hypothesis <- matrix(c(0,0,0,0,0.5), 1, 5, byrow=TRUE) > .RHS <- c(0) > linear.hypothesis(RegModel.1, .Hypothesis, rhs=.RHS) Linear hypothesis test Hypothesis: 0.5 tiempo2 = 0 Model 1: valoracion ~ clock + ram + tiempo1 + tiempo2 Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 15 2.2717 2 16 6.8090 -1 -4.5373 29.959 6.417e-05 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > remove(.Hypothesis, .RHS) > .Hypothesis <- matrix(c(10,0,0,0.1,-0.5), 1, 5, byrow=TRUE) > .RHS <- c(0) > linear.hypothesis(RegModel.1, .Hypothesis, rhs=.RHS) Linear hypothesis test Hypothesis: 0 (Intercept) + 0.1 tiempo1 - 0.5 tiempo2 = 0 Model 1: valoracion ~ clock + ram + tiempo1 + tiempo2 Model 2: restricted model Res.Df RSS Df Sum of Sq F Pr(>F) 1 15 2.2717 2 16 15.1935 -1 -12.9218 85.321 1.405e-07 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > remove(.Hypothesis, .RHS) > oldpar <- par(oma=c(0,0,3,0), mfrow=c(2,2)) > plot(RegModel.1) > par(oldpar) > cr.plots(RegModel.1, ask=FALSE) > trellis.device(theme="col.whitebg") > plot(all.effects(RegModel.1), ask=FALSE) > ordenadoresrcm$tipon <- with(ordenadoresrcm, as.numeric(tipo=="portátil")) > LinearModel.5 <- lm(tipon ~ tiempo1 , data=ordenadoresrcm) > summary(LinearModel.5) Call: lm(formula = tipon ~ tiempo1, data = ordenadoresrcm) Residuals: Min 1Q Median 3Q Max -0.80186 -0.26266 -0.08443 0.38990 0.73057 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.19081 0.24974 -0.764 0.45475 tiempo1 0.09024 0.03010 2.998 0.00772 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4304 on 18 degrees of freedom Multiple R-squared: 0.333, Adjusted R-squared: 0.2959 F-statistic: 8.986 on 1 and 18 DF, p-value: 0.007724 > ordenadoresrcm$fitted.LinearModel.5 <- fitted(LinearModel.5) > ordenadoresrcm$residuals.LinearModel.5 <- residuals(LinearModel.5) > ordenadoresrcm$rstudent.LinearModel.5 <- rstudent(LinearModel.5) > ordenadoresrcm$hatvalues.LinearModel.5 <- hatvalues(LinearModel.5) > ordenadoresrcm$cooks.distance.LinearModel.5 <- cooks.distance(LinearModel.5) > ordenadoresrcm$obsNumber <- 1:nrow(ordenadoresrcm) > ordenadoresrcm$yhatLM <- with(ordenadoresrcm, as.numeric(fitted.LinearModel.5 >= 0.5)) > GLM.6 <- glm(tipon ~ tiempo1 , family=binomial(logit), data=ordenadoresrcm) > summary(GLM.6) Call: glm(formula = tipon ~ tiempo1, family = binomial(logit), data = ordenadoresrcm) Deviance Residuals: Min 1Q Median 3Q Max -2.0069 -0.6985 -0.0987 0.8810 1.7317 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -3.9416 1.8528 -2.127 0.0334 * tiempo1 0.5284 0.2438 2.167 0.0302 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 27.726 on 19 degrees of freedom Residual deviance: 19.781 on 18 degrees of freedom AIC: 23.781 Number of Fisher Scoring iterations: 5 > ordenadoresrcm$fitted.GLM.6 <- fitted(GLM.6) > ordenadoresrcm$residuals.GLM.6 <- residuals(GLM.6) > ordenadoresrcm$rstudent.GLM.6 <- rstudent(GLM.6) > ordenadoresrcm$hatvalues.GLM.6 <- hatvalues(GLM.6) > ordenadoresrcm$cooks.distance.GLM.6 <- cooks.distance(GLM.6) > ErrorRateLM = sum(yhatLM != tipon)/ dim(ordenadoresrcm)[1] > ErrorRateGLM = sum(yhatGLM != tipon) / dim(ordenadoresrcm)[1] > ordenadoresrcm$yhatGLM <- with(ordenadoresrcm, as.numeric(fitted.GLM.6 >= 0.5)) > ErrorRateLM = sum(yhatLM != tipon) / dim(ordenadoresrcm) > ErrorRateGLM = sum(yhatGLM != tipon) / dim(ordenadoresrcm)