R: Correlation and regression

PDF Copy of the Correlation and regression notes

We’ve been learning about different aspects of R – how to bring data in, how to clean the data, and how to graph the data.  Providing us with the basics of manipulating our data and visualizing it.  Remember though that R is a system that is used for statistical computation as well as graphics.  What makes is a robust system is that it includes a programming language, graphics, interfaces or connection opportunities with other languages, and debugging capabilities.  Although we can use R for many different purposes we can also use it for our statistical needs.

To start the statistical side of things, today we will see how we can use R to create correlations and regressions with our data.  We will use Fisher’s Iris dataset as the sample data to take us through correlations and regressions.

Download the R Script file used to work through this section of the R program.

Let’s work through the R script file in R Studio.  I will add tricks and tips that I’ve learned in the sample at a later date.  Please note that the R-script file contains comments throughout to guide you through it.


3 thoughts on “R: Correlation and regression”

  1. Dear Sir/Madam,
    Thank you very much for your support. Sir, please help me. I am doing MSc. thesis research on the effect of tree management on soil physicochemical properties and maize yield. Here, I have three factorial arrangements and three replication with RCBD design such as; Fact-I: Tree Management(pruning, pollardig, and control), Fact-II: distance from a tree trunk (near the tree trunk, edge of the canopy, and open field), and Fact-III: soil depth (0-20cm and 21-40cm). So, I would like to analyze ANOVA and LSD tests. How to analyze this in R software?

    1. Good evening, I would recommend that you talk to someone at your academic institution for assistance. To conduct this analysis – I am a strong proponent for creating a statistical model where you identify the sources of variation in your trial – this forms the basis for your analysis. Write out your statistical model – identify which components are fixed and random. If you have mixed model (fixed and random effects) then you will need to use lmer() in R – review https://oacstats.ca/2018/05/21/r-anova-with-an-rcbd/ for more help.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: