R_mhw - Tutorial: Using the R Environment for Statistical...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Tutorial: Using the R Environment for Statistical Computing An example with the Mercer & Hall wheat yield dataset D G Rossiter University of Twente, Faculty of Geo-Information Science & Earth Observation (ITC) Enschede (NL) April 19, 2010 Contents 1 Introduction 1 2 R basics 1 2.1 Leaving R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3 Loading and examining a data set 7 3.1 Reading a CSV file into an R object . . . . . . . . . . . . . . . 7 3.2 Examining a dataset . . . . . . . . . . . . . . . . . . . . . . . . 8 3.3 Saving a dataset in R format . . . . . . . . . . . . . . . . . . . 11 3.4 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4 Exploratory graphics 12 4.1 Univariate exploratory graphics . . . . . . . . . . . . . . . . . . 13 4.1.1 Enhancing the histogram* . . . . . . . . . . . . . . . . . 14 4.1.2 Kernel density* . . . . . . . . . . . . . . . . . . . . . . . 15 4.1.3 Another histogram enhancement: colour-coding rela- tive frequency* . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 Bivariate exploratory graphics . . . . . . . . . . . . . . . . . . . 18 4.3 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Version 1.8. Copyright © 2006–2010 D G Rossiter. All rights reserved. Reproduction and dissemination of the work as a whole (not parts) freely permitted if this original copyright notice is included. Sale or placement on a web site where payment must be made to access this document is strictly prohibited. To adapt or translate please contact the author ( http://www.itc.nl/ personal/rossiter ).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
5 Descriptive statistics 22 5.1 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 6 Editing a data frame 25 6.1 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7 Introduction to modelling 27 8 Univariate modelling 27 8.1 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 9 Bivariate modelling: continuous variables 33 9.1 Correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 9.2 Univariate linear regression . . . . . . . . . . . . . . . . . . . . 40 9.2.1 Fitting a regression line . . . . . . . . . . . . . . . . . . 41 9.2.2 Regression diagnostics . . . . . . . . . . . . . . . . . . . 44 9.3 Structural Analysis* . . . . . . . . . . . . . . . . . . . . . . . . 49 9.4 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 10 Bivariate modelling: continuous vs. classified variables 57 10.1 Exploratory data analysis . . . . . . . . . . . . . . . . . . . . . 59 10.2 Two-sample t-test . . . . . . . . . . . . . . . . . . . . . . . . . . 61 10.3 One-way ANOVA . . . . . . . . . . . . . . . . . . . . . . . . . . 62 10.4 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 11 Multivariate modelling 64 11.1 Additive model: parallel regression . . . . . . . . . . . . . . . . 66 11.2 Comparing models . . . . . . . . . . . . . . . . . . . . . . . . . 67 11.3 Interaction model . . . . . . . . . . . . . . . . . . . . . . . . . . 69 11.4 Regression diagnostics . . . . . . . . . . . . . . . . . . . . . . . 71 11.5 Analysis of covariance: a nested model . . . . . . . . . . . . . . 75 11.6 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 12 Spatial analysis 79 12.1 Geographic visualisation . . . . . . . . . . . . . . . . . . . . . . 79 12.2 Setting up a co¨ordinate system . . . . . . . . . . . . . . . . . . 83 12.3 Loading add-in packages . . . . . . . . . . . . . . . . . . . . . . 84 12.4 Creating a spatially-explicit object . . . . . . . . . . . . . . . . 85 12.5 More geographic visualisation . . . . . . . . . . . . . . . . . . . 86 12.6 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 13 Spatial structure 88 13.1 Spatial structure: trend . . . . . . . . . . . . . . . . . . . . . . . 88 13.2 Spatial structure: local . . . . . . . . . . . . . . . . . . . . . . . 91 13.3 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 14 Absence of spatial structure* 94 14.1 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 15 Spatial structure of field halves 97 ii
Background image of page 2
15.1 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 16 The effect of plot size 100 16.1 Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 17 Wrapup 112 References 113 Index of R concepts 116 A Example Data Set 118 B Colours 119 iii
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1 Introduction This tutorial introduces the R environment for statistical computing and visualisation [ 8 , 19 ] and its dialect of the S language . It is organized as a systematic analysis of a simple dataset: the Mercer & Hall wheat yield uniformity trial (Appendix A ). After completing the tutorial you should: ˆ know the basics of the R environment; ˆ be able to use R at a beginning to intermediate level; ˆ follow a systematic approach to analyze a simple dataset. The tutorial is organized as a set of tasks followed by questions to check your understanding; answers are at the end of each section. If you are am- bitious, there are also some challenges : tasks and questions with no solution provided, that require the integration of skills learned in the section.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/12/2010 for the course APPLIED ST 2010 taught by Professor Various during the Spring '10 term at Universidad Nacional Agraria La Molina.

Page1 / 124

R_mhw - Tutorial: Using the R Environment for Statistical...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online