In: Statistics and Probability
The following data indicates the daily high, in °F, for a given day and the number of cars sold that day. Use R to construct a scatter plot of the data. Does there appear to be a linear correlation? What kind?
x (65, 75, 71, 83, 79, 77, 86, 90, 86, 93, 95, 94) Temp
y (7, 8, 7, 8, 9, 7, 5, 3, 7, 4, 3, 3) Cars sold
to do the program here is the R code
x <- c(65,75,71,83,79,77,86,90,86,93,95,94) #__temp___#
y <- c(7,8,7,8,9,7,5,3,7,4,3,3)#----cars sold---#
plot(x,y,main = "scatterplot of temp vs cars sold",xlab =
"temp",ylab ="cars sold") # scatterplot#
abline(lm(y~x),col="blue") # add regression line#
cor(x,y) #correlation coefficient#
-0.7512651
now from scatterplot we can see there is a linear relationship between x & y. as x increases the values of y decreases. hence the relationship is negative.
also for being sure we calculate the correlation coefficient of x & y which is -0.7512651 so it also indicates that the relationship between the two variables is negative. because correlation coefficient lies between -1 to +1 and negative values indicates negative linear relation and positive value indicates positive relation between the variables.
so x & y has a linear relation and this is a negative relation.