Windows Vista R 2.10 - I know it is old, I will update later today. How might I perform a piece-wise linear regression where two linear segments are separated by a single knot? In addition to estimating the slopes of the two segments (or the slope in one segment and the difference between the slope of the first and second segment), I would like the analysis to select the optimum knot. My first analysis will contain a single dependent and a single independent variables. Subsequent analyses will add additional independent variables to determine the effect on the results of adjusting for potential confounding. Thank you, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
On Thu, 23 Dec 2010, John Sorkin wrote:> Windows Vista > R 2.10 - I know it is old, I will update later today. > > How might I perform a piece-wise linear regression where two linear > segments are separated by a single knot? In addition to estimating the > slopes of the two segments (or the slope in one segment and the > difference between the slope of the first and second segment), I would > like the analysis to select the optimum knot. My first analysis will > contain a single dependent and a single independent variables. > Subsequent analyses will add additional independent variables to > determine the effect on the results of adjusting for potential > confounding.Have a look at the "segmented" package, introduced in R News in http://www.R-project.org/doc/Rnews/Rnews_2008-1.pdf Best, Z> Thank you, > John > > > John David Sorkin M.D., Ph.D. > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for th...{{dropped:6}} > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
On 23/12/2010 9:03 AM, John Sorkin wrote:> Windows Vista > R 2.10 - I know it is old, I will update later today. > > How might I perform a piece-wise linear regression where two linear segments are separated by a single knot? In addition to estimating the slopes of the two segments (or the slope in one segment and the difference between the slope of the first and second segment), I would like the analysis to select the optimum knot. My first analysis will contain a single dependent and a single independent variables. Subsequent analyses will add additional independent variables to determine the effect on the results of adjusting for potential confounding.Do you know the position of the knot? If so, it's simply linear regression with two predictors. One predictor could be the x variable, the other should be zero below the knot, x above it. (This corresponds to the formulation you list in parentheses; it's best if you want to test whether the knot is necessary or not). If you don't know the position of the knot it's a much harder problem. I don't know current recommended practice. Duncan Murdoch