1. Load the penguins2 excel file into R, and convert the dataset into a data frame.
library('xlsx')
penguins <- read.xlsx("/Users/jusimioni/Desktop/MSDA 2021-23/Fall 2022/data/penguins2.xlsx", sheetIndex = 1)
penguins <- as.data.frame(penguins)
colnames(penguins)
## [1] "species"           "island"            "bill_length_mm"   
## [4] "bill_depth_mm"     "flipper_length_mm" "body_mass_g"      
## [7] "year"
  1. Check for missing values in the dataset. For any missing value(s) in a numeric column(s) of data, impute the average of the column.
sum(is.na(penguins))
## [1] 8
sum(is.na(penguins$species))
## [1] 0
sum(is.na(penguins$island))
## [1] 0
sum(is.na(penguins$bill_length_mm)) # 2 missing values
## [1] 2
sum(is.na(penguins$bill_depth_mm)) # 2 missing values
## [1] 2
sum(is.na(penguins$flipper_length_mm)) # 2 missing values
## [1] 2
sum(is.na(penguins$body_mass_g)) # 2 missing values
## [1] 2
sum(is.na(penguins$year))
## [1] 0

Input of the average for missing values.

penguins$bill_length_mm[is.na(penguins$bill_length_mm)] <- mean(penguins$bill_length_mm,na.rm=TRUE)
penguins$bill_depth_mm[is.na(penguins$bill_depth_mm)] <- mean(penguins$bill_depth_mm,na.rm=TRUE)
penguins$flipper_length_mm[is.na(penguins$flipper_length_mm)] <- mean(penguins$flipper_length_mm,na.rm=TRUE)
penguins$body_mass_g[is.na(penguins$body_mass_g)] <- mean(penguins$body_mass_g,na.rm=TRUE)
  1. Convert all non-numeric columns of data into factors.
    Species
penguins$species = as.factor(penguins$species)
levels(penguins$species)
## [1] "Adelie"    "Chinstrap" "Gentoo"
penguins$species=as.numeric(penguins$species,"Adelie"=1, "Chinstrap"=2, "SGentoo"=3)

Island

penguins$island = as.factor(penguins$island)
levels(penguins$island)
## [1] "Biscoe"    "Dream"     "Torgersen"
penguins$island=as.numeric(penguins$island,"Biscoe"=1, "Dream"=2, "Torgersen"=3)
  1. Randomly sample the rows of your data to include 90% of the rows in your training set. Use therest of the rows as your testing set.
index <- sample(nrow(penguins), nrow(penguins)*0.90)
penguins_train <- penguins[index,]
penguins_test <- penguins[-index,]
  1. Using 10,000 trees that each have 3 splits, develop a boosting model to predict the body mass of a penguin. In creating your model, use a shrinkage/weight of 0.01.
library(gbm)
## Loaded gbm 2.1.8.1
p_boost<- gbm(formula = body_mass_g~.,
                   data = penguins_train,
                   distribution = "gaussian",
                   n.trees = 10000,
                   shrinkage = 0.01,
                   interaction.depth = 3)
summary(p_boost)

##                                 var   rel.inf
## flipper_length_mm flipper_length_mm 38.138583
## species                     species 21.806518
## bill_length_mm       bill_length_mm 18.163004
## bill_depth_mm         bill_depth_mm 16.831491
## year                           year  2.935484
## island                       island  2.124921
  1. Does it make more sense to use the training set or testing set when developing this model?
    Yes, becasue the test set will help validating the model.
  2. Which covariate is most influential in your predictive model? In answering this question, be sure to provide your output from your code listing the relative influence of each covariate.
    Flipper_length_mm is the most influecial variable of the set.
  3. Create a graph displaying the relationship (as determined in your model) between the target variable and the most influential covariate.
    The following plot shows the correlations between the variables. It i interesting to see the the very high correlation between flipper_legth_mm and species, the flipper_legth_mm and body mass, there is also correlation between body mass and species and a bit smaller correlation with the bill_legth_mm and negative correlation of body_mass and the othe rtwo variables.
correlations <- cor(penguins_train[,c(1, 2, 3, 4, 5, 6)], use="everything")
corrplot::corrplot(correlations, method="circle", type="lower",  sig.level = 0.01, insig = "blank")

Now looking at the variable flippper_length_mm and body mass, there is a high correlation between size and weight and the plot is really well distributed across the linear line for the chart.

library(car)
## Loading required package: carData
scatterplot(body_mass_g ~ flipper_length_mm, data=penguins_train,  xlab="Flipper Length MM", ylab="Penguin Mass", grid=FALSE)

d) Use the testing set to calculate your model’s mean squared error (MSE).

MSE_p_test<- predict(p_boost, penguins_test, n.trees = 10000)
mean((penguins_test$body_mass_g-MSE_p_test)^2)
## [1] 151453.6

The mean square error for the model is 170644.4 what is very large. e) Create a graph displaying the test MSE when various amounts of trees are used in the boosting model. Based on this graph, could the MSE be improved by using a smaller number of trees? Be sure to provide the instructor with all output produced by your code.

ntree <- seq(100, 10000, 100)

predmat <- predict(p_boost, newdata = penguins_test, n.trees = ntree)
predmat
##            100      200      300      400      500      600      700      800
##  [1,] 3865.560 3715.144 3685.915 3655.381 3654.397 3651.366 3647.966 3651.411
##  [2,] 3936.012 3891.546 3929.405 3979.349 4038.413 4060.209 4085.721 4090.905
##  [3,] 3702.458 3466.315 3386.877 3365.355 3353.156 3346.630 3356.031 3379.150
##  [4,] 3821.250 3666.698 3620.433 3596.580 3595.915 3594.100 3600.664 3614.372
##  [5,] 3947.082 3912.549 3942.593 3993.073 4027.893 4046.750 4062.086 4059.122
##  [6,] 3821.250 3663.771 3640.021 3651.569 3676.295 3691.616 3732.663 3754.686
##  [7,] 3844.350 3722.971 3715.387 3742.470 3764.188 3768.748 3786.696 3800.702
##  [8,] 3927.078 3846.923 3847.227 3877.705 3908.343 3925.895 3949.717 3951.356
##  [9,] 3692.385 3444.840 3333.289 3287.540 3271.150 3247.373 3242.882 3243.505
## [10,] 3939.843 3888.368 3906.489 3940.748 3972.542 3978.349 4011.281 4008.038
## [11,] 4046.304 4020.776 4042.718 4077.300 4093.101 4102.406 4115.810 4116.159
## [12,] 3757.833 3541.225 3462.223 3425.730 3416.624 3408.218 3404.762 3406.325
## [13,] 3874.899 3750.409 3706.962 3690.585 3691.938 3688.453 3683.148 3668.116
## [14,] 3947.082 3914.856 3951.957 3994.976 4049.629 4071.820 4095.872 4102.207
## [15,] 3886.492 3791.625 3781.381 3791.689 3815.880 3830.822 3830.756 3832.459
## [16,] 3936.012 3882.288 3903.090 3931.830 3957.337 3968.957 3968.979 3970.782
## [17,] 4030.646 4004.427 4010.312 4013.111 4029.788 4034.694 4029.836 4034.015
## [18,] 3941.708 3839.945 3785.657 3744.432 3718.544 3701.493 3676.302 3651.182
## [19,] 3682.910 3408.163 3271.147 3203.099 3170.136 3146.278 3136.983 3146.598
## [20,] 3875.035 3744.748 3719.804 3685.704 3689.172 3681.154 3673.101 3666.058
## [21,] 3816.380 3643.065 3572.495 3516.943 3497.367 3483.594 3469.490 3450.419
## [22,] 4927.674 5214.043 5344.744 5422.950 5446.425 5466.872 5474.503 5488.920
## [23,] 4465.188 4518.174 4520.887 4530.940 4526.682 4520.337 4523.931 4522.078
## [24,] 4433.249 4478.845 4472.658 4462.445 4447.923 4435.902 4437.266 4437.607
## [25,] 4433.249 4478.845 4474.936 4476.768 4470.957 4460.588 4465.084 4464.430
## [26,] 5061.397 5404.113 5556.608 5606.322 5633.246 5647.906 5651.644 5650.701
## [27,] 4751.562 4930.627 4999.491 5026.897 5044.265 5052.214 5068.688 5079.777
## [28,] 4691.350 4843.848 4880.754 4886.280 4886.416 4881.353 4886.651 4894.521
## [29,] 4583.142 4680.383 4698.666 4695.003 4695.627 4693.927 4699.441 4702.940
## [30,] 4048.958 4005.517 3975.500 3969.809 3931.901 3926.076 3917.979 3894.410
## [31,] 3821.250 3654.124 3560.021 3505.978 3479.408 3468.442 3451.494 3449.066
## [32,] 3830.724 3681.206 3624.631 3614.981 3615.533 3633.791 3634.396 3640.629
## [33,] 3920.848 3825.833 3784.815 3787.646 3780.897 3785.202 3784.366 3788.243
## [34,] 4192.049 4210.060 4231.554 4231.927 4237.735 4238.184 4249.537 4249.537
## [35,] 4041.689 3981.112 3916.150 3867.341 3826.949 3793.973 3777.542 3756.900
##            900     1000     1100     1200     1300     1400     1500     1600
##  [1,] 3633.171 3637.445 3632.671 3644.224 3635.552 3635.797 3631.775 3624.200
##  [2,] 4111.430 4129.236 4128.892 4130.079 4133.776 4133.802 4139.107 4130.798
##  [3,] 3385.185 3391.336 3393.126 3400.890 3400.526 3407.658 3414.015 3419.482
##  [4,] 3619.223 3625.467 3627.368 3629.535 3622.335 3629.780 3632.943 3628.789
##  [5,] 4069.461 4083.180 4078.588 4075.480 4074.401 4068.335 4070.004 4060.896
##  [6,] 3760.070 3771.590 3779.325 3794.374 3804.623 3812.937 3817.979 3821.251
##  [7,] 3808.868 3808.325 3814.144 3810.874 3817.170 3817.549 3808.478 3802.393
##  [8,] 3960.410 3955.446 3955.224 3960.014 3961.592 3967.934 3970.324 3967.877
##  [9,] 3242.204 3243.592 3241.669 3241.418 3241.893 3248.264 3234.554 3242.416
## [10,] 4020.723 4027.725 4033.620 4043.127 4045.289 4061.622 4065.983 4064.621
## [11,] 4122.149 4125.230 4132.324 4132.889 4127.247 4133.352 4142.224 4132.886
## [12,] 3417.433 3429.690 3436.134 3438.673 3442.038 3450.827 3445.693 3461.212
## [13,] 3664.416 3671.968 3665.276 3658.990 3667.427 3667.119 3662.321 3665.828
## [14,] 4121.545 4131.586 4131.758 4138.777 4155.543 4155.019 4153.595 4161.056
## [15,] 3841.822 3858.570 3857.767 3864.590 3883.207 3880.423 3888.680 3900.374
## [16,] 3978.927 3978.932 3966.494 3964.083 3972.280 3974.866 3978.869 3980.038
## [17,] 4044.792 4044.697 4053.445 4050.975 4050.778 4049.938 4060.659 4055.542
## [18,] 3648.790 3634.799 3634.550 3635.295 3636.854 3626.841 3626.461 3627.747
## [19,] 3148.623 3148.665 3142.896 3147.791 3152.795 3155.181 3158.448 3162.168
## [20,] 3655.485 3652.062 3635.602 3639.152 3635.508 3619.846 3618.992 3624.554
## [21,] 3448.348 3440.043 3436.624 3434.990 3439.150 3432.321 3419.993 3417.370
## [22,] 5495.253 5492.606 5498.729 5506.919 5520.372 5523.999 5521.782 5520.658
## [23,] 4529.164 4532.068 4528.003 4534.430 4533.917 4527.561 4523.774 4526.802
## [24,] 4437.596 4443.246 4439.019 4442.823 4444.477 4440.993 4434.646 4440.046
## [25,] 4477.593 4484.001 4487.008 4496.248 4500.894 4499.753 4494.174 4497.238
## [26,] 5657.349 5647.470 5651.190 5646.102 5644.758 5642.564 5632.980 5630.436
## [27,] 5091.621 5098.126 5107.562 5110.166 5112.547 5114.451 5127.076 5127.605
## [28,] 4904.082 4909.516 4906.536 4905.162 4901.614 4902.383 4913.901 4912.474
## [29,] 4709.976 4718.296 4717.402 4722.411 4719.877 4723.029 4737.690 4739.771
## [30,] 3877.920 3870.936 3850.533 3842.470 3840.370 3833.581 3833.759 3825.844
## [31,] 3449.605 3452.411 3462.476 3467.840 3468.448 3473.090 3475.603 3481.899
## [32,] 3648.802 3659.715 3667.605 3671.352 3668.968 3669.909 3684.975 3693.151
## [33,] 3793.190 3806.436 3803.332 3807.162 3804.262 3802.166 3812.312 3808.033
## [34,] 4264.251 4277.933 4285.476 4290.338 4305.601 4300.642 4308.718 4320.187
## [35,] 3757.969 3756.944 3758.142 3750.736 3751.788 3744.990 3750.255 3755.324
##           1700     1800     1900     2000     2100     2200     2300     2400
##  [1,] 3614.154 3615.457 3611.180 3617.286 3613.971 3619.212 3626.870 3630.011
##  [2,] 4126.206 4127.474 4118.802 4123.878 4119.279 4112.818 4114.158 4114.849
##  [3,] 3428.214 3436.493 3430.974 3439.526 3444.719 3447.755 3455.865 3452.272
##  [4,] 3629.454 3631.944 3628.072 3638.151 3640.189 3632.684 3638.366 3639.603
##  [5,] 4057.781 4053.827 4050.670 4057.532 4053.511 4043.086 4048.303 4051.005
##  [6,] 3830.153 3838.096 3851.288 3859.786 3864.648 3870.978 3883.675 3891.820
##  [7,] 3799.261 3793.853 3799.937 3793.885 3793.432 3792.609 3790.176 3790.877
##  [8,] 3973.425 3982.905 3980.732 3979.625 3976.536 3970.755 3971.966 3966.391
##  [9,] 3243.676 3252.640 3245.534 3245.260 3252.669 3254.953 3260.300 3259.894
## [10,] 4075.614 4081.385 4088.305 4096.058 4108.662 4127.161 4135.625 4147.209
## [11,] 4134.071 4124.617 4121.567 4126.094 4134.509 4136.868 4134.548 4140.649
## [12,] 3467.091 3477.055 3478.274 3481.846 3496.076 3502.761 3510.452 3510.570
## [13,] 3663.505 3660.867 3668.283 3676.677 3679.124 3673.315 3678.553 3678.031
## [14,] 4171.262 4168.075 4176.448 4184.092 4175.044 4172.966 4179.610 4183.439
## [15,] 3899.457 3904.880 3910.258 3915.448 3905.736 3907.093 3907.929 3914.524
## [16,] 3977.751 3981.956 3985.846 3987.720 3971.095 3969.330 3964.847 3965.707
## [17,] 4046.765 4041.203 4042.377 4039.247 4041.035 4047.484 4042.139 4034.821
## [18,] 3624.771 3617.727 3616.373 3612.166 3607.736 3623.515 3617.631 3607.251
## [19,] 3177.875 3180.048 3174.717 3175.986 3179.839 3183.816 3192.960 3193.641
## [20,] 3615.538 3614.501 3613.086 3607.185 3599.428 3608.337 3609.704 3609.071
## [21,] 3413.484 3408.520 3416.649 3414.425 3413.034 3413.364 3416.504 3414.401
## [22,] 5523.611 5532.696 5530.455 5533.870 5530.210 5538.517 5546.862 5540.230
## [23,] 4522.223 4515.292 4510.204 4509.008 4512.260 4513.682 4509.678 4503.115
## [24,] 4436.274 4426.859 4424.697 4419.897 4426.153 4426.485 4424.155 4426.457
## [25,] 4499.736 4494.935 4496.740 4496.421 4503.462 4512.225 4513.026 4518.551
## [26,] 5629.738 5623.595 5618.333 5615.650 5607.233 5601.977 5597.315 5593.461
## [27,] 5134.631 5130.978 5131.214 5128.786 5134.365 5139.424 5136.571 5139.521
## [28,] 4915.884 4912.627 4908.613 4900.385 4908.249 4912.781 4912.853 4917.082
## [29,] 4747.543 4750.737 4756.119 4758.009 4765.954 4776.403 4779.291 4786.303
## [30,] 3821.845 3809.050 3800.211 3791.888 3775.756 3777.775 3775.899 3767.084
## [31,] 3478.143 3484.366 3481.279 3485.354 3475.065 3484.142 3487.407 3495.328
## [32,] 3695.853 3701.530 3702.001 3697.838 3690.734 3692.855 3694.504 3696.162
## [33,] 3809.173 3811.136 3816.756 3817.055 3813.154 3816.470 3823.086 3838.014
## [34,] 4323.038 4323.133 4322.867 4333.214 4331.894 4328.108 4330.385 4336.186
## [35,] 3764.946 3758.493 3761.683 3764.077 3770.662 3779.717 3773.433 3779.791
##           2500     2600     2700     2800     2900     3000     3100     3200
##  [1,] 3624.711 3627.624 3628.258 3638.394 3633.432 3644.696 3649.266 3659.416
##  [2,] 4118.271 4120.044 4110.070 4114.753 4118.484 4118.842 4118.178 4117.568
##  [3,] 3449.242 3448.957 3449.509 3455.737 3448.701 3443.640 3461.173 3461.397
##  [4,] 3624.214 3624.863 3637.961 3641.226 3638.270 3644.449 3648.296 3647.563
##  [5,] 4061.713 4057.992 4047.883 4052.801 4057.008 4059.293 4059.615 4061.708
##  [6,] 3878.655 3878.849 3877.933 3894.168 3887.123 3889.606 3893.389 3906.618
##  [7,] 3782.002 3780.432 3783.458 3776.277 3776.928 3768.773 3772.402 3773.724
##  [8,] 3959.280 3965.078 3972.583 3971.233 3967.400 3964.887 3963.495 3957.736
##  [9,] 3260.507 3261.125 3261.601 3259.511 3261.049 3257.543 3266.819 3265.138
## [10,] 4149.790 4153.601 4155.508 4174.993 4170.208 4175.521 4187.909 4194.968
## [11,] 4146.647 4153.173 4150.500 4154.981 4155.068 4161.707 4168.677 4176.147
## [12,] 3518.214 3525.026 3524.402 3523.835 3526.640 3523.177 3534.314 3534.991
## [13,] 3693.146 3701.311 3693.949 3696.577 3700.536 3700.278 3694.964 3690.732
## [14,] 4194.181 4196.389 4189.972 4195.647 4203.694 4203.481 4199.467 4195.218
## [15,] 3914.809 3920.582 3922.247 3920.093 3932.155 3935.107 3931.838 3925.761
## [16,] 3966.310 3967.159 3957.152 3953.868 3965.362 3963.632 3954.347 3954.402
## [17,] 4031.064 4026.298 4032.081 4033.484 4030.669 4035.689 4035.428 4033.634
## [18,] 3606.970 3603.797 3600.096 3596.350 3598.532 3593.390 3591.801 3597.733
## [19,] 3192.794 3196.009 3202.270 3209.673 3220.491 3222.569 3226.413 3219.386
## [20,] 3597.417 3595.331 3589.249 3592.928 3587.576 3582.747 3576.172 3574.572
## [21,] 3421.221 3417.604 3413.039 3414.454 3421.220 3417.390 3419.201 3420.037
## [22,] 5547.162 5553.731 5557.398 5558.396 5559.859 5560.588 5577.449 5577.948
## [23,] 4504.990 4501.633 4501.558 4506.730 4506.948 4502.051 4518.766 4519.259
## [24,] 4427.624 4421.952 4422.595 4430.748 4433.503 4433.464 4447.207 4446.826
## [25,] 4519.535 4516.359 4520.643 4531.560 4537.559 4539.919 4554.758 4558.782
## [26,] 5599.587 5599.594 5607.159 5608.477 5605.788 5613.558 5620.567 5618.122
## [27,] 5142.034 5140.871 5152.274 5153.851 5152.191 5152.976 5153.850 5153.535
## [28,] 4917.857 4916.794 4921.614 4924.189 4922.332 4924.212 4928.070 4924.291
## [29,] 4788.641 4787.541 4793.832 4798.935 4799.895 4804.274 4809.337 4805.757
## [30,] 3770.129 3759.453 3745.594 3740.710 3746.506 3744.650 3734.049 3731.765
## [31,] 3488.062 3493.724 3494.947 3499.166 3508.404 3514.681 3516.047 3512.002
## [32,] 3695.986 3697.442 3695.457 3692.260 3696.658 3697.581 3695.816 3687.402
## [33,] 3848.619 3841.718 3842.343 3843.063 3847.775 3847.763 3854.655 3853.010
## [34,] 4343.526 4351.056 4343.165 4350.183 4350.678 4356.151 4357.321 4365.099
## [35,] 3776.577 3775.881 3767.559 3768.768 3767.309 3774.547 3770.832 3772.637
##           3300     3400     3500     3600     3700     3800     3900     4000
##  [1,] 3666.105 3661.670 3656.356 3664.642 3667.655 3666.447 3663.768 3664.279
##  [2,] 4124.773 4116.251 4121.394 4119.621 4109.800 4112.913 4115.346 4109.513
##  [3,] 3465.250 3467.294 3469.574 3479.448 3473.225 3470.808 3472.375 3474.543
##  [4,] 3651.192 3653.538 3656.029 3659.727 3657.210 3656.005 3655.061 3651.821
##  [5,] 4068.427 4060.931 4063.017 4064.756 4055.864 4060.030 4064.442 4063.014
##  [6,] 3911.478 3904.955 3906.287 3913.195 3906.709 3899.208 3900.325 3907.086
##  [7,] 3779.373 3772.872 3773.977 3776.188 3770.988 3765.016 3766.660 3763.546
##  [8,] 3962.322 3955.175 3952.593 3951.238 3949.196 3945.494 3946.694 3948.095
##  [9,] 3265.633 3268.421 3266.740 3271.643 3267.502 3269.096 3272.072 3275.919
## [10,] 4207.499 4203.158 4198.044 4208.362 4199.330 4205.358 4210.766 4209.764
## [11,] 4178.112 4170.819 4167.247 4172.658 4169.186 4174.786 4170.999 4165.099
## [12,] 3536.649 3543.483 3546.597 3551.143 3549.609 3552.796 3556.316 3562.578
## [13,] 3696.071 3694.388 3698.285 3701.788 3700.910 3704.728 3703.977 3711.341
## [14,] 4207.119 4204.742 4208.218 4208.138 4201.315 4203.518 4208.055 4206.943
## [15,] 3938.536 3938.237 3935.344 3941.697 3947.047 3940.888 3945.656 3947.790
## [16,] 3960.914 3959.091 3958.802 3963.284 3957.521 3957.351 3965.543 3969.600
## [17,] 4027.313 4018.743 4016.470 4015.480 4010.954 4013.383 4012.836 4006.731
## [18,] 3598.185 3587.014 3585.978 3587.240 3590.910 3587.129 3584.011 3590.675
## [19,] 3212.408 3220.021 3214.715 3214.975 3219.221 3220.082 3223.597 3236.144
## [20,] 3576.363 3572.246 3563.852 3566.422 3571.185 3567.264 3566.975 3567.247
## [21,] 3428.645 3420.883 3423.984 3430.370 3432.325 3426.294 3430.856 3436.163
## [22,] 5585.477 5583.080 5583.606 5578.257 5581.077 5584.452 5587.570 5587.257
## [23,] 4513.816 4514.638 4516.345 4513.475 4511.291 4510.431 4507.939 4497.030
## [24,] 4442.869 4446.373 4448.000 4448.726 4449.672 4453.100 4446.957 4438.826
## [25,] 4560.918 4567.252 4563.284 4559.461 4561.209 4564.005 4556.854 4549.355
## [26,] 5616.138 5612.016 5614.417 5608.893 5610.008 5606.268 5604.685 5609.047
## [27,] 5154.433 5157.741 5164.167 5165.578 5165.536 5175.093 5175.976 5176.345
## [28,] 4918.531 4917.646 4915.948 4914.453 4913.920 4921.412 4916.309 4915.035
## [29,] 4804.962 4806.168 4812.032 4815.519 4818.827 4825.610 4823.373 4826.991
## [30,] 3730.264 3721.449 3721.140 3714.354 3706.634 3706.084 3704.241 3697.780
## [31,] 3518.162 3514.380 3509.898 3517.347 3512.754 3505.742 3509.088 3510.419
## [32,] 3689.430 3683.688 3680.756 3681.431 3669.361 3670.594 3676.556 3676.227
## [33,] 3856.384 3849.765 3848.711 3858.161 3852.015 3851.164 3858.697 3857.740
## [34,] 4373.779 4377.381 4373.707 4377.563 4374.087 4379.641 4390.705 4384.834
## [35,] 3772.911 3773.725 3767.187 3774.609 3777.825 3775.668 3775.579 3773.851
##           4100     4200     4300     4400     4500     4600     4700     4800
##  [1,] 3674.198 3672.226 3681.951 3685.636 3676.778 3676.604 3678.625 3682.017
##  [2,] 4115.328 4107.803 4112.073 4116.757 4103.905 4106.834 4103.834 4113.525
##  [3,] 3477.577 3477.841 3487.532 3493.455 3498.945 3499.486 3502.258 3499.761
##  [4,] 3652.716 3644.390 3648.782 3658.520 3650.431 3656.781 3652.638 3656.637
##  [5,] 4070.891 4068.726 4071.236 4078.130 4072.080 4071.296 4068.585 4074.802
##  [6,] 3900.137 3892.847 3899.101 3899.185 3894.690 3895.608 3892.697 3884.474
##  [7,] 3748.435 3746.760 3747.102 3745.269 3748.060 3750.430 3747.672 3746.894
##  [8,] 3948.129 3941.937 3948.382 3950.819 3951.832 3944.165 3940.849 3949.698
##  [9,] 3270.498 3265.422 3272.210 3270.349 3269.955 3274.061 3279.500 3276.886
## [10,] 4210.174 4208.595 4213.604 4226.285 4229.385 4233.489 4233.744 4234.367
## [11,] 4169.157 4168.197 4169.129 4176.708 4182.338 4181.117 4178.898 4184.513
## [12,] 3554.823 3550.280 3561.819 3566.038 3566.612 3570.196 3572.821 3573.241
## [13,] 3712.511 3708.556 3716.582 3720.063 3719.800 3713.212 3721.909 3723.221
## [14,] 4210.240 4208.388 4207.315 4214.149 4211.519 4206.718 4209.097 4214.606
## [15,] 3960.654 3956.916 3961.279 3958.304 3951.898 3949.978 3951.295 3951.740
## [16,] 3975.723 3977.399 3975.042 3972.238 3968.577 3965.292 3967.380 3967.212
## [17,] 4002.172 4009.263 4011.232 4005.850 4012.110 4012.753 4008.555 4012.059
## [18,] 3591.764 3597.698 3604.622 3598.343 3603.780 3600.172 3604.352 3599.145
## [19,] 3236.480 3244.208 3242.858 3242.306 3244.210 3245.427 3242.358 3246.701
## [20,] 3571.733 3565.675 3573.450 3564.612 3556.592 3557.985 3560.677 3553.674
## [21,] 3438.356 3439.722 3443.813 3437.427 3442.870 3446.051 3446.853 3438.356
## [22,] 5590.501 5592.222 5599.352 5599.221 5602.271 5601.879 5601.841 5609.281
## [23,] 4499.246 4495.792 4495.906 4500.594 4488.834 4494.522 4500.245 4501.332
## [24,] 4440.283 4440.716 4441.660 4443.704 4434.874 4440.032 4445.750 4442.383
## [25,] 4549.827 4554.674 4556.720 4560.003 4555.292 4561.341 4567.454 4570.411
## [26,] 5608.701 5603.586 5598.097 5593.902 5597.223 5597.937 5593.482 5595.822
## [27,] 5180.502 5178.124 5178.949 5183.280 5182.920 5188.790 5185.626 5183.128
## [28,] 4921.981 4917.556 4920.379 4923.361 4921.309 4923.130 4922.196 4917.229
## [29,] 4836.673 4835.848 4839.761 4845.898 4848.739 4856.048 4859.859 4856.835
## [30,] 3696.299 3686.766 3688.324 3680.181 3675.185 3662.641 3655.991 3656.300
## [31,] 3515.765 3516.107 3521.370 3524.197 3523.958 3524.048 3517.106 3522.230
## [32,] 3668.334 3662.871 3666.721 3672.236 3668.159 3675.356 3675.617 3669.428
## [33,] 3853.635 3854.054 3855.227 3863.300 3860.538 3866.691 3864.374 3860.801
## [34,] 4388.026 4392.015 4387.908 4388.898 4394.722 4391.836 4391.410 4393.794
## [35,] 3776.386 3779.562 3781.797 3778.758 3792.830 3791.703 3789.908 3789.740
##           4900     5000     5100     5200     5300     5400     5500     5600
##  [1,] 3678.089 3670.922 3680.613 3680.084 3689.668 3687.018 3687.539 3690.454
##  [2,] 4110.725 4106.845 4108.565 4110.059 4107.126 4105.556 4093.721 4093.443
##  [3,] 3504.560 3503.492 3505.150 3502.938 3505.671 3515.193 3517.421 3512.990
##  [4,] 3654.320 3652.856 3654.978 3657.572 3660.947 3659.978 3658.933 3662.329
##  [5,] 4076.840 4073.609 4075.856 4075.345 4074.260 4078.019 4072.624 4077.788
##  [6,] 3881.041 3881.807 3875.566 3879.364 3875.327 3870.445 3880.693 3878.906
##  [7,] 3746.357 3747.516 3747.854 3750.420 3749.943 3744.599 3745.456 3741.001
##  [8,] 3945.146 3950.300 3953.411 3954.418 3949.138 3953.105 3951.164 3948.822
##  [9,] 3276.354 3271.349 3273.849 3269.773 3273.997 3280.926 3273.970 3273.594
## [10,] 4234.168 4240.168 4236.945 4245.871 4251.389 4252.696 4257.586 4263.370
## [11,] 4179.347 4176.070 4174.473 4170.574 4172.238 4172.179 4167.891 4173.734
## [12,] 3572.495 3569.870 3579.487 3580.358 3588.501 3593.292 3586.306 3589.720
## [13,] 3715.295 3717.063 3720.609 3714.622 3719.714 3716.364 3708.674 3709.523
## [14,] 4213.094 4214.136 4215.168 4221.270 4219.833 4224.789 4217.930 4218.235
## [15,] 3952.503 3953.459 3954.980 3954.611 3955.909 3959.604 3963.704 3963.358
## [16,] 3975.794 3969.697 3971.319 3970.614 3972.592 3972.111 3971.709 3975.671
## [17,] 4007.836 4001.512 4003.370 4002.335 4002.184 4000.424 3995.830 3993.680
## [18,] 3591.997 3599.451 3598.129 3595.316 3598.883 3595.900 3594.665 3594.018
## [19,] 3252.432 3256.068 3258.161 3256.754 3259.803 3262.565 3262.702 3262.959
## [20,] 3547.942 3541.861 3544.347 3536.483 3539.440 3533.254 3535.013 3535.730
## [21,] 3436.597 3444.537 3447.120 3445.783 3453.879 3453.545 3457.456 3454.855
## [22,] 5614.159 5616.692 5617.326 5613.803 5616.171 5618.634 5613.971 5616.684
## [23,] 4501.407 4506.296 4505.095 4506.581 4502.648 4506.587 4508.187 4505.994
## [24,] 4441.289 4442.620 4440.444 4441.480 4435.676 4439.439 4442.001 4437.784
## [25,] 4572.696 4575.498 4573.290 4575.434 4571.800 4575.349 4577.515 4572.908
## [26,] 5594.948 5593.156 5595.184 5601.069 5592.239 5598.322 5595.848 5591.444
## [27,] 5185.978 5182.613 5183.081 5184.151 5183.177 5188.448 5194.366 5191.437
## [28,] 4922.157 4928.498 4926.213 4922.789 4923.138 4925.256 4926.308 4924.294
## [29,] 4861.058 4865.662 4864.746 4862.342 4865.466 4868.038 4871.239 4870.953
## [30,] 3654.592 3657.192 3651.057 3639.678 3634.962 3626.333 3618.296 3621.894
## [31,] 3523.940 3520.491 3521.635 3528.990 3529.153 3522.682 3524.726 3520.075
## [32,] 3670.520 3672.246 3671.087 3674.078 3672.189 3670.922 3671.155 3670.002
## [33,] 3858.794 3860.304 3861.053 3857.638 3862.246 3860.362 3861.240 3859.255
## [34,] 4401.786 4396.439 4397.619 4403.621 4401.699 4411.201 4412.117 4417.684
## [35,] 3791.007 3780.848 3777.083 3776.169 3778.736 3772.679 3776.447 3781.963
##           5700     5800     5900     6000     6100     6200     6300     6400
##  [1,] 3701.525 3710.192 3710.890 3711.267 3714.699 3714.570 3713.363 3714.393
##  [2,] 4090.626 4092.365 4090.643 4090.968 4095.520 4092.402 4082.405 4083.759
##  [3,] 3524.204 3524.573 3523.513 3518.135 3521.794 3517.496 3517.730 3524.203
##  [4,] 3672.408 3677.001 3677.305 3682.151 3676.415 3669.739 3668.975 3676.782
##  [5,] 4076.613 4077.472 4077.333 4080.675 4078.199 4080.185 4075.157 4078.069
##  [6,] 3886.685 3887.707 3890.218 3883.554 3883.423 3881.254 3876.972 3880.875
##  [7,] 3743.161 3737.812 3732.776 3730.356 3732.440 3725.108 3724.153 3728.703
##  [8,] 3951.046 3945.532 3941.852 3937.501 3939.390 3933.828 3932.078 3932.799
##  [9,] 3274.816 3269.586 3271.463 3268.988 3271.034 3270.384 3273.346 3271.051
## [10,] 4261.217 4263.958 4273.871 4275.506 4276.291 4274.069 4276.222 4279.684
## [11,] 4177.006 4178.795 4178.247 4181.110 4177.386 4179.162 4179.695 4180.166
## [12,] 3591.037 3590.478 3592.132 3595.236 3595.365 3599.102 3605.770 3605.312
## [13,] 3708.692 3708.207 3707.112 3710.346 3713.232 3723.467 3719.465 3713.673
## [14,] 4212.465 4209.588 4212.550 4214.282 4212.372 4214.999 4207.190 4211.087
## [15,] 3968.302 3967.386 3975.125 3964.900 3976.969 3983.289 3976.404 3971.645
## [16,] 3978.010 3971.235 3973.931 3971.780 3972.880 3977.079 3972.107 3972.296
## [17,] 3995.997 3992.936 3998.047 3995.917 3991.798 3982.593 3984.717 3982.864
## [18,] 3597.567 3595.634 3602.815 3596.303 3595.076 3594.565 3598.260 3594.590
## [19,] 3268.575 3263.678 3266.524 3270.378 3265.603 3267.196 3272.313 3268.059
## [20,] 3535.169 3535.076 3540.780 3537.086 3540.310 3536.226 3533.065 3527.446
## [21,] 3456.677 3454.789 3456.049 3450.420 3458.330 3457.344 3460.077 3456.088
## [22,] 5619.710 5622.914 5622.109 5628.756 5624.220 5627.972 5628.594 5629.874
## [23,] 4512.803 4511.033 4504.577 4502.648 4508.107 4505.383 4516.329 4517.684
## [24,] 4439.215 4437.915 4431.968 4430.632 4430.160 4426.540 4437.128 4435.801
## [25,] 4575.403 4575.696 4568.546 4566.195 4564.173 4563.555 4575.087 4574.075
## [26,] 5593.011 5594.702 5594.287 5595.611 5590.387 5586.532 5588.219 5593.232
## [27,] 5194.638 5200.710 5201.625 5203.615 5200.828 5199.212 5201.373 5204.446
## [28,] 4923.194 4926.418 4925.185 4930.835 4931.199 4931.759 4930.233 4925.646
## [29,] 4871.988 4877.383 4882.569 4883.654 4890.303 4891.659 4893.928 4893.700
## [30,] 3620.615 3617.830 3611.898 3609.907 3606.642 3608.088 3609.439 3604.539
## [31,] 3531.423 3524.449 3514.621 3516.733 3515.137 3521.199 3521.534 3525.343
## [32,] 3669.860 3665.290 3665.987 3669.463 3670.398 3675.515 3680.220 3680.255
## [33,] 3863.921 3866.762 3863.881 3863.160 3864.234 3867.223 3866.779 3868.899
## [34,] 4412.667 4408.702 4406.673 4412.503 4413.019 4417.842 4417.908 4419.372
## [35,] 3787.777 3780.466 3775.638 3781.301 3785.585 3787.407 3791.283 3791.153
##           6500     6600     6700     6800     6900     7000     7100     7200
##  [1,] 3714.085 3715.941 3713.633 3716.727 3708.657 3712.531 3720.433 3722.030
##  [2,] 4081.618 4084.144 4083.919 4082.847 4072.332 4073.693 4071.975 4066.755
##  [3,] 3522.003 3530.075 3527.360 3530.453 3527.967 3536.895 3536.530 3534.515
##  [4,] 3682.082 3683.999 3684.614 3683.427 3682.854 3685.473 3690.269 3686.999
##  [5,] 4073.728 4074.434 4072.790 4075.071 4073.748 4076.117 4077.291 4077.971
##  [6,] 3879.542 3876.420 3875.924 3881.536 3881.891 3884.410 3883.376 3881.180
##  [7,] 3732.224 3734.138 3733.982 3735.975 3736.254 3737.683 3739.891 3734.330
##  [8,] 3940.082 3940.531 3944.903 3950.994 3952.919 3948.909 3945.876 3939.949
##  [9,] 3267.215 3273.345 3266.955 3265.527 3268.272 3272.872 3270.223 3270.162
## [10,] 4278.968 4282.387 4280.384 4281.173 4283.049 4286.142 4281.678 4284.380
## [11,] 4180.918 4179.930 4177.791 4179.390 4181.406 4180.339 4182.541 4186.993
## [12,] 3603.723 3605.325 3602.296 3603.343 3603.436 3611.678 3607.018 3610.932
## [13,] 3707.723 3717.623 3714.678 3722.835 3721.501 3723.932 3718.981 3720.227
## [14,] 4211.366 4213.803 4215.938 4218.738 4214.536 4216.034 4213.549 4213.917
## [15,] 3976.286 3980.759 3979.497 3990.288 3989.353 3996.824 3998.935 3997.398
## [16,] 3970.112 3965.625 3964.267 3970.260 3974.341 3979.875 3981.256 3980.776
## [17,] 3985.558 3983.907 3983.128 3982.090 3975.595 3978.999 3978.957 3977.814
## [18,] 3595.850 3600.074 3597.388 3595.788 3585.292 3593.248 3588.605 3586.702
## [19,] 3261.017 3273.669 3274.398 3275.898 3276.000 3279.199 3281.854 3280.301
## [20,] 3525.427 3520.535 3517.867 3517.748 3511.327 3510.447 3515.912 3513.620
## [21,] 3455.158 3463.149 3460.332 3466.163 3463.806 3472.005 3473.654 3469.231
## [22,] 5630.822 5632.028 5635.727 5633.244 5634.163 5641.175 5642.037 5636.213
## [23,] 4519.955 4523.023 4519.325 4517.588 4520.507 4517.107 4522.871 4519.918
## [24,] 4434.206 4433.617 4433.282 4434.694 4434.099 4431.152 4433.601 4433.502
## [25,] 4573.661 4573.550 4574.253 4574.717 4574.111 4570.133 4570.708 4568.496
## [26,] 5590.150 5589.624 5585.630 5584.038 5581.147 5581.486 5580.382 5576.462
## [27,] 5204.347 5205.768 5206.675 5213.787 5215.865 5212.361 5218.602 5217.690
## [28,] 4926.266 4929.681 4933.070 4939.113 4942.242 4942.991 4950.142 4951.589
## [29,] 4892.008 4896.212 4900.146 4905.929 4910.359 4903.959 4913.304 4913.991
## [30,] 3598.855 3590.416 3589.557 3582.474 3578.498 3582.728 3578.138 3568.569
## [31,] 3531.355 3531.102 3536.369 3534.358 3530.241 3532.397 3536.055 3533.118
## [32,] 3678.390 3687.090 3686.057 3679.385 3679.119 3685.601 3692.913 3684.504
## [33,] 3869.885 3872.317 3867.055 3864.675 3868.675 3870.935 3873.735 3870.515
## [34,] 4418.570 4422.589 4424.909 4427.115 4426.828 4436.894 4436.304 4440.568
## [35,] 3794.903 3789.931 3790.753 3786.740 3785.338 3786.962 3788.502 3788.341
##           7300     7400     7500     7600     7700     7800     7900     8000
##  [1,] 3723.240 3720.095 3724.762 3729.481 3736.934 3744.122 3741.908 3746.765
##  [2,] 4063.221 4062.707 4068.648 4061.579 4064.094 4054.048 4056.747 4049.639
##  [3,] 3531.414 3534.490 3531.955 3538.191 3539.543 3539.229 3540.978 3547.390
##  [4,] 3685.912 3686.689 3688.238 3687.701 3690.229 3687.747 3686.001 3688.753
##  [5,] 4075.763 4072.455 4083.412 4080.606 4084.470 4074.028 4081.740 4076.585
##  [6,] 3875.078 3871.654 3868.090 3872.208 3883.125 3877.756 3876.868 3876.781
##  [7,] 3734.112 3733.641 3739.130 3735.662 3739.369 3737.398 3732.485 3729.778
##  [8,] 3936.795 3935.283 3930.249 3929.544 3937.717 3929.770 3927.181 3922.832
##  [9,] 3269.592 3268.495 3263.625 3262.840 3264.403 3261.761 3259.168 3263.677
## [10,] 4276.550 4274.593 4277.628 4278.829 4286.422 4287.807 4296.081 4300.192
## [11,] 4181.179 4179.829 4186.927 4189.971 4195.702 4190.667 4192.302 4187.257
## [12,] 3607.053 3610.034 3605.539 3608.196 3608.436 3603.939 3606.617 3610.776
## [13,] 3720.975 3722.347 3723.349 3726.784 3729.509 3725.442 3727.937 3732.709
## [14,] 4212.616 4212.239 4215.239 4204.273 4204.390 4195.616 4201.183 4199.477
## [15,] 4000.548 4000.653 3997.981 4000.126 4002.026 3996.539 3998.904 3994.802
## [16,] 3979.543 3979.036 3982.905 3984.126 3981.501 3972.111 3974.632 3968.761
## [17,] 3976.739 3981.116 3987.326 3983.096 3979.969 3975.173 3974.491 3973.867
## [18,] 3582.520 3581.517 3585.432 3590.380 3592.482 3593.733 3595.722 3594.732
## [19,] 3279.217 3278.163 3280.519 3281.111 3283.035 3282.546 3281.218 3281.227
## [20,] 3513.201 3511.754 3509.992 3511.881 3513.552 3514.620 3512.261 3512.891
## [21,] 3468.353 3471.972 3477.456 3479.965 3483.899 3483.485 3484.287 3487.710
## [22,] 5635.779 5638.809 5643.597 5647.003 5650.222 5652.111 5650.220 5647.556
## [23,] 4527.446 4526.697 4528.727 4526.795 4521.250 4525.558 4525.531 4536.187
## [24,] 4437.422 4433.069 4435.414 4432.284 4427.806 4430.115 4428.966 4438.034
## [25,] 4572.292 4571.347 4573.860 4571.033 4567.392 4566.931 4564.430 4574.867
## [26,] 5577.546 5579.336 5573.418 5572.353 5573.406 5569.341 5570.139 5564.058
## [27,] 5220.981 5216.326 5217.038 5218.116 5217.984 5218.253 5222.038 5224.407
## [28,] 4954.188 4952.919 4954.813 4957.084 4954.262 4954.927 4956.798 4960.184
## [29,] 4917.395 4918.466 4918.455 4921.152 4919.679 4922.099 4925.773 4928.471
## [30,] 3563.521 3560.209 3560.585 3555.812 3558.580 3558.265 3562.111 3558.748
## [31,] 3534.033 3533.902 3532.253 3531.111 3535.028 3540.716 3535.817 3534.127
## [32,] 3679.595 3682.249 3676.461 3679.306 3679.446 3681.379 3677.661 3682.512
## [33,] 3872.133 3875.502 3875.274 3877.129 3880.045 3885.119 3886.145 3890.508
## [34,] 4441.915 4445.905 4447.152 4446.807 4447.289 4445.412 4451.132 4447.339
## [35,] 3783.237 3782.599 3780.303 3781.761 3786.790 3792.357 3790.494 3787.062
##           8100     8200     8300     8400     8500     8600     8700     8800
##  [1,] 3757.815 3756.715 3750.371 3758.399 3754.068 3758.001 3755.454 3757.499
##  [2,] 4052.933 4056.883 4055.974 4054.870 4047.720 4053.213 4053.599 4054.956
##  [3,] 3549.413 3549.634 3547.183 3550.433 3547.011 3552.763 3555.365 3557.498
##  [4,] 3692.287 3693.053 3697.072 3696.128 3693.100 3694.791 3692.224 3696.548
##  [5,] 4080.122 4082.034 4085.746 4083.273 4078.012 4080.150 4082.687 4083.951
##  [6,] 3872.861 3871.715 3868.995 3868.321 3867.176 3867.344 3867.277 3871.170
##  [7,] 3724.019 3725.760 3719.304 3717.215 3715.026 3718.628 3715.080 3718.779
##  [8,] 3927.232 3934.068 3932.079 3929.357 3929.218 3933.562 3935.069 3934.965
##  [9,] 3266.380 3266.025 3263.395 3267.087 3264.008 3265.712 3265.912 3268.793
## [10,] 4299.432 4298.068 4305.074 4304.426 4310.316 4311.291 4309.772 4311.478
## [11,] 4189.884 4191.828 4195.545 4192.565 4194.256 4197.389 4193.723 4190.850
## [12,] 3613.288 3615.293 3613.460 3613.333 3611.626 3616.497 3616.876 3617.810
## [13,] 3738.553 3742.223 3740.398 3738.478 3737.155 3743.671 3745.393 3740.822
## [14,] 4199.029 4202.256 4201.771 4197.309 4196.551 4201.691 4197.464 4200.013
## [15,] 3996.192 4001.800 4000.457 4000.204 4002.951 4003.225 4004.332 4007.015
## [16,] 3973.069 3978.348 3974.939 3972.102 3973.003 3972.777 3970.171 3971.075
## [17,] 3969.304 3969.021 3971.798 3965.975 3967.319 3971.389 3966.600 3967.404
## [18,] 3589.615 3588.032 3588.989 3584.089 3586.862 3590.894 3588.108 3590.092
## [19,] 3281.549 3281.605 3283.693 3281.683 3278.332 3274.539 3274.141 3283.152
## [20,] 3509.533 3504.776 3498.117 3498.388 3503.388 3503.705 3502.309 3503.728
## [21,] 3485.723 3486.570 3481.063 3479.697 3484.086 3488.804 3484.758 3488.885
## [22,] 5649.317 5647.438 5653.799 5655.752 5656.395 5657.889 5659.950 5654.936
## [23,] 4527.307 4530.053 4534.905 4539.197 4542.780 4539.985 4537.598 4539.106
## [24,] 4430.317 4428.857 4427.381 4430.250 4436.295 4432.203 4429.046 4432.788
## [25,] 4567.351 4566.142 4567.811 4568.548 4572.910 4569.471 4566.320 4571.972
## [26,] 5565.387 5559.946 5556.911 5563.005 5566.270 5559.444 5559.359 5556.546
## [27,] 5223.305 5221.046 5218.006 5221.124 5224.273 5223.688 5221.065 5217.973
## [28,] 4962.098 4967.661 4966.896 4969.867 4977.091 4978.806 4977.460 4973.716
## [29,] 4933.865 4936.748 4935.234 4938.059 4951.965 4953.297 4951.457 4946.342
## [30,] 3565.081 3561.024 3561.058 3554.458 3549.294 3553.159 3548.406 3547.004
## [31,] 3534.709 3530.757 3538.600 3536.990 3530.496 3532.025 3526.396 3534.162
## [32,] 3677.591 3676.406 3683.333 3679.450 3672.984 3681.666 3686.281 3685.140
## [33,] 3886.707 3886.532 3896.147 3887.499 3884.790 3891.167 3891.272 3896.186
## [34,] 4451.360 4449.042 4451.041 4447.691 4446.425 4444.582 4445.203 4445.909
## [35,] 3791.121 3790.674 3794.268 3792.865 3796.169 3800.459 3792.326 3793.249
##           8900     9000     9100     9200     9300     9400     9500     9600
##  [1,] 3758.173 3762.123 3758.816 3759.947 3753.889 3761.069 3760.453 3760.410
##  [2,] 4060.968 4057.729 4056.974 4048.083 4044.502 4037.189 4034.382 4032.064
##  [3,] 3559.460 3552.141 3555.625 3555.449 3553.794 3559.872 3561.603 3560.037
##  [4,] 3702.970 3699.978 3699.012 3698.274 3690.182 3696.358 3691.763 3690.470
##  [5,] 4094.194 4091.250 4088.707 4085.858 4085.436 4083.401 4082.643 4083.513
##  [6,] 3870.970 3869.046 3872.121 3866.109 3867.384 3865.768 3869.547 3867.601
##  [7,] 3721.005 3717.559 3724.088 3723.133 3725.686 3723.554 3724.267 3719.580
##  [8,] 3933.386 3932.574 3937.212 3933.914 3935.727 3930.529 3930.579 3931.057
##  [9,] 3268.837 3268.372 3268.851 3270.974 3272.294 3272.548 3272.888 3262.320
## [10,] 4317.166 4315.751 4318.411 4318.192 4326.639 4327.733 4330.791 4327.070
## [11,] 4195.507 4194.826 4198.159 4199.212 4203.953 4204.583 4203.248 4206.779
## [12,] 3617.724 3619.263 3620.941 3623.737 3625.414 3626.823 3630.035 3622.520
## [13,] 3737.687 3741.647 3743.906 3743.859 3745.371 3741.784 3741.409 3735.966
## [14,] 4202.102 4203.420 4211.280 4206.647 4206.156 4202.790 4204.743 4202.039
## [15,] 4008.889 4009.667 4019.169 4009.027 4005.913 4005.025 4006.885 4013.704
## [16,] 3973.062 3972.605 3980.343 3976.373 3972.971 3970.711 3974.158 3978.695
## [17,] 3970.596 3978.300 3977.748 3982.186 3982.180 3980.955 3981.486 3981.970
## [18,] 3589.255 3593.669 3592.821 3592.537 3592.796 3594.408 3599.771 3599.712
## [19,] 3282.364 3277.331 3274.169 3274.345 3272.168 3278.624 3281.319 3280.305
## [20,] 3501.801 3503.681 3498.954 3496.307 3494.201 3494.708 3497.385 3494.874
## [21,] 3488.194 3487.240 3489.064 3486.448 3487.592 3487.081 3494.322 3495.461
## [22,] 5653.931 5656.232 5654.639 5664.105 5664.909 5669.619 5672.998 5672.166
## [23,] 4542.841 4542.694 4541.321 4543.360 4546.670 4546.845 4551.467 4552.768
## [24,] 4432.568 4432.302 4430.212 4428.853 4428.622 4425.877 4430.342 4430.532
## [25,] 4572.354 4571.864 4571.293 4571.348 4573.979 4571.364 4575.871 4576.672
## [26,] 5560.186 5559.177 5554.789 5552.837 5554.723 5553.162 5553.660 5551.205
## [27,] 5218.400 5218.480 5222.292 5221.944 5220.761 5221.121 5222.757 5226.197
## [28,] 4973.406 4970.280 4974.627 4977.769 4973.278 4970.259 4976.550 4978.422
## [29,] 4944.142 4943.456 4948.426 4951.745 4947.348 4948.422 4952.000 4954.001
## [30,] 3540.481 3537.275 3536.283 3534.822 3535.497 3531.437 3528.650 3531.704
## [31,] 3536.117 3533.172 3535.280 3540.529 3527.728 3535.633 3530.271 3533.982
## [32,] 3686.876 3679.116 3679.118 3675.969 3676.339 3681.139 3673.970 3673.677
## [33,] 3901.075 3894.844 3896.154 3897.853 3897.901 3903.883 3902.797 3902.233
## [34,] 4446.391 4450.023 4455.882 4454.838 4455.482 4452.309 4452.476 4461.119
## [35,] 3794.151 3798.416 3801.944 3801.649 3804.551 3804.951 3801.903 3808.149
##           9700     9800     9900    10000
##  [1,] 3760.146 3765.593 3764.561 3763.213
##  [2,] 4038.127 4039.312 4037.299 4034.754
##  [3,] 3564.896 3565.197 3566.939 3570.881
##  [4,] 3687.824 3689.191 3695.713 3697.701
##  [5,] 4085.488 4089.351 4088.829 4090.588
##  [6,] 3861.749 3867.479 3870.159 3866.471
##  [7,] 3713.966 3716.252 3718.207 3720.654
##  [8,] 3927.272 3931.548 3932.224 3932.859
##  [9,] 3258.436 3261.944 3265.025 3264.980
## [10,] 4325.080 4332.036 4337.163 4335.559
## [11,] 4205.200 4208.727 4208.826 4207.726
## [12,] 3617.872 3623.358 3623.131 3627.140
## [13,] 3729.974 3732.311 3733.420 3727.120
## [14,] 4202.613 4201.837 4202.175 4199.165
## [15,] 4017.215 4019.028 4021.599 4017.514
## [16,] 3977.402 3979.790 3982.443 3977.743
## [17,] 3978.487 3981.866 3982.216 3984.249
## [18,] 3597.770 3594.468 3595.717 3598.330
## [19,] 3277.097 3275.790 3272.107 3272.813
## [20,] 3491.914 3496.509 3493.716 3488.782
## [21,] 3490.849 3488.846 3490.566 3498.100
## [22,] 5673.316 5674.112 5672.801 5679.603
## [23,] 4559.607 4557.504 4558.321 4554.829
## [24,] 4432.231 4431.697 4429.845 4424.632
## [25,] 4577.741 4576.649 4575.111 4570.708
## [26,] 5549.421 5551.100 5550.261 5551.850
## [27,] 5225.856 5224.559 5226.581 5224.599
## [28,] 4973.158 4975.222 4977.701 4980.158
## [29,] 4951.263 4955.666 4953.758 4957.293
## [30,] 3527.030 3522.450 3517.515 3514.171
## [31,] 3530.116 3529.925 3531.640 3534.556
## [32,] 3670.384 3672.621 3675.567 3679.405
## [33,] 3896.070 3897.230 3902.390 3909.742
## [34,] 4465.167 4460.002 4462.746 4462.272
## [35,] 3804.734 3801.678 3803.250 3805.095
dim(predmat)
## [1]  35 100
err <- apply((predmat - penguins_test$body_mass_g)^2, 2, mean) 
plot(ntree, err, type = 'l', col = 2, lwd = 2, xlab = "n.trees", ylab = "Test MSE")

Looking at the between 2000 and 0 is where the model got the lower amount of errors, reducing the analysis to 2,000 may be beneficial for the model.
6. Now create a random forest of 10,000 trees to predict the body mass of a penguin. Be sure to provide the instructor with the output that you use to answer each part of this question below. Model

library(randomForest)
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
peg_rf <- randomForest(body_mass_g~., data = penguins_train, importance = TRUE, ntree = 10000) 
peg_rf
## 
## Call:
##  randomForest(formula = body_mass_g ~ ., data = penguins_train,      importance = TRUE, ntree = 10000) 
##                Type of random forest: regression
##                      Number of trees: 10000
## No. of variables tried at each split: 2
## 
##           Mean of squared residuals: 105617.4
##                     % Var explained: 83.96
  1. Based on the percent of variation explained by the model, do you believe that the random forest fits your data well?
    Yes, a % of variation explained of 83.7% is a good model.
  2. What is the out-of-bag error for the random forest?
    OOB error = 102142.9
  3. What are the two most important covariates in your random forest model?
peg_rf$importance
##                      %IncMSE IncNodePurity
## species           403395.390      52003539
## island            111422.623      14388719
## bill_length_mm    109242.862      25273628
## bill_depth_mm     111930.537      36782976
## flipper_length_mm 391887.781      61550555
## year                4340.058       2421040

The most important covarient that it is the most imprtant is flipper_length_mm with 60746570 IncNodePurity followed by specie.
d) Use the testing set to calculate the MSE for your random forest model. Based on your results, is the random forest more accurate than the boosting model? Or is your boosting model more accurate than your random forest?

Prediction

peg_pred <- predict(peg_rf, penguins_test)
mean((penguins_test$body_mass_g - peg_pred)^2)
## [1] 114386.1

The Random florest has a smaller error on prediction being a better model. Prediction error = 147461.6 for the testing set what is lower than boosting making the random florest model better.
e) Create a graph comparing the out-of-bag error to the number of trees used in the random forest model. Based on this graph, does it appear that a large number of trees are needed to develop a fairly accurate random forest model?

The following model show the out-of-bag error and the number of tree used. from very early the number gets close to 100000 and slightly change. Looking at the chart the large amount of trees is not needed.

plot(peg_rf$mse, type = 'l', col = 2, lwd = 2, xlab = "ntree", ylab = "OOB Error")