setwd("C:/MCF202/Data/")
bosque<- read.csv("bosque.csv")
plot(bosque$diametro, bosque$altura)

plot of chunk unnamed-chunk-2

plot(bosque$diametro, bosque$altura)
bosque.reg <- lm(bosque$altura ~bosque$diametro)
abline(bosque.reg)

plot of chunk unnamed-chunk-3

bosque.reg
## 
## Call:
## lm(formula = bosque$altura ~ bosque$diametro)
## 
## Coefficients:
##     (Intercept)  bosque$diametro  
##           3.038            0.341
summary(bosque.reg)
## 
## Call:
## lm(formula = bosque$altura ~ bosque$diametro)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.261 -2.048 -0.168  1.842  6.982 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       3.0380     0.5236     5.8  3.3e-08 ***
## bosque$diametro   0.3407     0.0186    18.4  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.62 on 162 degrees of freedom
## Multiple R-squared:  0.675,  Adjusted R-squared:  0.673 
## F-statistic:  337 on 1 and 162 DF,  p-value: <2e-16
cor.test(bosque$altura, bosque$diametro)
## 
##  Pearson's product-moment correlation
## 
## data:  bosque$altura and bosque$diametro
## t = 18.35, df = 162, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.7648 0.8659
## sample estimates:
##    cor 
## 0.8217
fitted(bosque.reg)
##      1      2      3      4      5      6      7      8      9     10 
## 13.668 15.031  8.319 13.463 14.247  8.898 13.974  6.581 18.983 12.032 
##     11     12     13     14     15     16     17     18     19     20 
## 13.872 13.361  9.034  6.956  6.888 15.303  8.353 14.554 18.369  6.786 
##     21     22     23     24     25     26     27     28     29     30 
## 13.838 15.712  6.445  7.740  7.467  7.160  7.808  9.613 13.361 13.157 
##     31     32     33     34     35     36     37     38     39     40 
##  8.114  7.126 14.962 12.850  6.445  7.297  9.307 12.578 10.874 15.985 
##     41     42     43     44     45     46     47     48     49     50 
##  7.603  9.750  7.910 18.642  8.660  8.251  7.535  9.613 10.533  8.932 
##     51     52     53     54     55     56     57     58     59     60 
## 13.600  7.603  6.718  6.445  7.944  9.750  8.046 11.317 12.475 14.520 
##     61     62     63     64     65     66     67     68     69     70 
## 13.668 13.736 10.431 12.067 13.327  6.786  7.876 12.135  9.477 10.022 
##     71     72     73     74     75     76     77     78     79     80 
## 13.566 14.690 11.828 10.942  8.898  9.682  6.786  8.421  7.876 14.554 
##     81     82     83     84     85     86     87     88     89     90 
## 13.259 12.918 10.976 17.143 13.361  8.694 13.872 15.985  8.591 13.089 
##     91     92     93     94     95     96     97     98     99    100 
## 15.916 13.497  8.148 10.227  6.820 10.567 11.147  7.535  7.467 10.874 
##    101    102    103    104    105    106    107    108    109    110 
## 13.259 12.578  7.978  8.148 11.896  6.445  7.603  8.830  6.786 11.283 
##    111    112    113    114    115    116    117    118    119    120 
##  9.341  9.920 11.317 16.973  7.297 10.976  7.126 15.678 14.792 10.533 
##    121    122    123    124    125    126    127    128    129    130 
##  8.489 12.578 15.678 20.243 17.211 14.554 12.918 15.303 19.630 19.255 
##    131    132    133    134    135    136    137    138    139    140 
##  9.784 15.542 15.303 17.961  8.762 20.414 16.325 16.836 12.067 13.804 
##    141    142    143    144    145    146    147    148    149    150 
## 17.211 14.724 19.392 14.213 19.800 14.826 17.007 16.325 14.690 18.199 
##    151    152    153    154    155    156    157    158    159    160 
##  9.852  8.319 18.301  9.920 17.007 18.710  8.319  7.195 15.610  9.818 
##    161    162    163    164 
## 16.768 12.373 15.235 14.758
resid(bosque.reg)
##         1         2         3         4         5         6         7 
##  0.132190 -3.730611 -4.318815 -0.163390  3.552999 -1.098006  4.325560 
##         8         9        10        11        12        13        14 
##  1.418756  0.517265 -5.032449 -3.672230  3.038820 -0.934286  0.643986 
##        15        16        17        18        19        20        21 
## -0.487874 -1.303172 -1.552885 -1.853631 -0.369474  0.614336  1.161840 
##        22        23        24        25        26        27        28 
## -1.612012 -0.444964  3.960375 -0.267065 -0.160434 -4.807765 -0.413477 
##        29        30        31        32        33        34        35 
## -5.261180 -2.356760 -2.914395  0.773636  0.737529  2.849871 -3.244964 
##        36        37        38        39        40        41        42 
## -3.596714 -3.906846  3.422431  1.425932 -2.384572  1.896655  4.650243 
##        43        44        45        46        47        48        49 
##  0.190025 -1.442035  1.140484  2.449325  2.064795  6.886523 -2.933367 
##        50        51        52        53        54        55        56 
## -1.232076 -0.799670  1.396655 -2.017524 -1.744964 -0.744045 -2.349757 
##        57        58        59        60        61        62        63 
## -1.046255 -0.816978  2.424641  2.080439 -0.067810 -0.335950 -0.231157 
##        64        65        66        67        68        69        70 
##  1.633481  2.872890  3.614336 -2.375905 -0.334659  2.422804 -2.522317 
##        71        72        73        74        75        76        77 
## -0.865600  0.910089 -2.228028 -3.842208 -2.298006 -4.581617 -2.885664 
##        78        79        80        81        82        83        84 
## -5.221025 -0.675905  3.846369 -1.058970  6.981731  1.823722 -2.542953 
##        85        86        87        88        89        90        91 
## -2.561180  1.706414 -1.172230  0.815428  0.008624  0.411380 -2.616432 
##        92        93        94        95        96        97        98 
##  0.402540 -2.148465  1.773263  2.180266 -4.367437  5.453372  3.364795 
##        99       100       101       102       103       104       105 
##  4.132935  4.825932 -1.258970 -0.177569  1.021885  1.251535 -3.496169 
##       106       107       108       109       110       111       112 
##  0.355036  0.396655 -1.229866  2.014336 -0.482908 -2.140916  0.879893 
##       113       114       115       116       117       118       119 
## -0.716978 -3.372603  1.903286  3.123722  0.873636 -2.677942 -1.692121 
##       120       121       122       123       124       125       126 
## -2.233367  2.010834  0.922431  2.322058 -3.443326 -0.311093  0.046369 
##       127       128       129       130       131       132       133 
##  0.581731 -1.903172  1.569935 -2.655295  6.116173  5.258338  0.596828 
##       134       135       136       137       138       139       140 
##  2.139366  0.438274 -1.413676 -3.325272  1.663677  1.733481  3.595910 
##       141       142       143       144       145       146       147 
##  1.188907  3.176019 -1.291575 -3.112931 -2.200416  2.673809  2.693327 
##       148       149       150       151       152       153       154 
##  0.674728  2.110089  2.100876  2.448033 -4.918815 -0.901334 -0.920107 
##       155       156       157       158       159       160       161 
##  4.093327 -2.410175  1.681185 -3.694504  4.990198 -3.717897 -0.468183 
##       162       163       164 
## -0.173149  2.264968 -1.558051
bosque.res<-resid(bosque.reg)
plot(bosque.res)

plot of chunk unnamed-chunk-3