Displaying 20 results from an estimated 4000 matches similar to: "Breakpoint in logistic GLM with 'segmented' package - error: replacement length zero"
2012 Jun 01
1
Finding multiple breakpoints - 'segmented' ?
Hello,
I'm attempting to find multiple breakpoints in an association of my
response variable (R.AUC) with two explanatory variables ('s.size' and
'bedekking'). The association between 's.size' and 'R.AUC' shows a
plateau, but the value when this plateau is reached is differs for
different values of 'bedekking'.
Initially I thought these different
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
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,
2008 Jul 08
1
package segmented problem
Hi, while using package "segmented" (version 0.2-4) by Vita Muggeo to
investigate a possible change point (around time = 222) in admissions
for a specific medical condition I had the following error message:
fit2.seg<-segmented(fit2, seg.Z=~time,psi=222)
Error in segmented.lm(fit2, seg.Z = ~time, psi = 222) :
(Some) estimated psi out of its range
"fit2" is a simple
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:
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
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
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
2010 Nov 29
2
FW: how to use by() ?
Thank you for the suggestion, Bill. The result is not quite what I would like. Here's sample code for you or anyone else who may be interested:
Al1 = c('A','C','C','C')
Al2 = c('G','G','G','T')
Freq1 = c(0.0078,0.0567,0.9434,0.9908)
MAF = c(0.0078,0.0567,0.0566,0.0092)
m1 = data.frame(Al1=Al1,
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
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
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
2009 Sep 18
1
Incorrect Dimension
I am new in R and i am having trouble here. I?ve already searched in the list
but hasn?t helped
When i run this script above i get the message "Error in gen[j, i] :
incorrect number of dimensions". However gen is 1000x200 (ind x loc) and so
is g
could anybody help me
for (i in 1 : loc) { #loc=200
for (j in 1 : ind) { #ind=1000
g1 <= function ( gen ) matrix ( if (gen[j, i]
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
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