Displaying 20 results from an estimated 5000 matches similar to: "package segmented problem"
2012 Aug 05
1
Problem with segmented function
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,
2006 Jan 18
1
Breakpoints for multiple variables using Segmented
Hi all,
I am using the package ?Segmented? to estimate logistic regression models
with unknown breakpoints (see Muggeo 2003 Statistics in Medicine
22:3055-3071). In the documentation it suggests that it might be possible to
include several variables with breakpoints in the same model: ?Z = a vector
or a matrix meaning the (continuous) explanatory variable(s) having
segmented relationships with
2013 Jan 11
1
problems with package 'segmented'
Dear R-users,
I am trying to understand how the 'segmented'-package works to determine
breakpoints and slopes of regression lines in broken-line regression models.
However, I am not able to repeat the example on the "plant"-dataset,
which was reported in the accompanying paper of the package. (V.M.R
Muggeo, "Segmented: an R package to fit regression models with
2013 Mar 12
1
Constrain slope in segmented package
Hello,
I'm currently using the segmented package of M.R. Muggeo to fit a
two-slope segmented regression. I would like to constrain a
null-left-slope, but I cannot make it. I followed the explanations of
the package (http://dssm.unipa.it/vmuggeo/segmentedRnews.pdf) to write
the following code :
fit.glm <- glm(y~x)
fit.seg <- segmented(fit.glm, seg.Z=~x,psi=0.3)
fit.glm
2012 May 25
1
Breakpoint in logistic GLM with 'segmented' package - error: replacement length zero
Hello all,
I've been having trouble with assessing a breakpoint in a logistic GLM
with two explanatory variables. For this analysis I've been using the
'segmented' package version 0.2-9.1. But I keep getting an error and I
don't see where I would be going awry. The situation is the following:
Two explanatory variables:
bedekking - a variable with possible values between 0 and
2012 May 08
1
Error with psi value for 'segmented' package for R
Hi everyone,
while trying to use 'segmented' (R i386 2.15.0 for Windows 32bit OS) to determine the breakpoint I got stuck with an error message and I can't find solution. It is connected with psi value, and the error says:
Error in seg.glm.fit(y, XREG, Z, PSI, weights, offs, opz) :
(Some) estimated psi out of its range
This is the code I am using:
2012 Jan 10
1
Problem with segmented
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
2009 Sep 04
1
predicting from segmented regression
Hello
I'm having trouble figuring out how to use the output of "segmented()"
with a new set of predictor values.
Using the example of the help file:
??set.seed(12)
xx<-1:100
zz<-runif(100)
yy<-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2)
dati<-data.frame(x=xx,y=yy,z=zz)
out.lm<-lm(y~x,data=dati)
o<-## S3
2007 Dec 06
2
Segmented regression
Hello all,
I have 3 time series (tt) that I've fitted segmented regression models
to, with 3 breakpoints that are common to all, using code below
(requires segmented package). However I wish to specifiy a zero
coefficient, a priori, for the last segment of the KW series (green)
only. Is this possible to do with segmented? If not, could someone point
in a direction?
The final goal is to
2008 Oct 03
1
NA's in segmented
I am trying to fit a very simple broken stick model using the package
"segmented" but I have hit a roadblock.
> str(data)
'data.frame': 18 obs. of 2 variables:
$ Bin : num 0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25 4.75 ...
$ LnFREQ: num 5.06 4.23 3.50 3.47 2.83 ...
I fit the lm easily:
> fit.lm<-lm(LnFREQ~Bin, data=id07)
But I keep getting an error
2012 Nov 16
1
Interpretation of davies.test() in segmented package
My data:
I have raw data points that form a logit style curve as if they were a time
series. Which is to say they form 3 distinct lines with 3 distinct slopes
in backwards z pattern. A certain class of my data looks essentially flat
to the eye with marginal oscillation. What is important to me is the x
value at which the state change is occurring, in other words, the break
point
Use of
2005 Jun 10
0
Replies of the question about robustness of segmented regression
I appreciate to Roger Koenker, Achim Zeileis and Vito Muggeo for their
informative answers. Listed below is unedited replies I got followed by the
question I posted.
Kyong
1. Roger Koenker:
You might try rqss() in the quantreg package. It gives piecewise
linear fits
for a nonparametric form of median regression using total variation
of the
derivative of the fitted function as a penalty
2008 Feb 19
1
Referencing to an object within a function
I am encountering an error when I attempt to reference a glm model
within a function. The function uses the segmented.glm command
(package = segmented). Within the segmented.glm command one specifies
an object, in this case a logistic regression model, and specifies a
starting threshold term (psi). I believe this is an environment
problem, but I do not have a solution. Any assistance
2012 May 03
1
Error with the 'segmented' package for R
Hi everyone,
I have encountered this problem while using 'segmented' plugin for R i386 2.15.0 (for Windows 32bit OS) and I just cannot find neither explanation nor solution for it.
I am trying to run this data
gpp temp
1.661 5
5.028 10
9.772 15
8.692 20
5.693 25
6.293 30
7.757 5
4.604 10
8.763 15
8.134 20
4.616 25
8.417 30
3.483 5
5.046 10
8.306 15
9.142 20
4.686 25
7.301 30
and with
2012 Mar 01
2
Help with segmented package
Hi everyone.
I'm using segmented package to find break point in a bi-linear relationship.
In a particular case, I find 1 pointcut (so 2 slopes).
I would like to know if it is possible to retrieve information in the
segmented object that could let me to plot 1 particular segment with a
different color.
For example, in that folowing example, I would like to plot the second
segment in red.
2018 May 22
2
Using tryCatch in a for loop
Data and code as promised:
#Creating a test dataset
Year<- c(2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014)
Lake1<- c(2, 4, 5, 2, 1, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2)
Lake2<- c(1, 3, -1, 4, -2, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2)
Lake3<- c(1, 2, 5, -3, 1, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2)
Lake4<- c(1, 1, 1, 1, 1, 1, 1, 250, 240, 240, 240, 240, 240, 239,
2007 Jul 29
1
Piecewise Regression with a known slope
Hey, all. I'm working on a data set with a broken stick linear
regression where I know one of the two slopes. It is a negative
linear function until the line intersects with the x-axis, at which
point it becomes 0. It is not a nonlinear asymptotic function, and,
indeed, using negative exponential or logistic types of fits as an
approximation has tended to lead to an under or
2018 May 22
0
Using tryCatch in a for loop
No. If your ouput is a numeric "matrix", it cannot include alpha. Columns
in a data frame can be of different classes, but each column must be single
class.
and finally, of course, see ?cat -- I think you are misusing it. If you
simply want to return "somestuff", your function should be:
function(w) {"somestuff"}
not
function(w) {cat("somestuff")}
As
2012 Sep 28
1
Annotate a segmented linear regression plot
Hello,
I have produced some segmented regressions with the segmented package by
Viggo Mutteo. I have some example data and code below. I want to annotate
the individual segments with the slope parameter (actually it would be
nicer to annotate with 1000*slope and add some small amount of text as
well). How can I do it? Reading the docs for segmented I can access all of
the slope parameters via a
2018 May 22
0
Using tryCatch in a for loop
On 5/22/2018 11:32 AM, Bailey Hewitt wrote:
> Hi Bert,
>
> Thank you for the quick response!
>
> In its current?state?the code?prints three lines that say "warning". What I was expecting is that I would?get?a matrix with 4 columns, 1. column names (from the original data, ex. Lake1) 2. breakpoint year 3. slope 4. slope difference from the first to the?second segment of