| Title: | Implementation of the Lind/Mehlum Utest |
|---|---|
| Description: | An implementation of Lind and Mehlum's (2010) 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. |
| Authors: | Jo Thori Lind [aut, cre] (ORCID: <https://orcid.org/0000-0002-2980-3814>) |
| Maintainer: | Jo Thori Lind <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.0 |
| Built: | 2026-05-24 09:45:10 UTC |
| Source: | https://github.com/jotlind/utest |
This function estimates the slope of the relationship at the extreme points of the independent variable
uslopes(lmObject, vars, .vcov = NULL, x.min = NULL, x.max = NULL)uslopes(lmObject, vars, .vcov = NULL, x.min = NULL, x.max = NULL)
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 |
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.
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)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)
This function computes the Lind/Mehlum test of a U shaped relationship.
utest(lmObject, vars, .vcov = NULL, x.min = NULL, x.max = NULL)utest(lmObject, vars, .vcov = NULL, x.min = NULL, x.max = NULL)
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 |
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).
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.
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"))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"))