Find the correlation coefficient ,
regression coefficient of x and
estimated value of y
With the help of dimension or array for the
given observation.
X Y
3
7
5
9
2
5
.
.
.
.
.
.
.
.
.
.
N1
N2
Solution: here we
see that the total number of observation is up to N so we put here
Do I = 1,N. because we have to put total
N observation.\
Answer:
dimension x(1000) ,Y(1000)
write(*,*) 'Enter the total no. of
observation N'
read(*,*) N
print*, 'enter value of dimension x'
do i = 1,N
read(*,*) x(i)
end do
write(*,*) 'Enter the value of the
dimension y'
do j= 1,N
read(*,*) y(j)
End do
sumx=0
sumy=0
do i=1,10
sumx=sumx+x(i)
sumy=sumy+y(i)
enddo
avex=sumx/10.0
avey=sumy/10.0
sum1=0
sum2=0
spxy=0
do i=1,10
sum1=sum1+(x(i)-avex)**2
sum2=sum2+(y(i)-avey)**2
spxy=spxy+(x(i)-avex)*(y(i)-avey)
end do
correlation= spxy/sqrt(sum1*sum2)
Byx=spxy/sum1
A=avey-(Byx*avex)
print*, 'the value of
corr',correlation,' ','Byx is=',Byx
print*, 'the estimated value of y is
=', A
print*, 'average of x is', avex,' ',' and average of y is',avey
stop
end
No comments:
Post a Comment