Real.estate <- read.csv("/cloud/project/Real estate.csv")
summary(Real.estate)
##        No        X1.transaction.date  X2.house.age   
##  Min.   :  1.0   Min.   :2013        Min.   : 0.000  
##  1st Qu.:104.2   1st Qu.:2013        1st Qu.: 9.025  
##  Median :207.5   Median :2013        Median :16.100  
##  Mean   :207.5   Mean   :2013        Mean   :17.713  
##  3rd Qu.:310.8   3rd Qu.:2013        3rd Qu.:28.150  
##  Max.   :414.0   Max.   :2014        Max.   :43.800  
##  X3.distance.to.the.nearest.MRT.station X4.number.of.convenience.stores
##  Min.   :  23.38                        Min.   : 0.000                 
##  1st Qu.: 289.32                        1st Qu.: 1.000                 
##  Median : 492.23                        Median : 4.000                 
##  Mean   :1083.89                        Mean   : 4.094                 
##  3rd Qu.:1454.28                        3rd Qu.: 6.000                 
##  Max.   :6488.02                        Max.   :10.000                 
##   X5.latitude     X6.longitude   Y.house.price.of.unit.area
##  Min.   :24.93   Min.   :121.5   Min.   :  7.60            
##  1st Qu.:24.96   1st Qu.:121.5   1st Qu.: 27.70            
##  Median :24.97   Median :121.5   Median : 38.45            
##  Mean   :24.97   Mean   :121.5   Mean   : 37.98            
##  3rd Qu.:24.98   3rd Qu.:121.5   3rd Qu.: 46.60            
##  Max.   :25.01   Max.   :121.6   Max.   :117.50
summary(Real.estate)
##        No        X1.transaction.date  X2.house.age   
##  Min.   :  1.0   Min.   :2013        Min.   : 0.000  
##  1st Qu.:104.2   1st Qu.:2013        1st Qu.: 9.025  
##  Median :207.5   Median :2013        Median :16.100  
##  Mean   :207.5   Mean   :2013        Mean   :17.713  
##  3rd Qu.:310.8   3rd Qu.:2013        3rd Qu.:28.150  
##  Max.   :414.0   Max.   :2014        Max.   :43.800  
##  X3.distance.to.the.nearest.MRT.station X4.number.of.convenience.stores
##  Min.   :  23.38                        Min.   : 0.000                 
##  1st Qu.: 289.32                        1st Qu.: 1.000                 
##  Median : 492.23                        Median : 4.000                 
##  Mean   :1083.89                        Mean   : 4.094                 
##  3rd Qu.:1454.28                        3rd Qu.: 6.000                 
##  Max.   :6488.02                        Max.   :10.000                 
##   X5.latitude     X6.longitude   Y.house.price.of.unit.area
##  Min.   :24.93   Min.   :121.5   Min.   :  7.60            
##  1st Qu.:24.96   1st Qu.:121.5   1st Qu.: 27.70            
##  Median :24.97   Median :121.5   Median : 38.45            
##  Mean   :24.97   Mean   :121.5   Mean   : 37.98            
##  3rd Qu.:24.98   3rd Qu.:121.5   3rd Qu.: 46.60            
##  Max.   :25.01   Max.   :121.6   Max.   :117.50
cor(Real.estate)
##                                                 No X1.transaction.date
## No                                      1.00000000        -0.048657949
## X1.transaction.date                    -0.04865795         1.000000000
## X2.house.age                           -0.03280811         0.017548767
## X3.distance.to.the.nearest.MRT.station -0.01357349         0.060879953
## X4.number.of.convenience.stores        -0.01269895         0.009635445
## X5.latitude                            -0.01010966         0.035057756
## X6.longitude                           -0.01105928        -0.041081778
## Y.house.price.of.unit.area             -0.02858717         0.087490606
##                                        X2.house.age
## No                                      -0.03280811
## X1.transaction.date                      0.01754877
## X2.house.age                             1.00000000
## X3.distance.to.the.nearest.MRT.station   0.02562205
## X4.number.of.convenience.stores          0.04959251
## X5.latitude                              0.05441990
## X6.longitude                            -0.04852005
## Y.house.price.of.unit.area              -0.21056705
##                                        X3.distance.to.the.nearest.MRT.station
## No                                                                -0.01357349
## X1.transaction.date                                                0.06087995
## X2.house.age                                                       0.02562205
## X3.distance.to.the.nearest.MRT.station                             1.00000000
## X4.number.of.convenience.stores                                   -0.60251914
## X5.latitude                                                       -0.59106657
## X6.longitude                                                      -0.80631677
## Y.house.price.of.unit.area                                        -0.67361286
##                                        X4.number.of.convenience.stores
## No                                                        -0.012698946
## X1.transaction.date                                        0.009635445
## X2.house.age                                               0.049592513
## X3.distance.to.the.nearest.MRT.station                    -0.602519145
## X4.number.of.convenience.stores                            1.000000000
## X5.latitude                                                0.444143306
## X6.longitude                                               0.449099007
## Y.house.price.of.unit.area                                 0.571004911
##                                        X5.latitude X6.longitude
## No                                     -0.01010966  -0.01105928
## X1.transaction.date                     0.03505776  -0.04108178
## X2.house.age                            0.05441990  -0.04852005
## X3.distance.to.the.nearest.MRT.station -0.59106657  -0.80631677
## X4.number.of.convenience.stores         0.44414331   0.44909901
## X5.latitude                             1.00000000   0.41292394
## X6.longitude                            0.41292394   1.00000000
## Y.house.price.of.unit.area              0.54630665   0.52328651
##                                        Y.house.price.of.unit.area
## No                                                    -0.02858717
## X1.transaction.date                                    0.08749061
## X2.house.age                                          -0.21056705
## X3.distance.to.the.nearest.MRT.station                -0.67361286
## X4.number.of.convenience.stores                        0.57100491
## X5.latitude                                            0.54630665
## X6.longitude                                           0.52328651
## Y.house.price.of.unit.area                             1.00000000
modelo <- lm(X3.distance.to.the.nearest.MRT.station~X6.longitude, data = Real.estate)

coef(modelo)
##  (Intercept) X6.longitude 
##   8059869.41    -66309.25
"Intervalos de confianza"
## [1] "Intervalos de confianza"
confint(modelo)
##                   2.5 %     97.5 %
## (Intercept)  7487358.15 8632380.67
## X6.longitude  -71019.98  -61598.51

Supuestos del modelo lineal: 1. Los errores se distribuyen normalmente 2. La media de los errores es cero 3. Los errores independientes

plot(Real.estate$X6.longitude, Real.estate$X3.distance.to.the.nearest.MRT.station, xlab = "lONGITUDE", ylab = "MRT STATION")
abline(modelo)

residuos <- residuals(modelo)
residuos
##             1             2             3             4             5 
##  -542.8713322  -369.5612019   177.5892801   177.5892801   -90.6383189 
##             6             7             8             9            10 
##  -289.4862639  -257.5783717  -204.8767907  1193.5152205  -527.4988134 
##            11            12            13            14            15 
##  -654.8730357  -347.6496491  -325.8263881  -132.7944954   127.2967080 
##            16            17            18            19            20 
##   345.9981608   -46.9702251  -876.9973278    23.5266277  -552.6461005 
##            21            22            23            24            25 
##  -256.9377872    -5.7587510  1274.7984792    -5.7587510  -239.2223042 
##            26            27            28            29            30 
##  -663.6686233    -0.5328199  -424.9044153  -220.7941406   267.7655952 
##            31            32            33            34            35 
##   949.7986068  -266.8117071  -519.1294314  -133.6803904  -277.1659038 
##            36            37            38            39            40 
##  1987.5596981  -394.2364023  1274.7984792   413.0498841  -123.5833956 
##            41            42            43            44            45 
##  1038.6190193   997.3304134  -284.6710465    68.7135588   397.0775598 
##            46            47            48            49            50 
##   172.7226034   123.9942749  -191.9066222  1029.8897747   910.6284462 
##            51            52            53            54            55 
##  -235.8842799  1964.8261611  -697.0434042  -325.8263881  -123.5833956 
##            56            57            58            59            60 
##  -140.1569983  -233.2924163  -778.8238420   910.6284462  -680.2691334 
##            61            62            63            64            65 
##  -389.4182003   -41.8479625  -288.6392639   397.0775598   958.8206287 
##            66            67            68            69            70 
##  -301.7640523  -391.0646425  -494.4270766  -308.7444009   177.5892801 
##            71            72            73            74            75 
##  -347.6496491  -191.9066222  -276.8092153  1038.6190193  -421.9228766 
##            76            77            78            79            80 
##  1274.7984792  -181.7645143  -290.6608357  -501.6815035  1359.3356398 
##            81            82            83            84            85 
##   397.0775598  -289.7400999  -325.6303717   -37.6123741    47.2910296 
##            86            87            88            89            90 
##   -30.8392858  1408.9168418   997.3304134   -60.7952055   813.0422600 
##            91            92            93            94            95 
##  -993.6199753   -63.8830206  -132.7944954  -110.0328035  -458.8250674 
##            96            97            98            99           100 
##  -494.4270766  -347.6496491  -491.0497852  -123.5833956  -347.6496491 
##           101           102           103           104           105 
##   -69.4762298 -1147.2374098  -391.0646425  -538.7162950   -85.4453566 
##           106           107           108           109           110 
##   -46.9702251  -249.9137940  1274.7984792  -342.2613609  -297.2474902 
##           111           112           113           114           115 
##  -494.4270766  -298.5144605  -224.1660325  -375.0651537  -405.6669422 
##           116           117           118           119           120 
##   584.2770559  1696.4820566  1155.2792042  -579.0871951  -123.5833956 
##           121           122           123           124           125 
##  -325.8263881  -325.8263881    78.9581296 -1008.6015124    -5.7587510 
##           126           127           128           129           130 
##  -391.0646425  -185.7720275    -0.5328199  -492.8125655  -319.4104930 
##           131           132           133           134           135 
##  -338.2304547  -297.2474902  -251.7499383  -215.8970897  -316.7832625 
##           136           137           138           139           140 
##   996.1715572   -90.6383189  -140.9169602  -758.1673511  -325.8263881 
##           141           142           143           144           145 
##  -123.5833956  -657.3557767   425.9635496  -325.8263881  1274.7984792 
##           146           147           148           149           150 
##   267.7655952 -1008.6015124   173.7854034  1282.2560206  -301.7529189 
##           151           152           153           154           155 
##  -294.5613999  -396.4678727  1274.7984792  -457.8010071   997.3304134 
##           156           157           158           159           160 
##  1038.6190193   -72.5290835  -183.1505294   -90.6383189  -183.1505294 
##           161           162           163           164           165 
##  -755.7978814  -181.7645143   997.3304134  -494.4270766 -1008.6015124 
##           166           167           168           169           170 
##  1515.2612392   -46.9702251  -306.2849543    83.6374155  2301.0035605 
##           171           172           173           174           175 
##   984.9823976    -0.5328199  -347.6496491    63.2388598  -358.8323973 
##           176           177           178           179           180 
##  -331.9582465   950.8402101  -288.8575471   140.0493309 -1046.9404944 
##           181           182           183           184           185 
##   901.9237504  -361.5362838  -297.2474902  1038.6190193  3413.3636346 
##           186           187           188           189           190 
##  -701.5982534  -290.6608357  4176.4555186  -246.7403241   997.3304134 
##           191           192           193           194           195 
##  -264.4779717   737.0069572  -540.3215417    94.1097316  1243.7218600 
##           196           197           198           199           200 
##  -189.1936960   537.0272519  -457.9205425  -356.0930494   132.8928336 
##           201           202           203           204           205 
##   958.8206287   177.5892801  -191.2734071  -123.5833956  1359.3356398 
##           206           207           208           209           210 
##  -700.4884383  -421.9228766  -182.8332488  1274.7984792  -288.3369150 
##           211           212           213           214           215 
##   -90.6383189  -993.6199753  -103.8428757  -347.6496491  -527.4988134 
##           216           217           218           219           220 
##    56.3436316  -345.1589458  -192.1321687  -325.8263881  -342.6541697 
##           221           222           223           224           225 
##  -281.4347697   -63.8830206  -382.9677333   -63.8830206  -205.9967533 
##           226           227           228           229           230 
##  -391.0646425  1038.6190193  -387.8867658  1052.9469997   -87.3510468 
##           231           232           233           234           235 
##  -297.2474902  1015.4258003   842.8736068  -355.3867586  -176.9533708 
##           236           237           238           239           240 
##  -196.0949110  -425.6521992  -893.5145957  -893.5145957   702.6508447 
##           241           242           243           244           245 
##  -476.0378010  -196.0949110  -337.3943295  -490.5519907  -657.3557767 
##           246           247           248           249           250 
##   535.7126903   -72.8182300  1026.7524306   996.1715572  1362.9971241 
##           251           252           253           254           255 
##  -273.9878455  -135.3671662  -347.6496491  -484.2401465   -51.7681500 
##           256           257           258           259           260 
##  1193.5152205  -867.4009691 -1041.6583944   -46.9702251   702.6508447 
##           261           262           263           264           265 
##  -683.6800272  -106.8805557  -123.5833956  -297.2474902   196.1268923 
##           266           267           268           269           270 
##  -183.1505294  -527.4988134  -251.7499383   -90.6383189   702.6508447 
##           271           272           273           274           275 
## -1023.6723773   132.8928336  -325.8263881 -1147.2374098  -253.6256261 
##           276           277           278           279           280 
##  -552.6461005  -189.1936960  -290.6608357  -538.7162950  -652.9863898 
##           281           282           283           284           285 
##  -402.3082199  -396.4678727  1408.9168418   -94.6207131    47.2910296 
##           286           287           288           289           290 
##  -161.4315868  -347.6496491  -189.1936960  -134.3072828  -123.5833956 
##           291           292           293           294           295 
##  -504.0956822  -778.8238420  -645.8451468    47.2910296  -215.3041271 
##           296           297           298           299           300 
##  -286.2524489   140.0493309   307.9641549  1038.6190193  -482.8157163 
##           301           302           303           304           305 
##  -492.7249110  -549.8958861  -106.8805557  -586.5582202  -563.9129859 
##           306           307           308           309           310 
##  -123.5833956 -1150.7014721  4178.1695186  -123.5833956   -72.5290835 
##           311           312           313           314           315 
##  1778.3051756  -229.2024688  -279.3817917  -494.4270766   413.0498841 
##           316           317           318           319           320 
##  -338.0996718  -196.0949110  -254.9352314  -421.9228766  -455.8619061 
##           321           322           323           324           325 
##  1155.2792042   -69.4762298 -1131.8732871  -157.4222592  -476.0378010 
##           326           327           328           329           330 
##   172.7226034  -778.8238420   757.5361064  -673.7163970  1155.2792042 
##           331           332           333           334           335 
##  -119.4775773   949.7986068  -374.0745124  -494.4270766    11.6067007 
##           336           337           338           339           340 
##  -264.2879464  -269.7155892   388.8692195  -165.9947674   -51.7681500 
##           341           342           343           344           345 
##  -860.1478288   737.0069572  -347.6496491  -347.6052324   816.9291039 
##           346           347           348           349           350 
## -1008.6015124  -476.0378010  1436.7810533   -41.8479625  -494.4270766 
##           351           352           353           354           355 
##  -325.8263881  -292.8914659   -72.6957440  -297.2474902  1274.7984792 
##           356           357           358           359           360 
##    -0.5328199 -1095.9726229   -30.8392858  -391.0646425  3067.6422182 
##           361           362           363           364           365 
##  -541.7741173  -300.7917727   -68.8151071  -476.6929199  -250.9978527 
##           366           367           368           369           370 
##  -224.3032226  1989.3975723  -452.5206528  -876.9973278  -290.6608357 
##           371           372           373           374           375 
##  -123.5833956  -359.9441396  -356.0930494  -993.6199753   -90.6383189 
##           376           377           378           379           380 
##  1184.7101047  -485.4017426  -755.7978814   364.6239477   -46.9702251 
##           381           382           383           384           385 
##  -123.5833956  -523.7162281  1292.4884495  -211.1532343   997.3304134 
##           386           387           388           389           390 
##  -543.5375374 -1008.6015124  -223.0380325  -146.9321105  -368.7912058 
##           391           392           393           394           395 
##   -33.7518107  2215.7938693  -283.4120212   -68.8151071   594.8925826 
##           396           397           398           399           400 
##  -235.8842799   979.8386126   127.2967080  -485.4017426 -1147.2374098 
##           401           402           403           404           405 
##  -251.7499383  -289.4862639 -1131.8732871  -504.2675150  -123.5833956 
##           406           407           408           409           410 
##  -668.4965992  -254.2853674  3067.6422182  -296.0662810  1038.6190193 
##           411           412           413           414 
##  -347.6496491  -261.9780658  -494.4270766  -347.6496491
#normalidad de los residuos:

hist(residuos, breaks = 15, col = "#B0E2FF")

shapiro.test(residuos)
## 
##  Shapiro-Wilk normality test
## 
## data:  residuos
## W = 0.81685, p-value < 2.2e-16

Como tiene un valor p muy menor a cero, se rechaza la hipotesis nula

#Media cero
plot(residuos, col="#B0E2FF")
abline(h=0)

t.test(residuos, mu=0)
## 
##  One Sample t-test
## 
## data:  residuos
## t = 2.2303e-16, df = 413, p-value = 1
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  -72.12113  72.12113
## sample estimates:
##  mean of x 
## 8.1828e-15

De acuerdo al gráfico y los resultados de la prueba, se evidencia que la media estadísticamente es casi 0.

#Supuesto de independencia 
residuos[2:length(residuos)]
##             2             3             4             5             6 
##  -369.5612019   177.5892801   177.5892801   -90.6383189  -289.4862639 
##             7             8             9            10            11 
##  -257.5783717  -204.8767907  1193.5152205  -527.4988134  -654.8730357 
##            12            13            14            15            16 
##  -347.6496491  -325.8263881  -132.7944954   127.2967080   345.9981608 
##            17            18            19            20            21 
##   -46.9702251  -876.9973278    23.5266277  -552.6461005  -256.9377872 
##            22            23            24            25            26 
##    -5.7587510  1274.7984792    -5.7587510  -239.2223042  -663.6686233 
##            27            28            29            30            31 
##    -0.5328199  -424.9044153  -220.7941406   267.7655952   949.7986068 
##            32            33            34            35            36 
##  -266.8117071  -519.1294314  -133.6803904  -277.1659038  1987.5596981 
##            37            38            39            40            41 
##  -394.2364023  1274.7984792   413.0498841  -123.5833956  1038.6190193 
##            42            43            44            45            46 
##   997.3304134  -284.6710465    68.7135588   397.0775598   172.7226034 
##            47            48            49            50            51 
##   123.9942749  -191.9066222  1029.8897747   910.6284462  -235.8842799 
##            52            53            54            55            56 
##  1964.8261611  -697.0434042  -325.8263881  -123.5833956  -140.1569983 
##            57            58            59            60            61 
##  -233.2924163  -778.8238420   910.6284462  -680.2691334  -389.4182003 
##            62            63            64            65            66 
##   -41.8479625  -288.6392639   397.0775598   958.8206287  -301.7640523 
##            67            68            69            70            71 
##  -391.0646425  -494.4270766  -308.7444009   177.5892801  -347.6496491 
##            72            73            74            75            76 
##  -191.9066222  -276.8092153  1038.6190193  -421.9228766  1274.7984792 
##            77            78            79            80            81 
##  -181.7645143  -290.6608357  -501.6815035  1359.3356398   397.0775598 
##            82            83            84            85            86 
##  -289.7400999  -325.6303717   -37.6123741    47.2910296   -30.8392858 
##            87            88            89            90            91 
##  1408.9168418   997.3304134   -60.7952055   813.0422600  -993.6199753 
##            92            93            94            95            96 
##   -63.8830206  -132.7944954  -110.0328035  -458.8250674  -494.4270766 
##            97            98            99           100           101 
##  -347.6496491  -491.0497852  -123.5833956  -347.6496491   -69.4762298 
##           102           103           104           105           106 
## -1147.2374098  -391.0646425  -538.7162950   -85.4453566   -46.9702251 
##           107           108           109           110           111 
##  -249.9137940  1274.7984792  -342.2613609  -297.2474902  -494.4270766 
##           112           113           114           115           116 
##  -298.5144605  -224.1660325  -375.0651537  -405.6669422   584.2770559 
##           117           118           119           120           121 
##  1696.4820566  1155.2792042  -579.0871951  -123.5833956  -325.8263881 
##           122           123           124           125           126 
##  -325.8263881    78.9581296 -1008.6015124    -5.7587510  -391.0646425 
##           127           128           129           130           131 
##  -185.7720275    -0.5328199  -492.8125655  -319.4104930  -338.2304547 
##           132           133           134           135           136 
##  -297.2474902  -251.7499383  -215.8970897  -316.7832625   996.1715572 
##           137           138           139           140           141 
##   -90.6383189  -140.9169602  -758.1673511  -325.8263881  -123.5833956 
##           142           143           144           145           146 
##  -657.3557767   425.9635496  -325.8263881  1274.7984792   267.7655952 
##           147           148           149           150           151 
## -1008.6015124   173.7854034  1282.2560206  -301.7529189  -294.5613999 
##           152           153           154           155           156 
##  -396.4678727  1274.7984792  -457.8010071   997.3304134  1038.6190193 
##           157           158           159           160           161 
##   -72.5290835  -183.1505294   -90.6383189  -183.1505294  -755.7978814 
##           162           163           164           165           166 
##  -181.7645143   997.3304134  -494.4270766 -1008.6015124  1515.2612392 
##           167           168           169           170           171 
##   -46.9702251  -306.2849543    83.6374155  2301.0035605   984.9823976 
##           172           173           174           175           176 
##    -0.5328199  -347.6496491    63.2388598  -358.8323973  -331.9582465 
##           177           178           179           180           181 
##   950.8402101  -288.8575471   140.0493309 -1046.9404944   901.9237504 
##           182           183           184           185           186 
##  -361.5362838  -297.2474902  1038.6190193  3413.3636346  -701.5982534 
##           187           188           189           190           191 
##  -290.6608357  4176.4555186  -246.7403241   997.3304134  -264.4779717 
##           192           193           194           195           196 
##   737.0069572  -540.3215417    94.1097316  1243.7218600  -189.1936960 
##           197           198           199           200           201 
##   537.0272519  -457.9205425  -356.0930494   132.8928336   958.8206287 
##           202           203           204           205           206 
##   177.5892801  -191.2734071  -123.5833956  1359.3356398  -700.4884383 
##           207           208           209           210           211 
##  -421.9228766  -182.8332488  1274.7984792  -288.3369150   -90.6383189 
##           212           213           214           215           216 
##  -993.6199753  -103.8428757  -347.6496491  -527.4988134    56.3436316 
##           217           218           219           220           221 
##  -345.1589458  -192.1321687  -325.8263881  -342.6541697  -281.4347697 
##           222           223           224           225           226 
##   -63.8830206  -382.9677333   -63.8830206  -205.9967533  -391.0646425 
##           227           228           229           230           231 
##  1038.6190193  -387.8867658  1052.9469997   -87.3510468  -297.2474902 
##           232           233           234           235           236 
##  1015.4258003   842.8736068  -355.3867586  -176.9533708  -196.0949110 
##           237           238           239           240           241 
##  -425.6521992  -893.5145957  -893.5145957   702.6508447  -476.0378010 
##           242           243           244           245           246 
##  -196.0949110  -337.3943295  -490.5519907  -657.3557767   535.7126903 
##           247           248           249           250           251 
##   -72.8182300  1026.7524306   996.1715572  1362.9971241  -273.9878455 
##           252           253           254           255           256 
##  -135.3671662  -347.6496491  -484.2401465   -51.7681500  1193.5152205 
##           257           258           259           260           261 
##  -867.4009691 -1041.6583944   -46.9702251   702.6508447  -683.6800272 
##           262           263           264           265           266 
##  -106.8805557  -123.5833956  -297.2474902   196.1268923  -183.1505294 
##           267           268           269           270           271 
##  -527.4988134  -251.7499383   -90.6383189   702.6508447 -1023.6723773 
##           272           273           274           275           276 
##   132.8928336  -325.8263881 -1147.2374098  -253.6256261  -552.6461005 
##           277           278           279           280           281 
##  -189.1936960  -290.6608357  -538.7162950  -652.9863898  -402.3082199 
##           282           283           284           285           286 
##  -396.4678727  1408.9168418   -94.6207131    47.2910296  -161.4315868 
##           287           288           289           290           291 
##  -347.6496491  -189.1936960  -134.3072828  -123.5833956  -504.0956822 
##           292           293           294           295           296 
##  -778.8238420  -645.8451468    47.2910296  -215.3041271  -286.2524489 
##           297           298           299           300           301 
##   140.0493309   307.9641549  1038.6190193  -482.8157163  -492.7249110 
##           302           303           304           305           306 
##  -549.8958861  -106.8805557  -586.5582202  -563.9129859  -123.5833956 
##           307           308           309           310           311 
## -1150.7014721  4178.1695186  -123.5833956   -72.5290835  1778.3051756 
##           312           313           314           315           316 
##  -229.2024688  -279.3817917  -494.4270766   413.0498841  -338.0996718 
##           317           318           319           320           321 
##  -196.0949110  -254.9352314  -421.9228766  -455.8619061  1155.2792042 
##           322           323           324           325           326 
##   -69.4762298 -1131.8732871  -157.4222592  -476.0378010   172.7226034 
##           327           328           329           330           331 
##  -778.8238420   757.5361064  -673.7163970  1155.2792042  -119.4775773 
##           332           333           334           335           336 
##   949.7986068  -374.0745124  -494.4270766    11.6067007  -264.2879464 
##           337           338           339           340           341 
##  -269.7155892   388.8692195  -165.9947674   -51.7681500  -860.1478288 
##           342           343           344           345           346 
##   737.0069572  -347.6496491  -347.6052324   816.9291039 -1008.6015124 
##           347           348           349           350           351 
##  -476.0378010  1436.7810533   -41.8479625  -494.4270766  -325.8263881 
##           352           353           354           355           356 
##  -292.8914659   -72.6957440  -297.2474902  1274.7984792    -0.5328199 
##           357           358           359           360           361 
## -1095.9726229   -30.8392858  -391.0646425  3067.6422182  -541.7741173 
##           362           363           364           365           366 
##  -300.7917727   -68.8151071  -476.6929199  -250.9978527  -224.3032226 
##           367           368           369           370           371 
##  1989.3975723  -452.5206528  -876.9973278  -290.6608357  -123.5833956 
##           372           373           374           375           376 
##  -359.9441396  -356.0930494  -993.6199753   -90.6383189  1184.7101047 
##           377           378           379           380           381 
##  -485.4017426  -755.7978814   364.6239477   -46.9702251  -123.5833956 
##           382           383           384           385           386 
##  -523.7162281  1292.4884495  -211.1532343   997.3304134  -543.5375374 
##           387           388           389           390           391 
## -1008.6015124  -223.0380325  -146.9321105  -368.7912058   -33.7518107 
##           392           393           394           395           396 
##  2215.7938693  -283.4120212   -68.8151071   594.8925826  -235.8842799 
##           397           398           399           400           401 
##   979.8386126   127.2967080  -485.4017426 -1147.2374098  -251.7499383 
##           402           403           404           405           406 
##  -289.4862639 -1131.8732871  -504.2675150  -123.5833956  -668.4965992 
##           407           408           409           410           411 
##  -254.2853674  3067.6422182  -296.0662810  1038.6190193  -347.6496491 
##           412           413           414 
##  -261.9780658  -494.4270766  -347.6496491
residuos[1:length(residuos)-1]
##             1             2             3             4             5 
##  -542.8713322  -369.5612019   177.5892801   177.5892801   -90.6383189 
##             6             7             8             9            10 
##  -289.4862639  -257.5783717  -204.8767907  1193.5152205  -527.4988134 
##            11            12            13            14            15 
##  -654.8730357  -347.6496491  -325.8263881  -132.7944954   127.2967080 
##            16            17            18            19            20 
##   345.9981608   -46.9702251  -876.9973278    23.5266277  -552.6461005 
##            21            22            23            24            25 
##  -256.9377872    -5.7587510  1274.7984792    -5.7587510  -239.2223042 
##            26            27            28            29            30 
##  -663.6686233    -0.5328199  -424.9044153  -220.7941406   267.7655952 
##            31            32            33            34            35 
##   949.7986068  -266.8117071  -519.1294314  -133.6803904  -277.1659038 
##            36            37            38            39            40 
##  1987.5596981  -394.2364023  1274.7984792   413.0498841  -123.5833956 
##            41            42            43            44            45 
##  1038.6190193   997.3304134  -284.6710465    68.7135588   397.0775598 
##            46            47            48            49            50 
##   172.7226034   123.9942749  -191.9066222  1029.8897747   910.6284462 
##            51            52            53            54            55 
##  -235.8842799  1964.8261611  -697.0434042  -325.8263881  -123.5833956 
##            56            57            58            59            60 
##  -140.1569983  -233.2924163  -778.8238420   910.6284462  -680.2691334 
##            61            62            63            64            65 
##  -389.4182003   -41.8479625  -288.6392639   397.0775598   958.8206287 
##            66            67            68            69            70 
##  -301.7640523  -391.0646425  -494.4270766  -308.7444009   177.5892801 
##            71            72            73            74            75 
##  -347.6496491  -191.9066222  -276.8092153  1038.6190193  -421.9228766 
##            76            77            78            79            80 
##  1274.7984792  -181.7645143  -290.6608357  -501.6815035  1359.3356398 
##            81            82            83            84            85 
##   397.0775598  -289.7400999  -325.6303717   -37.6123741    47.2910296 
##            86            87            88            89            90 
##   -30.8392858  1408.9168418   997.3304134   -60.7952055   813.0422600 
##            91            92            93            94            95 
##  -993.6199753   -63.8830206  -132.7944954  -110.0328035  -458.8250674 
##            96            97            98            99           100 
##  -494.4270766  -347.6496491  -491.0497852  -123.5833956  -347.6496491 
##           101           102           103           104           105 
##   -69.4762298 -1147.2374098  -391.0646425  -538.7162950   -85.4453566 
##           106           107           108           109           110 
##   -46.9702251  -249.9137940  1274.7984792  -342.2613609  -297.2474902 
##           111           112           113           114           115 
##  -494.4270766  -298.5144605  -224.1660325  -375.0651537  -405.6669422 
##           116           117           118           119           120 
##   584.2770559  1696.4820566  1155.2792042  -579.0871951  -123.5833956 
##           121           122           123           124           125 
##  -325.8263881  -325.8263881    78.9581296 -1008.6015124    -5.7587510 
##           126           127           128           129           130 
##  -391.0646425  -185.7720275    -0.5328199  -492.8125655  -319.4104930 
##           131           132           133           134           135 
##  -338.2304547  -297.2474902  -251.7499383  -215.8970897  -316.7832625 
##           136           137           138           139           140 
##   996.1715572   -90.6383189  -140.9169602  -758.1673511  -325.8263881 
##           141           142           143           144           145 
##  -123.5833956  -657.3557767   425.9635496  -325.8263881  1274.7984792 
##           146           147           148           149           150 
##   267.7655952 -1008.6015124   173.7854034  1282.2560206  -301.7529189 
##           151           152           153           154           155 
##  -294.5613999  -396.4678727  1274.7984792  -457.8010071   997.3304134 
##           156           157           158           159           160 
##  1038.6190193   -72.5290835  -183.1505294   -90.6383189  -183.1505294 
##           161           162           163           164           165 
##  -755.7978814  -181.7645143   997.3304134  -494.4270766 -1008.6015124 
##           166           167           168           169           170 
##  1515.2612392   -46.9702251  -306.2849543    83.6374155  2301.0035605 
##           171           172           173           174           175 
##   984.9823976    -0.5328199  -347.6496491    63.2388598  -358.8323973 
##           176           177           178           179           180 
##  -331.9582465   950.8402101  -288.8575471   140.0493309 -1046.9404944 
##           181           182           183           184           185 
##   901.9237504  -361.5362838  -297.2474902  1038.6190193  3413.3636346 
##           186           187           188           189           190 
##  -701.5982534  -290.6608357  4176.4555186  -246.7403241   997.3304134 
##           191           192           193           194           195 
##  -264.4779717   737.0069572  -540.3215417    94.1097316  1243.7218600 
##           196           197           198           199           200 
##  -189.1936960   537.0272519  -457.9205425  -356.0930494   132.8928336 
##           201           202           203           204           205 
##   958.8206287   177.5892801  -191.2734071  -123.5833956  1359.3356398 
##           206           207           208           209           210 
##  -700.4884383  -421.9228766  -182.8332488  1274.7984792  -288.3369150 
##           211           212           213           214           215 
##   -90.6383189  -993.6199753  -103.8428757  -347.6496491  -527.4988134 
##           216           217           218           219           220 
##    56.3436316  -345.1589458  -192.1321687  -325.8263881  -342.6541697 
##           221           222           223           224           225 
##  -281.4347697   -63.8830206  -382.9677333   -63.8830206  -205.9967533 
##           226           227           228           229           230 
##  -391.0646425  1038.6190193  -387.8867658  1052.9469997   -87.3510468 
##           231           232           233           234           235 
##  -297.2474902  1015.4258003   842.8736068  -355.3867586  -176.9533708 
##           236           237           238           239           240 
##  -196.0949110  -425.6521992  -893.5145957  -893.5145957   702.6508447 
##           241           242           243           244           245 
##  -476.0378010  -196.0949110  -337.3943295  -490.5519907  -657.3557767 
##           246           247           248           249           250 
##   535.7126903   -72.8182300  1026.7524306   996.1715572  1362.9971241 
##           251           252           253           254           255 
##  -273.9878455  -135.3671662  -347.6496491  -484.2401465   -51.7681500 
##           256           257           258           259           260 
##  1193.5152205  -867.4009691 -1041.6583944   -46.9702251   702.6508447 
##           261           262           263           264           265 
##  -683.6800272  -106.8805557  -123.5833956  -297.2474902   196.1268923 
##           266           267           268           269           270 
##  -183.1505294  -527.4988134  -251.7499383   -90.6383189   702.6508447 
##           271           272           273           274           275 
## -1023.6723773   132.8928336  -325.8263881 -1147.2374098  -253.6256261 
##           276           277           278           279           280 
##  -552.6461005  -189.1936960  -290.6608357  -538.7162950  -652.9863898 
##           281           282           283           284           285 
##  -402.3082199  -396.4678727  1408.9168418   -94.6207131    47.2910296 
##           286           287           288           289           290 
##  -161.4315868  -347.6496491  -189.1936960  -134.3072828  -123.5833956 
##           291           292           293           294           295 
##  -504.0956822  -778.8238420  -645.8451468    47.2910296  -215.3041271 
##           296           297           298           299           300 
##  -286.2524489   140.0493309   307.9641549  1038.6190193  -482.8157163 
##           301           302           303           304           305 
##  -492.7249110  -549.8958861  -106.8805557  -586.5582202  -563.9129859 
##           306           307           308           309           310 
##  -123.5833956 -1150.7014721  4178.1695186  -123.5833956   -72.5290835 
##           311           312           313           314           315 
##  1778.3051756  -229.2024688  -279.3817917  -494.4270766   413.0498841 
##           316           317           318           319           320 
##  -338.0996718  -196.0949110  -254.9352314  -421.9228766  -455.8619061 
##           321           322           323           324           325 
##  1155.2792042   -69.4762298 -1131.8732871  -157.4222592  -476.0378010 
##           326           327           328           329           330 
##   172.7226034  -778.8238420   757.5361064  -673.7163970  1155.2792042 
##           331           332           333           334           335 
##  -119.4775773   949.7986068  -374.0745124  -494.4270766    11.6067007 
##           336           337           338           339           340 
##  -264.2879464  -269.7155892   388.8692195  -165.9947674   -51.7681500 
##           341           342           343           344           345 
##  -860.1478288   737.0069572  -347.6496491  -347.6052324   816.9291039 
##           346           347           348           349           350 
## -1008.6015124  -476.0378010  1436.7810533   -41.8479625  -494.4270766 
##           351           352           353           354           355 
##  -325.8263881  -292.8914659   -72.6957440  -297.2474902  1274.7984792 
##           356           357           358           359           360 
##    -0.5328199 -1095.9726229   -30.8392858  -391.0646425  3067.6422182 
##           361           362           363           364           365 
##  -541.7741173  -300.7917727   -68.8151071  -476.6929199  -250.9978527 
##           366           367           368           369           370 
##  -224.3032226  1989.3975723  -452.5206528  -876.9973278  -290.6608357 
##           371           372           373           374           375 
##  -123.5833956  -359.9441396  -356.0930494  -993.6199753   -90.6383189 
##           376           377           378           379           380 
##  1184.7101047  -485.4017426  -755.7978814   364.6239477   -46.9702251 
##           381           382           383           384           385 
##  -123.5833956  -523.7162281  1292.4884495  -211.1532343   997.3304134 
##           386           387           388           389           390 
##  -543.5375374 -1008.6015124  -223.0380325  -146.9321105  -368.7912058 
##           391           392           393           394           395 
##   -33.7518107  2215.7938693  -283.4120212   -68.8151071   594.8925826 
##           396           397           398           399           400 
##  -235.8842799   979.8386126   127.2967080  -485.4017426 -1147.2374098 
##           401           402           403           404           405 
##  -251.7499383  -289.4862639 -1131.8732871  -504.2675150  -123.5833956 
##           406           407           408           409           410 
##  -668.4965992  -254.2853674  3067.6422182  -296.0662810  1038.6190193 
##           411           412           413 
##  -347.6496491  -261.9780658  -494.4270766
plot(residuos[1:length(residuos)-1],residuos[2:length(residuos)], xlab = "Residuos resagados", ylab = "Residuos")

#prueba de durbin

#install.packages("lmtest")
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric

dwtest(modelo, alternative = "two.sided")
## 
##  Durbin-Watson test
## 
## data:  modelo
## DW = 2.1249, p-value = 0.2027
## alternative hypothesis: true autocorrelation is not 0

``` En este caso, de acuerdo al valor-p se deduce que los erros si son independientes,es decir, no se rechaza la hipotesis nula.

#varianza Homogenea
plot(residuos, col="#B0E2FF")
abline(h=0)

bptest(modelo)
## 
##  studentized Breusch-Pagan test
## 
## data:  modelo
## BP = 6.3039, df = 1, p-value = 0.01205

Segun los resultados no hay homogeneas

En conclusion, no todos los supuestos se cumplieron, por ende, no seria factible modelarlo con modelo lineal simple