schilling@SchillingX230:~$ R R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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. Natural language support but running in an English locale 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 an HTML browser interface to help. Type 'q()' to quit R. > x = seq(-5,5,by=0.1) > x [1] -5.0 -4.9 -4.8 -4.7 -4.6 -4.5 -4.4 -4.3 -4.2 -4.1 -4.0 -3.9 -3.8 -3.7 -3.6 [16] -3.5 -3.4 -3.3 -3.2 -3.1 -3.0 -2.9 -2.8 -2.7 -2.6 -2.5 -2.4 -2.3 -2.2 -2.1 [31] -2.0 -1.9 -1.8 -1.7 -1.6 -1.5 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 [46] -0.5 -0.4 -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 [61] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 [76] 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 [91] 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 > beta0=1 > beta1=2.4 > noise=rnorm(length(x),mean=0,std=0.5) Error in rnorm(length(x), mean = 0, std = 0.5) : unused argument (std = 0.5) > noise=rnorm(length(x),0,0.5) > noise [1] -1.4251301647 -0.4442567272 0.1143163748 0.8779685569 -0.1732184994 [6] 0.3799955891 0.7873893068 -0.1188042427 0.0996600501 0.0359936568 [11] -0.0941153603 -0.2928489651 0.0574317179 0.5186504125 -0.1007411845 [16] -0.1040732300 -0.4885629019 0.7044580372 -0.1096771814 -0.4183087842 [21] -0.4636305184 0.6328762392 -0.7983479692 -0.0409224664 1.1415370458 [26] -0.0763578591 0.4704608851 -0.8107103705 -0.3742830359 -0.2623613484 [31] -0.8128512421 0.7282394610 -0.9313142821 -0.5093673181 -0.8870842659 [36] -1.4395736680 0.9993164744 0.4902101751 0.6638745302 -0.1402626088 [41] 0.8848244720 -0.6271547412 -0.6828306926 -0.0615130905 -0.2332098029 [46] -0.2400229504 0.1731584063 -0.2832433446 0.5165844703 0.0005545326 [51] -0.0004752740 0.0731506796 -0.4720779226 -0.0510483438 0.1818937513 [56] -0.8743936598 0.6733429676 1.7462054250 1.1438048841 0.7704504436 [61] -0.0312037889 -0.4055335013 1.0292332174 -0.7389027824 0.0481048608 [66] 0.1933241301 -0.6163229951 0.0216390171 -0.0717864968 0.5408981037 [71] -0.6942574533 0.0256843639 0.3949355589 0.1128763013 -0.8036116745 [76] -0.0286091897 0.5553196624 -0.7149622409 0.3755380819 -0.3786186112 [81] 0.6097865108 -0.0774656718 0.2887013923 -0.3236596832 1.3642555103 [86] -0.4811903537 -1.1412181494 0.2485060785 -0.2785890449 0.2931566741 [91] -0.0037537218 0.5309545703 0.0133960739 -0.0795748463 0.7391812442 [96] 0.0788176690 -0.4948296613 -0.0006822591 0.3511091574 -0.0734143749 [101] 0.0088520253 > y = beta0 + beta1*x + noise > y [1] -12.425130165 -11.204256727 -10.405683625 -9.402031443 -10.213218499 [6] -9.420004411 -8.772610693 -9.438804243 -8.980339950 -8.804006343 [11] -8.694115360 -8.652848965 -8.062568282 -7.361349588 -7.740741184 [16] -7.504073230 -7.648562902 -6.215541963 -6.789677181 -6.858308784 [21] -6.663630518 -5.327123761 -6.518347969 -5.520922466 -4.098462954 [26] -5.076357859 -4.289539115 -5.330710371 -4.654283036 -4.302361348 [31] -4.612851242 -2.831760539 -4.251314282 -3.589367318 -3.727084266 [36] -4.039573668 -1.360683526 -1.629789825 -1.216125470 -1.780262609 [41] -0.515175528 -1.787154741 -1.602830693 -0.741513091 -0.673209803 [46] -0.440022950 0.213158406 -0.003243345 1.036584470 0.760554533 [51] 0.999524726 1.313150680 1.007922077 1.668951656 2.141893751 [56] 1.325606340 3.113342968 4.426205425 4.063804884 3.930450444 [61] 3.368796211 3.234466499 4.909233217 3.381097218 4.408104861 [66] 4.793324130 4.223677005 5.101639017 5.248213503 6.100898104 [71] 5.105742547 6.065684364 6.674935559 6.632876301 5.956388326 [76] 6.971390810 7.795319662 6.765037759 8.095538082 7.581381389 [81] 8.809786511 8.362534328 8.968701392 8.596340317 10.524255510 [86] 8.918809646 8.498781851 10.128506079 9.841410955 10.653156674 [91] 10.596246278 11.370954570 11.093396074 11.240425154 12.299181244 [96] 11.878817669 11.545170339 12.279317741 12.871109157 12.686585625 [101] 13.008852025 > plot(x,y) > model = glm glm glm.control glm.fit > model = glm( y ~ x , family=gaussian) > model Call: glm(formula = y ~ x, family = gaussian) Coefficients: (Intercept) x 1.004 2.415 Degrees of Freedom: 100 Total (i.e. Null); 99 Residual Null Deviance: 5040 Residual Deviance: 34.34 AIC: 183.7 > beta0 [1] 1 > beta1 [1] 2.4 > plot(x,y) > predictions = model$f model$fitted.values model$family model$formula > predictions = model$f model$fitted.values model$family model$formula > predictions = model$fitted > plot(x,y) > lines(x,predictions,col="red") > y = beta0 + beta1*x > model = glm( y ~ x , family=gaussian) > plot(x,y) > lines(x,predictions,col="red") > y = beta0 + beta1*x + noise > model = glm( y ~ x , family=poisson) Error in eval(expr, envir, enclos) : negative values not allowed for the 'Poisson' family > > > > > x=seq(1,14) > x [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 > y = c(1,4,5) > y [1] 1 4 5 > names = c("patrick","nico","vanessa","norman") > names [1] "patrick" "nico" "vanessa" "norman" > y = c(0,1,2,3,1,4,9,18,23,31,20,25,37,45) > y [1] 0 1 2 3 1 4 9 18 23 31 20 25 37 45 > glm(y ~ x , family=poisson) Call: glm(formula = y ~ x, family = poisson) Coefficients: (Intercept) x 0.3396 0.2565 Degrees of Freedom: 13 Total (i.e. Null); 12 Residual Null Deviance: 207.3 Residual Deviance: 29.65 AIC: 86.58 > plot(x,y) > lines(x,model$fitted) Error in xy.coords(x, y) : 'x' and 'y' lengths differ > model = glm(y ~ x , family=poisson) > lines(x,model$fitted) > > > > cebData = read.table("ceb.txt",header=TRUE) > cebData x1.x2.x3.x4.x5.y 1 1,1,1,0.5,1.14,8 2 1,1,2,1.14,0.73,21 3 1,1,3,0.9,0.67,42 4 1,1,4,0.73,0.48,51 5 1,2,1,1.17,1.06,12 6 1,2,2,0.85,1.59,27 7 1,2,3,1.05,0.73,39 8 1,2,4,0.69,0.54,51 9 1,3,1,0.97,0.88,62 10 1,3,2,0.96,0.81,102 11 1,3,3,0.97,0.8,107 12 1,3,4,0.74,0.59,47 13 2,1,1,3.1,1.66,10 14 2,1,2,2.67,0.99,30 15 2,1,3,2.04,1.87,24 16 2,1,4,1.73,0.68,22 17 2,2,1,4.54,3.44,13 18 2,2,2,2.65,1.51,37 19 2,2,3,2.68,0.97,44 20 2,2,4,2.29,0.81,21 21 2,3,1,2.44,1.93,70 22 2,3,2,2.71,1.36,117 23 2,3,3,2.47,1.3,81 24 2,3,4,2.24,1.19,21 25 3,1,1,4.08,1.72,12 26 3,1,2,3.67,2.31,27 27 3,1,3,2.9,1.57,20 28 3,1,4,2,1.82,12 29 3,2,1,4.17,2.97,18 30 3,2,2,3.33,2.99,43 31 3,2,3,3.62,1.96,29 32 3,2,4,3.33,1.52,15 33 3,3,1,4.14,3.52,88 34 3,3,2,4.14,3.31,132 35 3,3,3,3.94,3.28,50 36 3,3,4,3.33,2.5,9 37 4,1,1,4.21,2.03,14 38 4,1,2,4.94,1.46,31 39 4,1,3,3.15,0.81,13 40 4,1,4,2.75,0.92,4 41 4,2,1,4.7,7.4,23 42 4,2,2,5.36,2.97,42 43 4,2,3,4.6,3.83,20 44 4,2,4,3.8,0.7,5 45 4,3,1,5.06,4.91,114 46 4,3,2,5.59,3.23,86 47 4,3,3,4.5,3.29,30 48 4,3,4,2,0,1 49 5,1,1,5.62,4.15,21 50 5,1,2,5.06,4.64,18 51 5,1,3,3.92,4.08,12 52 5,1,4,2.6,4.3,5 53 5,2,1,5.36,7.19,22 54 5,2,2,5.88,4.44,25 55 5,2,3,5,4.33,13 56 5,2,4,5.33,0.33,3 57 5,3,1,6.46,8.2,117 58 5,3,2,6.34,5.72,68 59 5,3,3,5.74,5.2,23 60 5,3,4,2.5,0.5,2 61 6,1,1,6.6,12.4,47 62 6,1,2,6.74,11.66,27 63 6,1,3,5.38,4.27,8 64 6,1,4,2,0,1 65 6,2,1,6.52,11.45,46 66 6,2,2,7.51,10.53,45 67 6,2,3,7.54,12.6,13 68 6,3,1,7.48,11.34,195 69 6,3,2,7.81,7.57,59 70 6,3,3,5.8,7.07,10 > cebData$x1 [1] 1,1,1,0.5,1.14,8 1,1,2,1.14,0.73,21 1,1,3,0.9,0.67,42 [4] 1,1,4,0.73,0.48,51 1,2,1,1.17,1.06,12 1,2,2,0.85,1.59,27 [7] 1,2,3,1.05,0.73,39 1,2,4,0.69,0.54,51 1,3,1,0.97,0.88,62 [10] 1,3,2,0.96,0.81,102 1,3,3,0.97,0.8,107 1,3,4,0.74,0.59,47 [13] 2,1,1,3.1,1.66,10 2,1,2,2.67,0.99,30 2,1,3,2.04,1.87,24 [16] 2,1,4,1.73,0.68,22 2,2,1,4.54,3.44,13 2,2,2,2.65,1.51,37 [19] 2,2,3,2.68,0.97,44 2,2,4,2.29,0.81,21 2,3,1,2.44,1.93,70 [22] 2,3,2,2.71,1.36,117 2,3,3,2.47,1.3,81 2,3,4,2.24,1.19,21 [25] 3,1,1,4.08,1.72,12 3,1,2,3.67,2.31,27 3,1,3,2.9,1.57,20 [28] 3,1,4,2,1.82,12 3,2,1,4.17,2.97,18 3,2,2,3.33,2.99,43 [31] 3,2,3,3.62,1.96,29 3,2,4,3.33,1.52,15 3,3,1,4.14,3.52,88 [34] 3,3,2,4.14,3.31,132 3,3,3,3.94,3.28,50 3,3,4,3.33,2.5,9 [37] 4,1,1,4.21,2.03,14 4,1,2,4.94,1.46,31 4,1,3,3.15,0.81,13 [40] 4,1,4,2.75,0.92,4 4,2,1,4.7,7.4,23 4,2,2,5.36,2.97,42 [43] 4,2,3,4.6,3.83,20 4,2,4,3.8,0.7,5 4,3,1,5.06,4.91,114 [46] 4,3,2,5.59,3.23,86 4,3,3,4.5,3.29,30 4,3,4,2,0,1 [49] 5,1,1,5.62,4.15,21 5,1,2,5.06,4.64,18 5,1,3,3.92,4.08,12 [52] 5,1,4,2.6,4.3,5 5,2,1,5.36,7.19,22 5,2,2,5.88,4.44,25 [55] 5,2,3,5,4.33,13 5,2,4,5.33,0.33,3 5,3,1,6.46,8.2,117 [58] 5,3,2,6.34,5.72,68 5,3,3,5.74,5.2,23 5,3,4,2.5,0.5,2 [61] 6,1,1,6.6,12.4,47 6,1,2,6.74,11.66,27 6,1,3,5.38,4.27,8 [64] 6,1,4,2,0,1 6,2,1,6.52,11.45,46 6,2,2,7.51,10.53,45 [67] 6,2,3,7.54,12.6,13 6,3,1,7.48,11.34,195 6,3,2,7.81,7.57,59 [70] 6,3,3,5.8,7.07,10 70 Levels: 1,1,1,0.5,1.14,8 1,1,2,1.14,0.73,21 ... 6,3,3,5.8,7.07,10 > cebData x1.x2.x3.x4.x5.y 1 1,1,1,0.5,1.14,8 2 1,1,2,1.14,0.73,21 3 1,1,3,0.9,0.67,42 4 1,1,4,0.73,0.48,51 5 1,2,1,1.17,1.06,12 6 1,2,2,0.85,1.59,27 7 1,2,3,1.05,0.73,39 8 1,2,4,0.69,0.54,51 9 1,3,1,0.97,0.88,62 10 1,3,2,0.96,0.81,102 11 1,3,3,0.97,0.8,107 12 1,3,4,0.74,0.59,47 13 2,1,1,3.1,1.66,10 14 2,1,2,2.67,0.99,30 15 2,1,3,2.04,1.87,24 16 2,1,4,1.73,0.68,22 17 2,2,1,4.54,3.44,13 18 2,2,2,2.65,1.51,37 19 2,2,3,2.68,0.97,44 20 2,2,4,2.29,0.81,21 21 2,3,1,2.44,1.93,70 22 2,3,2,2.71,1.36,117 23 2,3,3,2.47,1.3,81 24 2,3,4,2.24,1.19,21 25 3,1,1,4.08,1.72,12 26 3,1,2,3.67,2.31,27 27 3,1,3,2.9,1.57,20 28 3,1,4,2,1.82,12 29 3,2,1,4.17,2.97,18 30 3,2,2,3.33,2.99,43 31 3,2,3,3.62,1.96,29 32 3,2,4,3.33,1.52,15 33 3,3,1,4.14,3.52,88 34 3,3,2,4.14,3.31,132 35 3,3,3,3.94,3.28,50 36 3,3,4,3.33,2.5,9 37 4,1,1,4.21,2.03,14 38 4,1,2,4.94,1.46,31 39 4,1,3,3.15,0.81,13 40 4,1,4,2.75,0.92,4 41 4,2,1,4.7,7.4,23 42 4,2,2,5.36,2.97,42 43 4,2,3,4.6,3.83,20 44 4,2,4,3.8,0.7,5 45 4,3,1,5.06,4.91,114 46 4,3,2,5.59,3.23,86 47 4,3,3,4.5,3.29,30 48 4,3,4,2,0,1 49 5,1,1,5.62,4.15,21 50 5,1,2,5.06,4.64,18 51 5,1,3,3.92,4.08,12 52 5,1,4,2.6,4.3,5 53 5,2,1,5.36,7.19,22 54 5,2,2,5.88,4.44,25 55 5,2,3,5,4.33,13 56 5,2,4,5.33,0.33,3 57 5,3,1,6.46,8.2,117 58 5,3,2,6.34,5.72,68 59 5,3,3,5.74,5.2,23 60 5,3,4,2.5,0.5,2 61 6,1,1,6.6,12.4,47 62 6,1,2,6.74,11.66,27 63 6,1,3,5.38,4.27,8 64 6,1,4,2,0,1 65 6,2,1,6.52,11.45,46 66 6,2,2,7.51,10.53,45 67 6,2,3,7.54,12.6,13 68 6,3,1,7.48,11.34,195 69 6,3,2,7.81,7.57,59 70 6,3,3,5.8,7.07,10 > cebData = read.table("ceb.txt",header=TRUE,sep=",") > cebData x1 x2 x3 x4 x5 y 1 1 1 1 0.50 1.14 8 2 1 1 2 1.14 0.73 21 3 1 1 3 0.90 0.67 42 4 1 1 4 0.73 0.48 51 5 1 2 1 1.17 1.06 12 6 1 2 2 0.85 1.59 27 7 1 2 3 1.05 0.73 39 8 1 2 4 0.69 0.54 51 9 1 3 1 0.97 0.88 62 10 1 3 2 0.96 0.81 102 11 1 3 3 0.97 0.80 107 12 1 3 4 0.74 0.59 47 13 2 1 1 3.10 1.66 10 14 2 1 2 2.67 0.99 30 15 2 1 3 2.04 1.87 24 16 2 1 4 1.73 0.68 22 17 2 2 1 4.54 3.44 13 18 2 2 2 2.65 1.51 37 19 2 2 3 2.68 0.97 44 20 2 2 4 2.29 0.81 21 21 2 3 1 2.44 1.93 70 22 2 3 2 2.71 1.36 117 23 2 3 3 2.47 1.30 81 24 2 3 4 2.24 1.19 21 25 3 1 1 4.08 1.72 12 26 3 1 2 3.67 2.31 27 27 3 1 3 2.90 1.57 20 28 3 1 4 2.00 1.82 12 29 3 2 1 4.17 2.97 18 30 3 2 2 3.33 2.99 43 31 3 2 3 3.62 1.96 29 32 3 2 4 3.33 1.52 15 33 3 3 1 4.14 3.52 88 34 3 3 2 4.14 3.31 132 35 3 3 3 3.94 3.28 50 36 3 3 4 3.33 2.50 9 37 4 1 1 4.21 2.03 14 38 4 1 2 4.94 1.46 31 39 4 1 3 3.15 0.81 13 40 4 1 4 2.75 0.92 4 41 4 2 1 4.70 7.40 23 42 4 2 2 5.36 2.97 42 43 4 2 3 4.60 3.83 20 44 4 2 4 3.80 0.70 5 45 4 3 1 5.06 4.91 114 46 4 3 2 5.59 3.23 86 47 4 3 3 4.50 3.29 30 48 4 3 4 2.00 0.00 1 49 5 1 1 5.62 4.15 21 50 5 1 2 5.06 4.64 18 51 5 1 3 3.92 4.08 12 52 5 1 4 2.60 4.30 5 53 5 2 1 5.36 7.19 22 54 5 2 2 5.88 4.44 25 55 5 2 3 5.00 4.33 13 56 5 2 4 5.33 0.33 3 57 5 3 1 6.46 8.20 117 58 5 3 2 6.34 5.72 68 59 5 3 3 5.74 5.20 23 60 5 3 4 2.50 0.50 2 61 6 1 1 6.60 12.40 47 62 6 1 2 6.74 11.66 27 63 6 1 3 5.38 4.27 8 64 6 1 4 2.00 0.00 1 65 6 2 1 6.52 11.45 46 66 6 2 2 7.51 10.53 45 67 6 2 3 7.54 12.60 13 68 6 3 1 7.48 11.34 195 69 6 3 2 7.81 7.57 59 70 6 3 3 5.80 7.07 10 > cebData$ cebData$x1 cebData$x2 cebData$x3 cebData$x4 cebData$x5 cebData$y > cebData$x1 [1] 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 [39] 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 > sample(70) [1] 20 38 69 53 10 6 36 50 5 67 18 28 47 4 7 48 43 55 16 33 60 52 57 61 19 [26] 15 34 14 29 56 64 49 26 30 59 2 35 1 40 27 39 66 24 54 45 58 37 68 12 63 [51] 32 13 62 8 51 44 46 23 31 11 9 22 70 41 25 42 21 17 3 65 > data = cebData[ sample(70) , ] > data x1 x2 x3 x4 x5 y 47 4 3 3 4.50 3.29 30 45 4 3 1 5.06 4.91 114 26 3 1 2 3.67 2.31 27 41 4 2 1 4.70 7.40 23 60 5 3 4 2.50 0.50 2 16 2 1 4 1.73 0.68 22 44 4 2 4 3.80 0.70 5 29 3 2 1 4.17 2.97 18 23 2 3 3 2.47 1.30 81 66 6 2 2 7.51 10.53 45 3 1 1 3 0.90 0.67 42 4 1 1 4 0.73 0.48 51 53 5 2 1 5.36 7.19 22 69 6 3 2 7.81 7.57 59 7 1 2 3 1.05 0.73 39 13 2 1 1 3.10 1.66 10 35 3 3 3 3.94 3.28 50 31 3 2 3 3.62 1.96 29 46 4 3 2 5.59 3.23 86 8 1 2 4 0.69 0.54 51 28 3 1 4 2.00 1.82 12 50 5 1 2 5.06 4.64 18 6 1 2 2 0.85 1.59 27 68 6 3 1 7.48 11.34 195 48 4 3 4 2.00 0.00 1 42 4 2 2 5.36 2.97 42 15 2 1 3 2.04 1.87 24 20 2 2 4 2.29 0.81 21 37 4 1 1 4.21 2.03 14 33 3 3 1 4.14 3.52 88 51 5 1 3 3.92 4.08 12 5 1 2 1 1.17 1.06 12 59 5 3 3 5.74 5.20 23 2 1 1 2 1.14 0.73 21 36 3 3 4 3.33 2.50 9 64 6 1 4 2.00 0.00 1 14 2 1 2 2.67 0.99 30 9 1 3 1 0.97 0.88 62 39 4 1 3 3.15 0.81 13 55 5 2 3 5.00 4.33 13 18 2 2 2 2.65 1.51 37 34 3 3 2 4.14 3.31 132 22 2 3 2 2.71 1.36 117 67 6 2 3 7.54 12.60 13 10 1 3 2 0.96 0.81 102 63 6 1 3 5.38 4.27 8 27 3 1 3 2.90 1.57 20 12 1 3 4 0.74 0.59 47 43 4 2 3 4.60 3.83 20 30 3 2 2 3.33 2.99 43 11 1 3 3 0.97 0.80 107 24 2 3 4 2.24 1.19 21 65 6 2 1 6.52 11.45 46 70 6 3 3 5.80 7.07 10 58 5 3 2 6.34 5.72 68 1 1 1 1 0.50 1.14 8 38 4 1 2 4.94 1.46 31 52 5 1 4 2.60 4.30 5 61 6 1 1 6.60 12.40 47 62 6 1 2 6.74 11.66 27 19 2 2 3 2.68 0.97 44 40 4 1 4 2.75 0.92 4 32 3 2 4 3.33 1.52 15 49 5 1 1 5.62 4.15 21 17 2 2 1 4.54 3.44 13 57 5 3 1 6.46 8.20 117 54 5 2 2 5.88 4.44 25 25 3 1 1 4.08 1.72 12 21 2 3 1 2.44 1.93 70 56 5 2 4 5.33 0.33 3 > attach(data) The following object is masked _by_ .GlobalEnv: y > x1 [1] 4 4 3 4 5 2 4 3 2 6 1 1 5 6 1 2 3 3 4 1 3 5 1 6 4 4 2 2 4 3 5 1 5 1 3 6 2 1 [39] 4 5 2 3 2 6 1 6 3 1 4 3 1 2 6 6 5 1 4 5 6 6 2 4 3 5 2 5 5 3 2 5 > y [1] 0 1 2 3 1 4 9 18 23 31 20 25 37 45 > attach(data) The following object is masked _by_ .GlobalEnv: y The following objects are masked from data (pos = 3): x1, x2, x3, x4, x5, y > y [1] 0 1 2 3 1 4 9 18 23 31 20 25 37 45 > rm(y) > attach(data) The following objects are masked from data (pos = 3): x1, x2, x3, x4, x5, y The following objects are masked from data (pos = 4): x1, x2, x3, x4, x5, y > y [1] 30 114 27 23 2 22 5 18 81 45 42 51 22 59 39 10 50 29 86 [20] 51 12 18 27 195 1 42 24 21 14 88 12 12 23 21 9 1 30 62 [39] 13 13 37 132 117 13 102 8 20 47 20 43 107 21 46 10 68 8 31 [58] 5 47 27 44 4 15 21 13 117 25 12 70 3 > model = glm( y ~ x1 + x2 +x3 +x4 +x5, family = gaussian) > model Call: glm(formula = y ~ x1 + x2 + x3 + x4 + x5, family = gaussian) Coefficients: (Intercept) x1 x2 x3 x4 x5 23.0216 -7.3185 22.4771 -7.4485 0.7141 3.4414 Degrees of Freedom: 69 Total (i.e. Null); 64 Residual Null Deviance: 94700 Residual Deviance: 51610 AIC: 674.9 > yHat = model$fitted > yHat 1 2 3 4 5 6 7 53.368957 74.240818 19.216504 60.075710 27.572413 4.643312 14.030363 8 9 10 11 12 13 14 51.770413 59.708034 50.768305 18.783188 10.559462 52.505811 63.273119 15 16 17 18 19 20 21 41.573874 31.339549 60.253157 33.004937 61.389272 33.214476 1.440799 22 23 24 25 26 27 28 13.590498 51.839124 83.459970 32.813179 37.853185 16.408391 27.967659 29 30 31 32 33 34 35 18.768494 76.118846 3.400821 57.692163 53.508948 26.609518 49.684827 36 37 38 39 40 41 42 -26.777983 21.278303 79.406995 -1.083844 27.509446 45.530635 67.947683 43 44 45 46 47 48 49 67.534365 50.464919 71.710485 -2.221275 8.671580 55.899342 32.821617 50 51 52 53 54 55 56 43.790957 64.234739 51.716775 60.675931 52.668693 63.175377 35.011960 57 58 59 60 61 62 63 9.879696 -4.233107 41.525277 31.630149 36.245237 -8.439389 23.835177 64 65 66 67 68 69 70 19.752566 60.970554 79.244169 35.964844 24.927324 76.751630 6.531076 > y [1] 30 114 27 23 2 22 5 18 81 45 42 51 22 59 39 10 50 29 86 [20] 51 12 18 27 195 1 42 24 21 14 88 12 12 23 21 9 1 30 62 [39] 13 13 37 132 117 13 102 8 20 47 20 43 107 21 46 10 68 8 31 [58] 5 47 27 44 4 15 21 13 117 25 12 70 3 > rmse = sqrt( (y-yHat)^2/length(y)) > rmse 1 2 3 4 5 6 7 2.7931246 4.7521311 0.9303058 4.4313949 3.0564880 2.0745210 1.0793349 8 9 10 11 12 13 14 4.0363364 2.5448767 0.6894443 2.7749398 4.8335688 3.6461419 0.5107354 15 16 17 18 19 20 21 0.3076367 2.5505640 1.2254866 0.4786815 2.9415446 2.1257767 1.2620659 22 23 24 25 26 27 28 0.5270363 2.9688432 13.3315835 3.8024021 0.4956392 0.9073709 0.8327946 29 30 31 32 33 34 35 0.5699440 1.4200695 1.0277985 5.4612580 3.6465168 0.6704657 4.8627669 36 37 38 39 40 41 42 3.3201040 1.0424421 2.0805338 1.6833414 1.7342105 1.0196059 7.6557162 43 44 45 46 47 48 49 5.9122743 4.4779143 3.6202895 1.2216761 1.3540052 1.0636748 1.5324763 50 51 52 53 54 55 56 0.0945375 5.1114264 3.6713569 1.7541092 5.0998842 0.5766528 3.2285467 57 58 59 60 61 62 63 2.5243591 1.1035674 0.6543545 0.5534086 0.9268715 1.4867914 1.0560057 64 65 66 67 68 69 70 0.1490969 5.7335778 4.5126849 1.3105495 1.5451108 0.8069741 0.4220444 > das war falsch Error: unexpected symbol in "das war" > rmse = sqrt( sum( (y-yHat)^2 )/length(y) ) > rmse [1] 27.15371 >