Performs logarithmic regression between two sets of values, obtaining parameters and of the following equation.
Where:
Parameter is also calculated to determine the goodness of fit.
CALL logreg(x,y,a,b,R2)
Where:
x
and y
= vectors of rank 1 with real numbers.
See this example to use an array of
rank larger than 1.a
, b
= regression coefficients calculated by the subroutine.R2
= the determination coefficient to measure the goodness of fit, calculated by the subroutine.The following program performs a logarithmic regression of two variables:
PROGRAM logregExample
USE FU_Statistics, ONLY: logreg
IMPLICIT NONE
REAL, DIMENSION(5) :: x = [1., 2., 3., 4., 5.]
REAL, DIMENSION(5) :: y = [3., 4., 5., 6., 7.]
REAL :: a, b, R2
CALL logreg(x, y, a, b, R2)
WRITE(*,*) a, b, R2
END PROGRAM logregExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | DIMENSION(:) | :: | x |
Vector of real numbers with the values of the first variable. It can have any size and it must have one dimension. |
|
real(kind=sp), | intent(in), | DIMENSION(:) | :: | y |
Vector of real numbers with the values of the second variable. It can have any size and it must have one dimension. |
|
real(kind=sp), | intent(out) | :: | a |
Regression coefficient. |
||
real(kind=sp), | intent(out) | :: | b |
Regression coefficient. |
||
real(kind=sp), | intent(out) | :: | R2 |
Determination coefficient. |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | DIMENSION(:) | :: | x |
Vector of real numbers with the values of the first variable. It can have any size and it must have one dimension. |
|
real(kind=dp), | intent(in), | DIMENSION(:) | :: | y |
Vector of real numbers with the values of the second variable. It can have any size and it must have one dimension. |
|
real(kind=dp), | intent(out) | :: | a |
Regression coefficient. |
||
real(kind=dp), | intent(out) | :: | b |
Regression coefficient. |
||
real(kind=dp), | intent(out) | :: | R2 |
Determination coefficient. |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=qp), | intent(in), | DIMENSION(:) | :: | x |
Vector of real numbers with the values of the first variable. It can have any size and it must have one dimension. |
|
real(kind=qp), | intent(in), | DIMENSION(:) | :: | y |
Vector of real numbers with the values of the second variable. It can have any size and it must have one dimension. |
|
real(kind=qp), | intent(out) | :: | a |
Regression coefficient. |
||
real(kind=qp), | intent(out) | :: | b |
Regression coefficient. |
||
real(kind=qp), | intent(out) | :: | R2 |
Determination coefficient. |