[R] piecewise linear regression

Jonathan Baron baron at cattell.psych.upenn.edu
Sat Nov 10 21:23:15 CET 2001


We sent questionnaires to lots of folks.  The questionnaires
differed in word count (wc).  For each questionnaire, I know wc
and whether the questionnaire was returned or not (status).  It
looks like there is a fixed rate of return when wc is below a
break point, and the rate of return falls off linearly after
that.

I want to do a piecewise linear regression with two pieces
meeting at a common breakpoint.  I think it is important that I
don't specify the breakpoint in advance (although, if I get
desperate, I'll do that).

I've tried to fit a model in nls, several different ways
(including using the "hockey stick" method described in
http://www5.biostat.wustl.edu/s-news/s-news-archive/200004/msg00215.html)
and I keep getting a "singular gradient matrix" error (sometimes
the "initial" matrix, sometimes not).  I also got the same thing
with very simple artificial data (using a continuous dependent
measure).  For example:

nls(status~A+B*wc+C*pmin(A,D-wc)),start=list(A=1,B=0,C=0,D=0))

(I know I should use a logistic version, but if this version
doesn't work, I can't imagine that would work.)

Ideas?

Jon Baron
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list