# [R] R help

Michael Bedward michael.bedward at gmail.com
Mon Nov 22 06:08:49 CET 2010

```Hi Ahmed,

Please reply via the list - you'll get better answers because most
people there know more than me :)

Here is a toy example that is similar to the example graph you sent me...

# generate data: linear up to a change point, then plateau with constant std dev
x <- 20:70
y <- rnorm(length(x), c(20:50 * 2, rep(100, 20)), 10)
plot(x, y)

library(segmented)
# naive linear regression
y.lm <- lm(y ~ x)

# convert to segmented (chage-point) regression with
# initial change-point (psi) deliberately away from
# known cp in artificial data
y.seg <- segmented(y.lm, seg.Z=~x, psi=40)

Results are:
Call: segmented.lm(obj = y.lm, seg.Z = ~x, psi = 40)

Meaningful coefficients of the linear terms:
(Intercept)            x         U1.x
11.006        1.684       -1.688

Estimated Break-Point(s) psi1.x : 51.4

There is an article about the segmented package in Rnews vol 8/1:
http://cran.r-project.org/doc/Rnews/Rnews_2008-1.pdf

Hope this helps.

Michael

On 22 November 2010 15:03, Ahmed Attia <ahmedatia80 at gmail.com> wrote:
> Hi Dr Michael,
>
> Attached is an example for the linear plus plateua model but in SAS, this
> exactly what I need to do in R.
>
> Ahmed
>
> On Sun, Nov 21, 2010 at 7:44 PM, Michael Bedward <michael.bedward at gmail.com>
> wrote:
>>
>> Hi Ahmed,
>>
>> Does 'quadratic plateau' model refer to a chage-point or bent-cable
>> regression with quadratic on one side and an asymptote on the other ?
>> If so, you might like to look at the bentcableAR package.  There is a
>> background article here:
>> http://faculty.washington.edu/gchiu/Articles/bentcable-jasa.pdf
>>
>> Michael
>>
>>
>> On 22 November 2010 06:06, Ahmed Attia <ahmedatia80 at gmail.com> wrote:
>> > Dear All,
>> >
>> > I'm a beginner user in R and I would like to make a quadratic and
>> > plateau model in R. Can you help please with an example?
>> >
>> > Thanks so much
>> >
>> >
>> >
>> > --
>> > Ahmed M. Attia
>> > Assistant Lecturer
>> > El-Khattara farm Station
>> > Agronomy Dept.,
>> > Zgazig Univ., Egypt
>> > Visiting Scientist
>> > Haskell Agricultural laboratory
>> > Agronomy and Horticultural Dept.,
>> > Univ. of Nebraska-Lincoln
>> > ahmedatia at zu.edu.eg
>> > aattiamohamed2 at unlnotes.unl.edu
>> > Cell phone: 4023604178
>> >
>> > ______________________________________________
>> > 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.
>> >
>
>
>
> --
> Ahmed M. Attia
> Assistant Lecturer
> El-Khattara farm Station
> Agronomy Dept.,
> Zgazig Univ., Egypt
> Visiting Scientist
> Haskell Agricultural laboratory
> Agronomy and Horticultural Dept.,
> Univ. of Nebraska-Lincoln
> ahmedatia at zu.edu.eg
> aattiamohamed2 at unlnotes.unl.edu
> Cell phone: 4023604178
>
>
>

```

More information about the R-help mailing list