Last data update: 2014.03.03

R: Conducting Piecewise Linear Regression
threshptR Documentation

Conducting Piecewise Linear Regression

Description

Function threshpt estimates a optimal threshold point of non-linear relationship using a piecewise linear regression analysis. A user needs to give approximate threshold point range to start, then threshpt finds optimal threshold point within the given approximate range using grid search method (see details).

Usage

threshpt(formula = formula, family = family, data = data, expvar = expvar, 
startrng = startrng, endrng = endrng, searchunit = searchunit, ...)

Arguments

formula

An object of class formula, which is same as the formula in the glm.

family

Family of distribution which is same as the family in the glm syntax.

data

Data to be used

expvar

Main exposure variable (X)

startrng

Approximate starting point

endrng

Approximate ending point

searchunit

Unit to search for a threshold point

...

Not used

Details

threshpt() estimates a optimal threshold point based on grid search method which finds the point that produces minimum deviance among the equally spaced grid points. This method widely used in environmetal epidemiologic studies.

Value

threshpt returns a optimal threshold and estimates/etandard errors/p-values for the coefficients of a fitted model with optimal threshold.

Author(s)

Youn-Hee Lim, Il-Sang Ohn, and Ho Kim

References

Lerman P. Fitting segmented regression models by grid search. Applied Statistics, 23(1):77-84, 1980.
Kim H, Ha JS, and Park J. High temperature, heat index, and mortality in 6 major cities in south korea. Archives of environmental & occupational health, 61(6):265-270, 2006.
Kim SY, Lee JT, Hong YC, Ahn KJ, and Kim H. Determining the threshold effect of ozone on daily mortality: an analysis of ozone and mortality in seoul, korea, 1995-1999. Environmental research, 94(2):113-119, 2004.
Stafoggia M et al. Short-term associations between fine and coarse particulate matter and hospitalizations in Southern Europe: results from the MED-PARTICLES project. Environmental health perspective, 121(8):932-938, 2013.

See Also

modTempEff

Examples

# read the Seoul data set and create lag variables
data(mort)
seoul = read6city(mort, 11)
seoul_lag = lagdata(seoul, c("meantemp", "mintemp", "meanpm10", "meanhumi"), 5)

# find a optimal threshold and conduct piecewise linear regression
mythresh = threshpt(nonacc ~ meantemp_m3 + meanpm10_m2 +  meanhumi + ns(sn, 4*10) + factor(dow), 
			     expvar = "meantemp_m3", family = "poisson", data = seoul_lag,
			     startrng = 23, endrng = 33, searchunit = 0.2)
mythresh

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HEAT)
Loading required package: splines
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HEAT/threshpt.Rd_%03d_medium.png", width=480, height=480)
> ### Name: threshpt
> ### Title: Conducting Piecewise Linear Regression
> ### Aliases: threshpt
> 
> ### ** Examples
> 
> # read the Seoul data set and create lag variables
> data(mort)
> seoul = read6city(mort, 11)
> seoul_lag = lagdata(seoul, c("meantemp", "mintemp", "meanpm10", "meanhumi"), 5)
> 
> # find a optimal threshold and conduct piecewise linear regression
> mythresh = threshpt(nonacc ~ meantemp_m3 + meanpm10_m2 +  meanhumi + ns(sn, 4*10) + factor(dow), 
+ 			     expvar = "meantemp_m3", family = "poisson", data = seoul_lag,
+ 			     startrng = 23, endrng = 33, searchunit = 0.2)
> mythresh
Call:
threshpt(formula = nonacc ~ meantemp_m3 + meanpm10_m2 + meanhumi + 
    ns(sn, 4 * 10) + factor(dow), family = "poisson", data = seoul_lag, 
    expvar = "meantemp_m3", startrng = 23, endrng = 33, searchunit = 0.2)

Coefficietns for main exposure:
        beta1           se1            p1       beta1+2         se1+2 
-5.100188e-04  9.126435e-04  5.762731e-01  1.841560e-02  3.229438e-03 
         p1+2 
 1.181208e-08 

Other coefficients:
                  Estimate   Std. Error     Pr(>|z|)
(Intercept)   4.745430e+00 2.619664e-02 0.000000e+00
meanpm10_m2   3.258080e-04 8.698421e-05 1.799637e-04
meanhumi     -8.188705e-05 1.579924e-04 6.042507e-01
factor(dow)2  3.620847e-02 7.165486e-03 4.345205e-07
factor(dow)3  1.661660e-02 7.199066e-03 2.099022e-02
factor(dow)4  1.279535e-02 7.209467e-03 7.593109e-02
factor(dow)5  1.679618e-02 7.201088e-03 1.967705e-02
factor(dow)6  2.102104e-03 7.225583e-03 7.711085e-01
factor(dow)7  1.790020e-03 7.221325e-03 8.042275e-01
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>