MyNixOS website logo
Description

Universal Turning Point and Inflection Point Tests.

Performs turning point and inflection point tests for U-shaped and inverse U-shaped relationships in regression models. Implements the Sasabuchi (1980) test as extended by Lind and Mehlum (2010) with support for quadratic, cubic, log-quadratic, and inverse functional forms. Features include delta-method standard errors, Fieller confidence intervals, Simonsohn (2018) two-lines test, and parametric bootstrap. Designed for post-estimation analysis of linear models, panel models, and quantile regression. References: Lind and Mehlum (2010) <doi:10.1111/j.1468-0084.2009.00569.x>; Sasabuchi (1980); Fieller (1954) <doi:10.1111/j.2517-6161.1954.tb00159.x>.

tptest: Universal Turning Point and Inflection Point Tests

Overview

The tptest package implements tests for U-shaped and inverse U-shaped relationships in regression analysis. It provides a comprehensive framework for detecting turning points and inflection points in time series and panel data.

Key Features

  • Sasabuchi (1980) / Lind-Mehlum (2010) Test: Rigorous test for U-shape or inverse U-shape
  • Multiple Functional Forms: Quadratic, cubic, inverse, and log-quadratic specifications
  • Delta-Method Standard Errors: Proper inference for turning point estimates
  • Fieller Confidence Intervals: Robust intervals when denominator is uncertain
  • Simonsohn (2018) Two-Lines Test: Alternative U-shape validation
  • Parametric Bootstrap: Bootstrap confidence intervals

Installation

# Install from CRAN (when available)
install.packages("tptest")

# Install development version from GitHub
devtools::install_github("muhammedalkhalaf/tptest")

Usage

library(tptest)

# Simulate data with U-shaped relationship
set.seed(42)
n <- 200
x <- runif(n, 1, 10)
y <- 50 - 8*x + 0.5*x^2 + rnorm(n, sd = 5)
dat <- data.frame(y = y, x = x, x_sq = x^2)

# Fit quadratic model
fit <- lm(y ~ x + x_sq, data = dat)

# Test for U-shape
result <- tptest(fit, vars = c("x", "x_sq"), data = dat)
print(result)

Output

==========================================
  Turning Point Test (Lind & Mehlum 2010)
==========================================

Model form: Quadratic: y = b1*x + b2*x^2
Data interval: [1.023, 9.987]

Detected shape: U shape
Turning point (x*): 8.234
  Delta-method SE:  0.5123
  95% CI:         [7.230, 9.238]

------------------------------------------
Sasabuchi (1980) Test
------------------------------------------
                Lower bound    Upper bound
Interval            1.0230         9.9870
Slope              -6.2456         1.7532
t-value           -12.4532         3.4521
P>|t|               0.0000         0.0003

Overall test: t = 3.4521, p = 0.000312 ***
-> Strong evidence of U shape (p < 0.01)
------------------------------------------
*** p<0.01, ** p<0.05, * p<0.10

Environmental Kuznets Curve Example

# Load example data
data(ekc)

# Fit model
fit <- lm(emissions ~ gdp + gdp_sq, data = ekc)

# Test for inverse U-shape
result <- tptest(fit, vars = c("gdp", "gdp_sq"), 
                 fieller = TRUE, data = ekc)
summary(result)
plot(result)

References

  • Lind, J. T., & Mehlum, H. (2010). With or without U? The appropriate test for a U-shaped relationship. Oxford Bulletin of Economics and Statistics, 72(1), 109-118. https://doi.org/10.1111/j.1468-0084.2009.00569.x

  • Sasabuchi, S. (1980). A test of a multivariate normal mean with composite hypotheses determined by linear inequalities. Biometrika, 67(2), 429-439.

  • Fieller, E. C. (1954). Some problems in interval estimation. Journal of the Royal Statistical Society: Series B, 16(2), 175-185. https://doi.org/10.1111/j.2517-6161.1954.tb00159.x

  • Simonsohn, U. (2018). Two lines: A valid alternative to the invalid testing of U-shaped relationships with quadratic regressions. Advances in Methods and Practices in Psychological Science, 1(4), 538-555.

License

GPL-3

Author.

Metadata

Version

1.0.3

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows