A quick web search on "piecewise regression R" immediately brought up
(the fairly well known) package "segmented" which fits segmented
glm's.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed
How can I fit a piecewise continuous logistic regression with a single free
knot (i.e. the knot is not specified; the model produce an estimate of the
value of the knot).
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of
On Fri, 7 Apr 2017, Sorkin, John wrote:
Is there an R package that will perform a piecewise continuous Poisson
regression? I want to model two linear segments that intersect at a
common knot.
The "segmented" package implements such broken stick regressions based on
either "lm" or "glm" model
dear John,
The package segmented can help you. ?plot.segmented includes a Poisson example
best,
vito
"Sorkin, John" ha scritto:
Is there an R package that will perform a piecewise continuous
Poisson regression? I want to model two linear segments that
intersect at a common knot.
Thank
Is there an R package that will perform a piecewise continuous Poisson
regression? I want to model two linear segments that intersect at a common knot.
Thank you,
John
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicin
Friday, 28 August 2015 14:12
To: r-help@r-project.org
Subject: [R] Piecewise regression using segmented package plotted in xyplot
Hi,
xyplot(threshold ~ age |frequency.a, data=rage,
groups=HL,
cex=0.5,
layout=c(7,4),
par.strip.tex=list(cex=0.8),
xlab="Age (years)",
ylab=&
I perhaps should have added a stronger warning here; note that the model
fitting in my previous post (below) uses explicit initial breakpoints for
segmented (specifically, c(30,60) at line 1 of the get.segments() ). if you
know where yours are, substitute them there. Otherwise, you'd need to us
There isn't an abline method for segmented, and even if there were you'd need
segments() for a segmented line plot. You're going to have to roll your own.
That will need a function to extract the break locations and predicted values
at those points
I don't have your data, so I can't do one spe
Hi,
xyplot(threshold ~ age |frequency.a, data=rage,
groups=HL,
cex=0.5,
layout=c(7,4),
par.strip.tex=list(cex=0.8),
xlab="Age (years)",
ylab="Threshold (dB SPL)",
na.rm="TRUE",
panel=function(x,y,groups,...) {
panel.superpose(x,y,groups=HL,...)
# panel.abline(segmented(lm(threshold~age
On Aug 7, 2015, at 12:05 PM, Drew Morrison wrote:
> Thanks, Jean. I've actually looked at that source before. The issue is that I
> can't constrain the slope of the /center/ section to be zero - in fact, I've
> applied similar code to a three-segment regression and I can get a zero
> slope either
Thanks, Jean. I've actually looked at that source before. The issue is that I
can't constrain the slope of the /center/ section to be zero - in fact, I've
applied similar code to a three-segment regression and I can get a zero
slope either of the two sides, but not in the middle.
Here's a list of
This posting on StackOverflow might be useful to you.
http://stackoverflow.com/questions/13810607/in-r-package-segmented-how-could-i-set-the-slope-of-one-of-lines-in-the-model
Jean
On Thu, Aug 6, 2015 at 3:01 PM, Drew Morrison
wrote:
> Hi,
>
> I'm working on a way to predict the electricity con
Hi,
I'm working on a way to predict the electricity consumption of electrically
heated buildings as a function of outdoor air temperature. I've identified a
three-segment linear model as a candidate for a good fit, with the slope of
the center section constrained to zero. I'm working with the segm
On 11/02/2015 4:30 PM, Goldschneider, Jill wrote:
> I was playing with some examples of piecewise regression using lm() and have
> come across a behavior I'm uncertain about.
> Below is simple 3-segment dataset. I compare predicted output of a model
> created by one call to lm() to that of 3 mod
I was playing with some examples of piecewise regression using lm() and have
come across a behavior I'm uncertain about.
Below is simple 3-segment dataset. I compare predicted output of a model
created by one call to lm() to that of 3 models created by 3 calls to lm().
In case A and B, the resul
Hello,
library(sos)
findFn("Piecewise Aggregate Approximation")
or
RSiteSearch('Piecewise Aggregate Approximation')
Hope this helps,
Pascal
On Thu, May 15, 2014 at 6:13 PM, Babak Bastan wrote:
> Hi experts
>
> Is there any package or function in r to use PAA (Piecewise Aggregate
> Approximati
Hi experts
Is there any package or function in r to use PAA (Piecewise Aggregate
Approximation). Could you please inform me if is there any?
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/
Dear Vito,
Thank you very much for the advice - I will try it and see how the regression
looks.
Best,
Lucas
On Jun 6, 2012, at 11:45 AM, Vito Muggeo (UniPa) wrote:
> dear Lucas,
> If you are interested in selecting the number of breakpoints here a possible
> remedy:
>
> 1. Fit a segmented
dear Lucas,
If you are interested in selecting the number of breakpoints here a
possible remedy:
1. Fit a segmented model with a large number of breakpoints via the
arguments psi=NA and stop.if.error=FALSE in seg.control() (see the
example below)
2. extract the "model matrix" relevant to th
Hi Vito,
I am more interested in selecting the number of breakpoints. My data has some
structure and I believe that fitting a piecewise regression would be of great
benefit.
Thanks,
Lucas
On Jun 6, 2012, at 4:54 AM, Vito Muggeo (UniPa) wrote:
> dear lucas,
> yes you are right, segmented does
dear lucas,
yes you are right, segmented does not handle 'lars' objects.
Out of curisity, are you interested in selecting the number of
breakpoints or in selecting additional covariates with linear parameters?
vito
Il 06/06/2012 0.01, Lucas Santana dos Santos ha scritto:
Hi All,
I am tryi
Hi All,
I am trying to fit a piecewise lasso regression, but package Segmented does not
work with Lars objects.
Does any know of any package or implementation of piecewise lasso regression?
Thanks,
Lucas
__
R-help@r-project.org mailing list
https://s
Hello all,
I am trying to estimate the cumulative distribution function for a single
stock return time series. A piecewise estimation is composed of three parts:
parametric generalized Pareto (GP) for the lower tail (10% of the
observation), non-parametric kernel-smoothed interior (80% of the
obse
On Sat, 15 Jan 2011, vito.muggeo wrote:
dear all,
The package segmented allows to estimate piecewise linear relationships
(*connected*
lines, i.e. a gradual change in the slope) with several breakpoints (known or
unknown)
within (generalized) linear models..
The package also includes some func
Thank u Doctor Muggeo,
I was just getting familiar with your package this morning..i find it
interesting 'cause so far is the only one that allows estimations for the
single slope parameters between brakepoints, by the slope() function.
Contrarily, supposing only one knot in a linear regression,I d
dear all,
The package segmented allows to estimate piecewise linear relationships
(*connected*
lines, i.e. a gradual change in the slope) with several breakpoints (known or
unknown)
within (generalized) linear models..
The package also includes some functions for plotting and testing..
Have a l
If you know the knot and want linear segments, lm (or any other "normal"
regression software) can perform the analysis. For example if you want to
regress y on x and have a knot a 20 the following code will work:
x <- runif(500,0,40)
plot(x)
for (i in 1:500) {
if (x[i] < 20) y[i] <- (-0.5*x[
You failed to specify 2 crucial issues: Are the join points known
(linear rgression, splines) or unknown (nonlinear regression)? And as
several have already indicated, what are the smoothness constraints?
-- Bert
On Fri, Jan 14, 2011 at 6:42 AM, Federico Bonofiglio
wrote:
> Hello everybody
>
oh yes, and the structchange package.
After a day of experimentation I couldn't figure out how to get the
structchange package to work for my problems. Although it is probably user
error on my part, the package seems to be specific to time series problems.
Also, I think it needed regularly spaced
I wish I had a better answer.
There are two things that I know of that use a direct approach:
The segmentation package seems to work well if you are doing a few fits, but
I had problems when I tried running it on loads of data. It's a bit tricky
to parametrize. When I tried investigating the in
Hello:
I just found 58 help pages in 32 contributed packages containing
the terms "piecewise" and "regression", as follows:
library(sos)
pr <- ???'piecewise regression' # for "piecewise" with "regression"
summary(pr) # 58 matches in 32 packages
pr # view the 58 links sorted by package
Searching the archives would surely be a better way to assemble a list
of candidate packages but the "segmented" package is surely in the list.
On Jan 14, 2011, at 9:42 AM, Federico Bonofiglio wrote:
Hello everybody
Quick question, if you'd like to throw a little tip:
does anyone knows a
Hello everybody
Quick question, if you'd like to throw a little tip:
does anyone knows a function that runs piecewise regression models with
coefficients estimation and inferences ?
Thank you
[[alternative HTML version deleted]]
__
R-help
Hi everyone,
I'm trying to fit a of piecewise regression model on a time series. The idea
is to divide the series into segments and then to apply linear regression
models on each segment but in a "global way" and considering
heteroskedasticity between the segments. For example, I build a time ser
Hello,
Fitting a piecewise smooth curve to a set of points (and a piecewise
linear function in particular) seems to be a recurring question on
this list. Nevertheless, I was not able to find an answer to a
question that bothers me.
Suppose I have the following data set, and would want to fit it w
n Ritz [mailto:r...@life.ku.dk]
> Sent: Saturday, April 17, 2010 2:45 PM
> To: Derek Ogle
> Cc: r-help@r-project.org
> Subject: Re: [R] piecewise nls?
>
> Hi Derek,
>
> have a look at the following made-up example:
>
> f1 <- function(x){2*x}
> f2 <- function(x
Hi Derek,
have a look at the following made-up example:
f1 <- function(x){2*x}
f2 <- function(x){-10*x+1}
x<-rnorm(10)
x
(x<0)*f1(x)
(x>=0)*f2(x)
(x<0)*f1(x) + (x>=0)*f2(x)
Therefore I suggest you should specify the model as follows:
yourNLSmodel <- nls(Y ~ (X=Z) * g(X,a,d,e), data =
myData
I am looking into fitting a so-called double von Bertalanffy function to fish
length-at-age data. Attempting to simplify the situation, the model looks like
this ...
Y ~ f(X; a,b,c) if x < Z
Y ~ g(X; a,d,e) if x >= Z
where
* f and g are non-linear functions (the "traditional" "single" von Be
Is a 95% CI on a breakpoint fixed effect legitimate when the nonlinear
equation is continuous but not differentiable at the breakpoint?
I used the nlme to generate a non-linear mixed-effects piecewise model
with initial slope zero prior to an unknown breakpoint. It did give a
95% CI for the bre
On Mon, Jan 4, 2010 at 6:24 AM, Walmes Zeviani
wrote:
> AD Hayward wrote:
>>
>> Dear all,
>>
>> I'm attempting to use a piecewise regression to model the trajectory
>> of reproductive traits with age in a longitudinal data set using a
>> mixed model framework. The aim is to find three slopes and
AD Hayward wrote:
>
> Dear all,
>
> I'm attempting to use a piecewise regression to model the trajectory
> of reproductive traits with age in a longitudinal data set using a
> mixed model framework. The aim is to find three slopes and two points-
> the slope from low performance in early
AD Hayward wrote:
>
> I'm attempting to use a piecewise regression to model the trajectory
> of reproductive traits with age in a longitudinal data set using a
> mixed model framework.
>
You might have a look a Alejandro Jara DPpackage which worked quite well for
me in a similar case.
Th
Dear all,
I'm attempting to use a piecewise regression to model the trajectory
of reproductive traits with age in a longitudinal data set using a
mixed model framework. The aim is to find three slopes and two points-
the slope from low performance in early age to a point of high
performan
Hi all!
I was looking for a software which does Piecewise Aggregate Approximation of
time series data for dimensionality reduction. I have read some papers which
have mentoned the technique but no mention about the software used was given
any where. Any suggestions about it would be appreciated. T
Hi,
In addition to useful Ben's suggestion, you have a, possibly simpler,
alternative.
If you are willing to assume to know the power of you piecewise
polynomial (beta parameter according to code of Ben) you can use the
package segmented. Using the data generated by Ben in his previous
email
Joe Waddell gmail.com> writes:
>
> Hi,
> I am a biologist (relatively new to R) analyzing data which we predict
> to fit a power function. I was wondering if anyone knew a way to model
> piecewise functions in R, where across a range of values (0-x) the data
> is modeled as a power function,
Hi,
I am a biologist (relatively new to R) analyzing data which we predict
to fit a power function. I was wondering if anyone knew a way to model
piecewise functions in R, where across a range of values (0-x) the data
is modeled as a power function, and across another range (x-inf) it is a
li
Sorry for my delay..
If you do not know the breakpoint, I would suggest to estimate it..
Have a look to the segmented package. The relevant code here is
attach(d)
m0<-lm(percent~ year , weights=1/se)
library(segmented)
mseg<-segmented(m0,seg.Z=~year,psi=1995)
points(year, fitted(mseg))
Hope th
On 8/03/2009, at 3:54 AM, David Freedman wrote:
Hi - I'd like to construct and plot the percents by year in a small
data set
(d) that has values between 1988 and 2007. I'd like to have a
breakpoint
(buy no discontinuity) at 1996. Is there a better way to do this
than in
the code below
It actually looked reasonably economical but the output certainly is
ugly. I see a variety of approaches in the r-help archives. This
thread discusses two other approaches, degree-one splines from Berry
and hard coded-coefficients from Lumley:
http://finzi.psych.upenn.edu/R/Rhelp08/archive/
Hi - I'd like to construct and plot the percents by year in a small data set
(d) that has values between 1988 and 2007. I'd like to have a breakpoint
(buy no discontinuity) at 1996. Is there a better way to do this than in
the code below?
> d
year percent se
1 198830.6 0.32
2 1989
Hi,
Let me pick up this old thread. How does one extract the locations of the knots
(ends of the segments) from the fit object below?
Thanks,
Vadim
>From : roger koenker < roger_at_ysidro.econ.uiuc.edu >
Date : Tue 31 May 2005 - 10:23:19 EST
It is conventional to fit piecewise linear
52 matches
Mail list logo