[R] Error with Segmented package

David Winsemius dwinsemius at comcast.net
Thu Oct 8 01:11:26 CEST 2015


On Oct 7, 2015, at 6:50 AM, andrew haywood wrote:

> Dear List,
> 
> I am trying to run a simple pieewise regression using the segmented package.
> 
> When running the following code
> 
> library(segmented)
> data = data.frame(x=c(50,60,70,80,90,100,110) , y=
> c(703.786,705.857,708.153,711.056,709.257, 707.4, 705.6))
> 
> model.lm = segmented(lm(y~x,data = data),seg.Z = ~x, psi = NA, control =
> seg.control(K=1))
> 
> I get the following error.
> 
> Error in if (psi == Inf) psi <- median(XREGseg) :
>  missing value where TRUE/FALSE needed

I don't get any error, despite being a bit behind the times. You need to specify the versions (OS, R, segmented) and prepare for some debugging efforts. Easiest way to do this is with the output of sessionInfo(). 

R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (64-bit)

I also have an embarrassing number of packages loaded.

other attached packages:
 [1] segmented_0.5-1.1   boot_1.3-17         sqldf_0.4-10      
 
(remaining 48 are omitted)


> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list