| Title: | Lind/Mehlum Utest | 
| Version: | 0.4.0 | 
| Description: | An implementation of Lind and Mehlum's (2010) <doi:10.1111/j.1468-0084.2009.00569.x> Utest to test for the presence of a U shaped or inverted U shaped relationship between variables in (generalized) linear models. It also implements a test of upward/downward sloping relationships at the lower and upper boundary of the data range. | 
| URL: | https://github.com/jotlind/utest | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.3.2 | 
| Suggests: | testthat | 
| NeedsCompilation: | no | 
| Packaged: | 2025-08-21 08:13:52 UTC; jlind | 
| Author: | Jo Thori Lind | 
| Maintainer: | Jo Thori Lind <j.t.lind@econ.uio.no> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-08-26 19:50:02 UTC | 
utest: Lind/Mehlum Utest
Description
An implementation of Lind and Mehlum's (2010) doi:10.1111/j.1468-0084.2009.00569.x Utest to test for the presence of a U shaped or inverted U shaped relationship between variables in (generalized) linear models. It also implements a test of upward/downward sloping relationships at the lower and upper boundary of the data range.
Author(s)
Maintainer: Jo Thori Lind j.t.lind@econ.uio.no (ORCID)
Authors:
- Halvor Mehlum halvor.mehlum@econ.uio.no 
See Also
Useful links:
Estimates slopes at extremes
Description
This function estimates the slope of the relationship at the lower and upper extreme points of the independent variable
Usage
uslopes(lmObject, vars, .vcov = NULL, x.min = NULL, x.max = NULL)
Arguments
| lmObject | The model to be tested | 
| vars | A vector with the name of the linear and squared terms. Can also be provided as a formula | 
| .vcov | The covariance matrix to use | 
| x.min | Lower bound of interval. If  | 
| x.max | Upper bound of interval. If  | 
Details
The function computes slopes of a quadratic relationship at the lower  and upper bound defined by x.min and x.max. Standard errors of the
estimated slopes, t-values, and p-values from a one-sided test of a flat relationship as well as the extreme point of the estimated relationship are also provided.
Value
A list with class "uslopes" containing the following components:
| interval | a vector with the interval for the independent varaible. | 
| slope | a vector with the slope of the relationship at the extremes. | 
| tval | a vector with the t-value of the relationship at the extremes. | 
| pval | a vector with the p-value from a one-sided test a the extremes of the interval. | 
| extreme | the estimated extreme point of the relationship. | 
See Also
Examples
x <- runif(100,min=-1,max=1)
xsq <- x^2
y <- x^2+rnorm(100)
mod <- lm(y~x+xsq)
uslopes(mod,c("x","xsq"))
uslopes(mod,~x+xsq,x.max=0.8)
Perform Utest
Description
This function computes the Lind/Mehlum test of a U shaped relationship.
Usage
utest(lmObject, vars, .vcov = NULL, x.min = NULL, x.max = NULL)
Arguments
| lmObject | The model to be tested | 
| vars | A vector with the name of the linear and squared terms. Can also be provided as a formula | 
| .vcov | The covariance matrix to use | 
| x.min | Lower bound of interval. If  | 
| x.max | Upper bound of interval. If  | 
Details
To test for a U shaped or inverse U shaped relationship, it is necessary to provide an interval where the shape is located. A U shaped relationship is downward sloping at the lower bound and upward sloping at the upper bound, and vice versa for an inverted U shape.
The function assumes inputs from a model including a squared specification. The sign of the squared term is used to differentiate between U shaped and inverted U shaped relationships.
The function provides a test of the joint hypothesis of a downward sloping relationship at x.min and an uppward sloping relationship
at x.max for U shaped relationships and vice versa for inverted U shaped relationships, as detailed in Lind and Mehlum (2010) doi:10.1111/j.1468-0084.2009.00569.x.
Value
A list with class "htest" containing the following components:
| statistic | the test statistic. | 
| p.value | the p-value for the test. | 
| method | a character string indicating what type of test was performed. | 
| data.name | a character string giving the name(s) of the data. | 
| alternative | a character string describing the alternative hypothesis. | 
References
J. T. Lind and H. Mehlum (2010) , With or without U? The appropriate test for a U shaped relationship. Oxford Bulletin of Economics and Statistics 72(1): 109-18, doi:10.1111/j.1468-0084.2009.00569.x.
See Also
Examples
x <- runif(100,min=-1,max=1)
xsq <- x^2
y <- x^2+rnorm(100)
mod <- lm(y~x+xsq)
utest(mod,c("x","xsq"))
utest(mod,~x+xsq,x.max=0.8)
mod.logit <- glm((y>0)~x+xsq,family="binomial")
utest(mod.logit,c("x","xsq"))