Linear_Regression Subroutine

public subroutine Linear_Regression(x, y, a, b, r2)

This subroutine computes the regression line for a data set of x, y variables.

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in), allocatable :: x(:)

x: input array of length n which contains the set of independent variable

real(kind=pr), intent(in), allocatable :: y(:)

y: input array of length n which contains the set of dependent variable

real(kind=pr), intent(out) :: a

a: output real variable. Slope of the regression line

real(kind=pr), intent(out) :: b

b: output real variable. Intercept of the regression line

real(kind=pr), intent(out) :: r2

Variables

Type Visibility Attributes Name Initial
real(kind=pr), public :: aux1
real(kind=pr), public :: aux2
real(kind=pr), public :: aux3
real(kind=pr), public :: aux4
real(kind=pr), public :: aux5
integer, public :: i
integer, public :: n

total number of data set.

real(kind=pr), public :: t1
real(kind=pr), public :: t2
real(kind=pr), public :: t3
real(kind=pr), public :: t4