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.

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

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

License

GPL-3

Author

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.