The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
R package for polynomial evaluation of linearity.
lin.eval
is a R package for performing polynomial
evaluation of linearity.
lin.eval
can be installed via Github:
if (!require(devtools)) {
install.packages('devtools')
} ::install_github('vishesh-shrivastav/lin.eval') devtools
Polynomial evaluation of linearity is a technique of assessing if the best way to describe the relationship between two vectors.
Fit three models - linear, second-order polynomial and third-order polynomial
Find out best-fitting model among the three by comparing their p-values. Model with the lowest p-value out of the three is the best-fitting one.
If the best-fitting model is linear, linearity is established and no further steps need to be carried out. This is called Linear 1 type.
Else, best-fitting model is either second or third order polynomoal model. In this case, calculate average deviation from linearity (adl). This is given by:
where, l
is the vector of predictions from linear model
and p
is the vector of predictions from best-fitting
polynomial model.
If adl
is greater than or equal to the threshold
value for deviation from linearity, conclude that the relationship is
non-linear.
Else if adl
is less than the threshold value for
deviation from linearity, conclude that although the best-fitting model
is not linear, deviation from linearity is not significant and hence, it
is still a linear relationship. This is called a Linear 2 type.
Call the poly_eval()
function with the following
parameters:
y
: vector of response values
x
: vector of predictor values
threshold
: threshold value for average deviation from
linearity as percentage. Defaults to 5.
> library("lin.eval")
> foo <- c(165.3929, 165.3929, 1119.5714, 1119.5714, 2073.7500, 2073.7500, 3027.9286, 3027.9286, 3982.1071, 3982.1071, 4936.2857, 4936.2857, 5890.4643, 5890.4643)
> bar <- c(386.2143, 386.2143, 840.6548, 840.6548, 1829.6905, 1829.6905, 3074.4048, 3074.4048, 4295.8810, 4295.8810, 5215.2024, 5215.2024, 5553.4524, 5553.4524)
> derp <- poly_eval(bar, foo, 30)
-order polynomial.
Best fitting model is third:
Computing average deviation from linearity: 27.28 %
Average Deviation from Linearity27.28; which is less than or equal to 30; linearity is established. We call this linearity type as Linear 2 Although the best fitting model is nonlinear, since average deviation from linearity is
You can check the values stored in the result variable:
> derp$p1
1] 8.851095e-12
[> derp$p2
1] 2.514044e-10
[> derp$p3
1] 1.930392e-78
[> derp$adl
1] 27.28302 [
Usage without passing in optional argument for adl:
> xx <- c(0, 1, 2, 4, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30)
> yy <- c(126.6, 101.8, 71.6, 101.6, 68.1, 62.9, 45.5, 41.9, 46.3, 34.1, 38.2, 41.7, 24.7, 41.5, 36.6, 19.6, 22.8, 29.6, 23.5, 15.3, 13.4, 26.8, 9.8, 18.8, 25.9, 19.3)
> poly_eval(yy, xx)
-order polynomial.
Best fitting model is second
Computing average deviation from linearity...: 70.42 %
Average Deviation from Linearity5, nonlinearity is established.
Since, average deviation from linearity is greater than The relationship between the two input vectors is best described by a second order polynomial
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.