[R] Problem with segmented function

2012-08-05 Thread stella
Hi,

I appreciate your help with the segmented function. I am relatively new to
R. I followed the introduction of the 'segmented'-package by Vito Muggeo,
but still it does not work.
Here are the lines I wrote:

data_test<-data.frame(x=c(1:10),y=c(1,1,1,1,1,2,3,4,5,6))
lr_test<-lm(y~x,data_test)
seg_test<-segmented(lr_test,seg.Z~x,psi=1)


/error in segmented.lm(lr_test, seg.Z ~ x, psi = 1) : 
 A wrong number of terms in `seg.Z' or `psi'/

Thank you very much,
Stella



--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-segmented-function-tp4639227.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Problem with segmented

2012-01-11 Thread Sarah Goslee
We really need the small reproducible example requested in the posting
guide, including sample data, the actual R commands you used, the
libraries required, and your OS and version of R.

Sarah

On Wed, Jan 11, 2012 at 9:08 AM, Filoche  wrote:
> Hi there.
>
> Here's the error message.
>
> Error in seg.lm.fit(y, XREG, Z, PSI, weights, offs, opz) :
>  (Some) estimated psi out of its range
>
> I have tried many ways to specify the arguments, but apparently the error
> message is related to the estimated break point being invalid. However, my
> estimation fall within range of my data.
>
> Thank for your help,
> Phil
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@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.


Re: [R] Problem with segmented

2012-01-11 Thread Filoche
Hi there.

Here's the error message.

Error in seg.lm.fit(y, XREG, Z, PSI, weights, offs, opz) : 
  (Some) estimated psi out of its range

I have tried many ways to specify the arguments, but apparently the error
message is related to the estimated break point being invalid. However, my
estimation fall within range of my data.

Thank for your help,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-segmented-tp4282398p4285505.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Problem with segmented

2012-01-11 Thread Vito Muggeo (UniPa)

dear Phil,
I am not able to read the error message.. did you forget it?

However: does x exist in the workspace?

The following lines work:

myreg2 = lm(y ~ x, data=xy)
mysegmented = segmented(myreg2, seg.Z=~x, psi=c(245000))

myreg2 = lm(xy$y ~ xy$x)
x<-xy$x
mysegmented = segmented(myreg2, seg.Z=~x, psi=c(245000))


The following line does *not* work (as specified in ?segmented, argument 
seg.Z)


myreg2 = lm(xy$y ~ xy$x)
mysegmented = segmented(myreg2, seg.Z=~xy$x, psi=c(245000)) #error


Hope to have been clear,
vito



Il 10/01/2012 17.17, Filoche ha scritto:

Hi everyone.

I'm trying to use the segmented function with the following data:


For instance, I use segmented package as follow:

myreg2 = lm(xy$y ~ xy$x)
mysegmented = segmented(myreg2, seg.Z=~x, psi=c(245000), control =
seg.control(display=FALSE))

Which get me to the following error :


As a break point, a starting guess of 245000 seems fair.

Anyone has an idea why I'm getting such error?

Regards,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-segmented-tp4282398p4282398.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.



--

Vito M.R. Muggeo
Dip.to Sc Statist e Matem `Vianelli'
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 23895240
fax: 091 485726
http://dssm.unipa.it/vmuggeo

__
R-help@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.


[R] Problem with segmented

2012-01-10 Thread Filoche
Hi everyone.

I'm trying to use the segmented function with the following data:


For instance, I use segmented package as follow:

myreg2 = lm(xy$y ~ xy$x)
mysegmented = segmented(myreg2, seg.Z=~x, psi=c(245000), control =
seg.control(display=FALSE))

Which get me to the following error : 


As a break point, a starting guess of 245000 seems fair.

Anyone has an idea why I'm getting such error?

Regards,
Phil

--
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-segmented-tp4282398p4282398.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.