Final Assignmnt Stat Kamii
Final Assignmnt Stat Kamii
library(psych)
cor.test(Iris[-5])
View(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 Setosa
2 4.9 3.0 1.4 0.2 Setosa
3 4.7 3.2 1.3 0.2 Setosa
4 4.6 3.1 1.5 0.2 Setosa
5 5.0 3.6 1.4 0.2 Setosa
6 5.4 3.9 1.7 0.4 Setosa
7 4.6 3.4 1.4 0.3 Setosa
8 6.4 3.2 4.5 1.5 Versicolor
9 6.9 3.1 4.9 1.5 Versicolor
10 5.5 2.3 4.0 1.3 Versicolor
11 6.5 2.8 4.6 1.5 Versicolor
12 5.7 2.8 4.5 1.3 Versicolor
13 6.3 3.3 4.7 1.6 Versicolor
14 5.8 2.7 5.1 1.9 Virginica
15 6.8 3.2 5.9 2.3 Virginica
16 6.7 3.3 5.7 2.5 Virginica
17 6.7 3.0 5.2 2.3 Virginica
18 6.3 2.5 5.0 1.9 Virginica
x<-corr.test(iris[-5])
print(iris-data)
# Calculate the correlation matrix
correlation_matrix<- cor(iris-data)
Call:corr.test(x = iris[-5])
Correlation matrix
Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length 1.00 -0.12 0.87 0.82
Sepal.Width -0.12 1.00 -0.43 -0.37
Petal.Length 0.87 -0.43 1.00 0.96
Petal.Width 0.82 -0.37 0.96 1.00
Sample Size
[1] 150
Probability values (Entries above the diagonal are adjusted for multiple tests.)
To see confidence intervals of the correlations, print with the short=FALSE option
Interpretation:
1. 1 indicates a perfect positive correlation.
2. -1 indicates a perfect negative correlation.
3. 0 indicates that there is no relationship between the different variables.