Professional Documents
Culture Documents
Lanka jaswanth
19BIT0061
Statistics for Engineering
MAT2001
EXPERIMENT-2
> #Correlation
> X=c(21,23,30,54,57,58,72,78,87,90)
> Y=c(60,71,72,83,110,84,100,92,113,135)
> MX=mean(X)
> MX
[1]57
> MY=mean(Y)
> MY
[1]92
> SDX=sqrt(var(X))
> SDY=sqrt(var(Y))
> SDX
[1] 25.48638
> SDY
[1] 22.82299
> cov(X,Y)
[1] 510.4444
> Cor
[1] 0.8775417
> Cor1=cor(X,Y)
> Cor1
[1] 0.8775417
> Cor2=cor.test(X,Y)
> Cor2
data: X and Y
0.5540299 0.9707861
sample estimates:
cor
0.8775417
> X=c(10,15,12,17,13,16,24,14,22)
> Y=c(30,42,45,46,33,34,40,35,39)
> n=length(X)
> U=rank(X)
> V=rank(Y)
> rankcor=1-((6*sumD2)/(n*(n^2-1)))
> rankcor
[1] 0.4
> #Linearregression
> X=c(4.7,8.2,12.4,15.8,20.7,24.9,31.9,35.0,39.1,38.8)
> Y=c(4.0,8.0,12.5,16.0,20.0,25.0,31.0,36.0,40.0,40.0)
> Reg=lm(X~Y)
> Reg
Call:
lm(formula = X ~ Y)
Coefficients:
(Intercept) Y
0.7508 0.9634
> X2=c(11,10,7,15,19,12,8,14)
> Y=c(110,80,70,120,150,90,70,120)
> multiReg=lm(Y~X1+X2)
> multiReg
Call:
lm (formula = Y ~ X1 + X2)
Coefficients:
(Intercept) X1 X2
16.8314 -0.2442 7.8488
Result:
Correlation=0.8775417
RankCorrelation=0.4
Linear regression=Coefficients:
(Intercept) Y
0.7508 0.9634