Homework on Multiple Linear Regressions

Added on - 21 Apr 2020

  • 11

    pages

  • 5362

    words

  • 6

    views

  • 0

    downloads

Showing pages 1 to 4 of 11 pages
HOMEWORKMultiple Linear Regressions in RQuestion 1: Continuation of Birds DataIn class we performed a multiple regression on {pop90_00 ~ log_bodsize + farmland +bred_lat + mig_date + log_popsize + broods + log_migdist + dichrom}and through astepwise model selection process found that the model {pop90_00 ~ log_bodsize +mig_date}performed better. What happens if we used pop70_90 as the responsevariable?Substitute pop70_90 as your response variable and follow the process described in theexplanation document to answer the following questions:R codesStep one:to load data into R and organize it>#loading data in R> Trend.in.mean.migration.date=c(-0.032, -0.157, -0.06, -0.116, -0.291, -0.099, -0.461,0.136, -0.346, -0.312, -0.13, -0.049, -0.05, -0.056, -0.154, 0.034, 0.116, -0.368, -0.286,0.238, 0.006, -0.193, -0.44, -0.954, -0.36, -0.215, -0.816, 0.266, -0.474, -0.325, 0.026, -0.205, 0.063, -0.249, -0.302, -0.118, -0.14, -0.156, 0.009, 0.251, -0.033, -0.033, -0.174,0.141, -0.01, -0.502, -0.333, -0.492, 0.129, -0.018, -0.084, -0.045, 0.028, -0.532, -0.13, -0.208, -0.075, -0.014, -0.056, 0.021, -0.069, -0.252, -0.313, 0.019, -0.377, -0.068, -0.18,0.272, -0.048, -0.722, -0.098, -0.06, -0.153, -0.303, -0.156, 0.015, -0.03, 0.622, 0.085, -0.167, 0.016, -0.102, -0.119, -0.118, 0, 0.134, -0.194, -0.024, -0.228, -0.208, -0.314, -0.192, -0.05, -0.061, -0.415, -0.061)> Population.trend.1970.1990=c(3, 0, 0, 0, -3, -3, 0, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -2,0, 0, 3, 0, 3, 0, 0, 3, 2, 0, 0, -3, 0, 0, 0, 0, 0, 0, -3, 3, 0, -2, -2, -2, 3, 3, 0, 3, 0, 0, 0, 0, 0, 2,0, 0, 0, -2, 0, 0, 0, 3, 0, 0, -3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, -2, 0,0, 0, 0, 0, 0, 0, 0)> Population.trend.1990.2000=c(1, 0, 0, 0, -1, -2, -1, 3, -1, -1, -1, -1, 0, -2, 1, 0, -2, 1, 0,0, 0, -1, 0, 2, 1, 0, 0, -1, 3, 3, -2, -1, -1, -1, 1, -1, 0, 0, -2, -3, -2, -1, -1, -2, -1, 2, 3, 3, -2, 0,0, 0, -2, 0, -1, -1, 0, -1, -1, -2, 0, 0, 3, -2, 1, 0, 0, -2, -1, 0, -2, -1, 0, 0, 0, -1, 1, 0, -2, 1, 0,1, 0, 0, 0, -2, 0, -2, 1, 0, 1, 0, 0, 0, 0, -3)> No..of.broods=c(1, 1, 2, 1, 4, 1, 1, 1, 3, 2, 3, 1, 1, 1, 1, 1, 3, 3, 2, 1, 1, 3, 1, 4, 3, 1, 1, 1,1, 1, 2, 3, 1, 2, 3, 1, 2, 2, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 2, 2, 2, 2, 1, 1,3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 4, 4, 2, 2, 3, 1)> Natal.dispersal=c(15.6, NA, 40.4, 47, 5.5, NA, 19.9, NA, 0.9, NA, NA, 36.8, NA, NA,NA, NA, 4.4, 11.1, 4.2, NA, NA, NA, NA, 10.4, 10.7, 9.9, 8.6, NA, NA, 34.3, 10.4, 8.4,NA, 5.4, 6, 20.6, 3.6, NA, NA, NA, NA, NA, 14.1, NA, NA, NA, 28.2, NA, 47, NA, NA,NA, NA, NA, NA, NA, 16.1, 12.5, 12.8, 18.9, 5.3, 5.3, NA, NA, NA, 12.2, NA, 20, 20.8,NA, NA, NA, 2.1, 4.6, NA, 0.5, NA, NA, 9.5, 41.2, NA, 14.4, 32.3, NA, NA, NA, NA,NA, 8.9, NA, 3.3, 7, NA, NA, 8.3, NA)
> Farmland.breeding.habitat=c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,1)> Habitat.specialization=c(NA, NA, NA, NA, 1.32, NA, NA, NA, 0.69, NA, 0.46, NA,NA, NA, NA, NA, 0.63, 0.56, 0.52, NA, NA, NA, NA, 0.68, 0.19, 0.32, 0.55, 0.27, NA,NA, 0.89, 0.54, NA, NA, 0.25, NA, 0.51, NA, NA, NA, NA, NA, 0.88, NA, 0.67, NA,NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.47, NA, NA, NA, 0.44, 0.36, NA, NA,0.89, 0.78, 0.41, 2.09, 0.65, NA, NA, NA, 0.38, 0.71, 1.09, 0.79, NA, NA, 0.4, 0.32, 0.34,0.54, 0.51, NA, NA, NA, NA, NA, 0.41, NA, 0.21, 0.4, NA, NA, 0.44, NA)> Thermal.maximum=c(NA, NA, NA, NA, 20.08, NA, NA, NA, 16.97, NA, 19.55, NA,NA, NA, NA, NA, 20.54, 20.59, 20.51, NA, NA, NA, NA, 19.24, 20.26, 20.46, 20.4,20.46, NA, NA, 20.55, 19.35, NA, NA, 20.42, NA, 20.57, NA, NA, NA, NA, NA, 20.52,NA, 20.2, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 20.24, NA, NA, NA,20.57, 20.47, NA, NA, 19.93, 19.7, 19.87, 18.92, 17.7, NA, NA, NA, 19.05, 18.87, 18.86,19.44, NA, NA, 19.96, 20.49, 19.39, 20.35, 19.71, NA, NA, NA, NA, NA, 20.4, NA,20.52, 19.69, NA, NA, 20.09, NA)> Migration.distance=c(12.79, 66.84, 62.1, 44.6, 13.01, 26.72, 8.12, 12.28, 15.64, 21.27,47.07, 59.39, 63.88, 17.08, 9.66, 43.12, 4.11, 1.16, 1.34, 24.22, 0.7, 2.56, 15.78, 3.45,2.03, 5.71, 0.29, 49.38, 9.29, 1.08, 44.25, 4.72, 36.48, 10.52, 5, 43, 5.54, 13.75, 7.05,10.57, 21.39, 71.34, 42.34, 35.2, 64.72, 22.14, 34.34, 7.28, 23.5, 59.92, 63.1, 25.5, 2.55,16.1, 4.89, 11.05, 18.12, 40.98, 64.4, 38.17, 0, 0, 2.63, 52.2, 15.83, 33.93, 22.55, 52.74,68.09, 20.49, 4.4, 7.87, 9.23, 0, 0, 34.84, 3.34, 52.75, 2.63, 19.63, 63.25, 53.05, 27.79,9.35, 62.89, 44.39, 49.16, 35.28, 1.34, 10.77, 3.98, 14.65, 10.77, 14.13, 4.36, 12.08)> Wintering.in.Africa=c(0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0)> Winter.habitat=c(1, 3, 3, 3, 2, 4, 3, 3, 2, 3, 1, 5, 4, 3, 3, 3, 2, 2, 5, 1, 4, 4, 4, 1, 1, 2, 2, 1,3, 3, 5, 2, 2, 3, 5, 1, 2, 1, 3, 4, 4, 2, 5, 5, 2, 4, 4, 4, 4, 4, 1, 3, 4, 4, 3, 4, 2, 2, 1, 2, 1, 1, 3, 3,5, 1, 1, 1, 1, 2, 4, 4, 2, 1, 1, 2, 4, 4, 2, 1, 1, 2, 2, 4, 3, 3, 3, 3, 1, 1, 5, 1, 2, 2, 2, 2)> Northernmost.breeding.latitude=c(70, 63.93, 70.63, 64.64, 71.16, 70.63, 71.09, 71.11,71.17, 75, 70.5, 70, 83.33, 70.16, 70.31, 71.25, 66, 63.57, 70.31, 67.67, 81.75, 83.33,82.22, 65, 67.33, 71.17, 66.36, 70.47, 70, 62.41, 70.33, 70.44, 67.5, 71.18, 70, 70.67,71.25, 71.25, 71.25, 73.28, 71.25, 70, 70.38, 69.5, 66.33, 71.25, 71.25, 79.31, 68, 70.31,65, 71.17, 70.63, 74.53, 71.25, 73.2, 71.17, 70.67, 70.5, 71.17, 67.33, 70.67, 71.27, 71.25,60.36, 70.5, 70.29, 68.33, 71.18, 83, 66, 67.67, 70.67, 70.31, 70.29, 70, 80.83, 71.25,71.25, 70.1, 70.31, 69.33, 69.67, 66.17, 70.78, 71.25, 70.31, 71.09, 69.33, 71.17, 71.17,70.33, 71.17, 71.17, 69, 70.16)> Sexual.dichromatism=c(1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1)
> Brain.mass..g.=c(2.92, 0.52, NA, 0.58, 0.97, NA, 5.82, 11.91, 0.36, 0.58, 0.68, 0.69,NA, 4.36, NA, NA, 0.67, 0.59, 0.89, NA, NA, NA, NA, 2.27, 2.38, 8.14, 4.69, 2.24, NA,NA, 0.59, 0.82, NA, 0.68, 0.66, 0.45, 0.77, 0.78, 1.35, NA, NA, 0.54, 0.58, NA, 1, 6.43,NA, NA, 2.88, NA, NA, NA, NA, NA, NA, NA, 0.58, 0.47, 0.53, 0.72, 0.65, 0.85, NA,NA, 0.61, 0.54, 0.38, NA, 0.31, NA, NA, NA, 0.71, 0.89, 0.38, 0.67, 7.92, NA, 1.7, 0.67,0.62, 0.56, 0.53, 4.74, NA, NA, NA, 1.42, 0.5, 1.45, 1.92, 1.59, 1.85, 1.87, 2.21, 2.16)> Body.mass..g.=c(204, 12, 11.9, 11.8, 36.4, 917, 1119, 3464.5, 19.2, 21.5, 23.4, 39.6,107.5, 656.5, 840.3, 26.1, 18.9, 15.6, 27.6, 23.4, 394.5, 63.2, 722.5, 314.5, 494.5, 544.5,249, 120.5, 11375, 10750, 19.5, 26.8, 20.6, 18.8, 16.4, 14.3, 24.2, 22.6, 106.5, 2804.5,531, 13.3, 19.1, 37.3, 30.7, 895, 817.5, 1599.5, 280.5, 301, 25, 18.2, 1587.5, 1306.5,1641.5, 1090.5, 20.8, 17.4, 15.5, 24, 11.8, 18.5, 2254, 140.5, 16, 15.9, 7.7, 9.1, 9.3, 37.4,875, 829.8, 19, 31, 5.8, 16.6, 2066.5, 125, 80.5, 18.9, 19, 14.5, 12.4, 1152, 67.5, 47.8,173.5, 112, 8.9, 62.8, 95.8, 70.5, 92.1, 117, 117.8, 218.5)> European.breeding.population..pairs.x.10.5.=c(3.95, 50, 59, 38.5, 600, 3.4, 42, 1.55,115, 15.2, 345, 119.5, 0.58, 8.05, 5.4, 2.53, 190, 205, 230, 45.5, 2.15, 1.7, 7.2, 6.25, 130,120, 101, 64, 0.19, 1.03, 169.5, 245, 106, 68, 630, 160, 1850, 175, 14.15, 0.72, 3.75, 53,260, 9.4, 96.5, 15.25, 3.25, 1.45, 18.5, 0.04, 53, 61.5, 0.93, 1.15, 0.61, 0.97, 195, 109.5,180, 88, 320, 685, 3.4, 3.55, 64, 114, 454.45, 180, 780, 11.9, 3.75, 0.44, 190, 106.5, 270,77, 10.2, 4.2, 395, 370, 240, 195, 63, 0.54, 7.75, 11.6, 1.18, 4.45, 315, 185, 610, 280, 190,4.9, 52, 22.5)> #making data into data frame>birds=cbind(Trend.in.mean.migration.date,Population.trend.1970.1990,Population.trend.1990.2000, No..of.broods, Natal.dispersal, Farmland.breeding.habitat,Habitat.specialization, Thermal.maximum, Migration.distance, Wintering.in.Africa,Winter.habitat, Northernmost.breeding.latitude, Sexual.dichromatism, Brain.mass..g.,Body.mass..g., European.breeding.population..pairs.x.10.5.)> birds=as.data.frame(birds)Step two: Extracting important data from extracted data> #Extracting relevant information> log_migdist <- log10(birds$Migration.distance+1)> log_popsize <- log10(birds$European.breeding.population..pairs.x.10.5.)> log_bodsize <- log10(birds$Body.mass..g)> farmland <- birds$Farmland.breeding.habitat> dichrom <- birds$Sexual.dichromatism> broods <- birds$No..of.broods> mig_date <- birds$Trend.in.mean.migration.date> pop70_90 <- birds$Population.trend.1970.1990> pop90_00 <- birds$Population.trend.1990.2000> habitat <- birds$Habitat.specialization> winter <- birds$Winter.habitat
> bred_lat <- birds$Northernmost.breeding.latitudeStep three:Running multiple regression line and simple regression> # Running simple regression> fit1<-lm(pop70_90 ~ mig_date)> #Running multiple regression> fit<-lm(pop70_90 ~ log_bodsize + farmland + bred_lat + mig_date + log_popsize +broods + log_migdist + dichrom)> #output of regression models> summary(fit1)Call:lm(formula = pop70_90 ~ mig_date)Residuals:Min 1Q Median 3Q Max-3.3736 -0.4039 -0.1175 0.0774 3.2273Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) -0.0359 0.1673 -0.215 0.8305mig_date -1.4072 0.6336 -2.221 0.0288 *---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 1.403 on 94 degrees of freedomMultiple R-squared: 0.04986, Adjusted R-squared: 0.03975F-statistic: 4.933 on 1 and 94 DF, p-value: 0.02875> summary(fit)Call:lm(formula = pop70_90 ~ log_bodsize + farmland + bred_lat + mig_date +log_popsize + broods + log_migdist + dichrom)Residuals:Min 1Q Median 3Q Max-3.9308 -0.4317 0.1438 0.4943 2.6227Coefficients:
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document