Original link: http://tecdat.cn/?p=9484
table of Contents
Introduction
Below is an example of species diversity shows how the correlation analysis and linear regression analysis in the R language.
How to do the test
Correlation and linear regression examples
Simple graph data
Correlation
You can use cor.test function. It can perform Pearson, Kendall and Spearman correlation.
Pearson correlation
Pearson correlation is related to the most common form. Assumed that the data are linearly related, and the residuals were normally distributed.
Kendall related
Kendall's rank correlation is a nonparametric test, it is not assumed that the distribution of data or data are linearly related. It ranked data to determine the degree of correlation.
Spearman
Spearman rank correlation is a nonparametric test, it is not assumed that the distribution of data or data are linearly related. It sorts the data to determine the degree of correlation, and in order for the measurement.
Linear Regression
Linear regression can be used lm perform the function. You can use lmrob perform robust regression function.
Draw linear regression
Check the model assumptions
Linear Model residuals histogram. These residuals should be approximately normally distributed.
Graph of residuals versus predicted values. Residuals should be unbiased and evenly.
Robust Regression
The linear regression is not sensitive to outliers in the response variable.
Drawing model
Examples of linear regression
Power Analysis
Correlation power analysis