1 / 11

BIO503: Tutorial 3 Solutions

BIO503: Tutorial 3 Solutions. Harvard School of Public Health Wintersession 2009. Solar Radiation Data. 1A. Assign the data to an object called solar.radiation. > solar.radiation <- c(11.1, 10.6, 6.3, 8.8, 10.7, 11.2, 8.9, 12.2)

Download Presentation

BIO503: Tutorial 3 Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BIO503: Tutorial 3 Solutions Harvard School of Public Health Wintersession 2009

  2. Solar Radiation Data 1A. Assign the data to an object called solar.radiation. > solar.radiation <- c(11.1, 10.6, 6.3, 8.8, 10.7, 11.2, 8.9, 12.2) 1B. Find the mean, median, and variance of the radiation observations. > mean(solar.radiation) > median(solar.radiation) > variance(solar.radiation)

  3. 1C. Add 10 to solar.radiation > sr10 <- solar.radiation + 10 Find the mean, median, variance of sr10. > mean(sr10) > median(sr10) > variance(sr10) The mean and median values change but the variance remains the same as that for the solar.radiation data.

  4. 1D. Multiple solar.radiation by -2 1D. Multiply each observation by -2: > srm2 <- solar.radiation*(-2) > mean(srm2) > median(srm2) > variance(srm2) The mean, median and variance values of srm2 are different from those for solar.radiation.

  5. 1E. Histograms Plot of histogram of solar.radiation, sr10 and srm2. > win.graph(32,16) > par(mfrow=c(1,3)) > hist(solar.radiation, main="solar.radiation", col="blue") > hist(sr10, main="sr10", col="gold") > hist(srm2, main="srm2", col="purple")

  6. 1F. Make a scatter plot > plot(solar.radiation, ylab="solar radiation observed", main="solar radiation data for tutorial 3") > date <- 1:8 > lmObj <- lm(solar.radiation ~ date)

  7. 1G. Add a fitted line > plot(date, solar.radiation, ylab="solar radiation observed", xlab="date", main="solar radiation data for tutorial 3") > abline(lmObj, lwd=3, col="green", lty=2)

  8. 1H. Which variance formula? Compute each of the quantities: The first formula: > n <- length(solar.radiation) > formula1 <- (1/n)*sum((solar.radiation - mean(solar.radiation))^2) The second formula: > formula2 <- (1/(n-1))*sum((solar.radiation - mean(solar.radiation))^2) > var(solar.radiation) == formula1 > var(solar.radiation) == formula2 R uses the sample variance (formula2) formula for the var function.

More Related