R - Program
R - Program
R - Program
Correlation Test
Problem: The following data gives the marks obtained by 12 students
in statistics and mathematics:
Students 1 2 3 4 5 6 7 8 9 10 11 12
Statistics 2 3 3 5 6 9 14 15 19 21 22 23
Mark s mathematics 23 24 24 23 17 28 38 34 35 39 41 43
cor.test(statistics,mathematics)
data: x and y
t = 7.8756, df = 10, p-value = 1.35e-05
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.7575203 0.9799783
sample estimates:
cor
0.9279869
Interpretation:-
The correlation coefficient between the two vectors turns out to be
0.9279869.
The test statistic turns out to be 7.8756 and the corresponding p-value is
1.35e-05.
Since this value is less than .05, we have sufficient evidence to say that
the correlation between the two variables is statistically significant.
EX-03
Linear Regression Model
Problem:-
Obtain a linear relationship between weight (kg) and height (cm) of 10 subjects.
Height 151 174 138 186 128 136 179 163 152 131
Weight 63 81 56 91 47 57 76 72 62 48
Residuals:
Min 1Q Median 3Q Max
-6.3002 -1.6629 0.0412 1.8944 3.9775
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -38.45509 8.04901 -4.778 0.00139 **
x 0.67461 0.05191 12.997 1.16e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Interpretation:-
The fitted regression equation is:
weight =-38.45509+0.67461*Height
weight =-38.45509+0.67461*(170)
weight =76.22
This is the p-value associated with the model coefficients. Since the p-
value for Height (1.164e-06) is significantly less than .05, we can say that
there is a statistically significant association between Height and weight.
The F-statistic (168.9) and the corresponding p-value (1.164e-06) tell us
the overall significance of the regression model.