Re: [R] Piecewise continuous logistic regression with one knot

2017-06-23 Thread Bert Gunter
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

[R] Piecewise continuous logistic regression with one knot

2017-06-23 Thread Sorkin, John
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

Re: [R] Piecewise continuous Poisson regression

2017-04-07 Thread Achim Zeileis
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

Re: [R] Piecewise continuous Poisson regression

2017-04-07 Thread Vito Michele Rosario Muggeo
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

[R] Piecewise continuous Poisson regression

2017-04-07 Thread Sorkin, John
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

Re: [R] Piecewise regression using segmented package plotted in xyplot

2015-08-28 Thread Duncan Mackay
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=&

Re: [R] Piecewise regression using segmented package plotted in xyplot

2015-08-28 Thread S Ellison
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

Re: [R] Piecewise regression using segmented package plotted in xyplot

2015-08-28 Thread S Ellison
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

[R] Piecewise regression using segmented package plotted in xyplot

2015-08-27 Thread Sumitrajit Dhar
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

Re: [R] Piecewise (segmented) linear regression with center section slope constraint

2015-08-07 Thread David Winsemius
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

Re: [R] Piecewise (segmented) linear regression with center section slope constraint

2015-08-07 Thread Drew Morrison
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

Re: [R] Piecewise (segmented) linear regression with center section slope constraint

2015-08-07 Thread Adams, Jean
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

[R] Piecewise (segmented) linear regression with center section slope constraint

2015-08-06 Thread Drew Morrison
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

Re: [R] piecewise regression and lm() question

2015-02-11 Thread Duncan Murdoch
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

[R] piecewise regression and lm() question

2015-02-11 Thread Goldschneider, Jill
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

Re: [R] Piecewise Aggregate Approximation in r

2014-05-15 Thread Pascal Oettli
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

[R] Piecewise Aggregate Approximation in r

2014-05-15 Thread Babak Bastan
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/

Re: [R] Piecewise Lasso Regression

2012-06-08 Thread Lucas Santana dos Santos
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

Re: [R] Piecewise Lasso Regression

2012-06-06 Thread Vito Muggeo (UniPa)
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

Re: [R] Piecewise Lasso Regression

2012-06-06 Thread Lucas Santana dos Santos
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

Re: [R] Piecewise Lasso Regression

2012-06-06 Thread Vito Muggeo (UniPa)
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

[R] Piecewise Lasso Regression

2012-06-05 Thread Lucas Santana dos Santos
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

[R] Piecewise distribution function estimation with Generalized Pareto for tail

2011-07-06 Thread Edwin Sun
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

Re: [R] piecewise regression

2011-01-15 Thread Achim Zeileis
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

Re: [R] piecewise regression

2011-01-15 Thread Federico Bonofiglio
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

Re: [R] piecewise regression

2011-01-14 Thread vito.muggeo
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

Re: [R] piecewise regression

2011-01-14 Thread John Sorkin
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[

Re: [R] piecewise regression

2011-01-14 Thread Bert Gunter
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 >

Re: [R] piecewise regression

2011-01-14 Thread Gene Leynes
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

Re: [R] piecewise regression

2011-01-14 Thread Gene Leynes
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

Re: [R] piecewise regression

2011-01-14 Thread Spencer Graves
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

Re: [R] piecewise regression

2011-01-14 Thread David Winsemius
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

[R] piecewise regression

2011-01-14 Thread Federico Bonofiglio
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

[R] Piecewise regression using lme()

2010-07-21 Thread goulvenS
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

[R] Piecewise nls w/ boundary as a fitting parameter

2010-05-19 Thread Primoz PETERLIN
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

Re: [R] piecewise nls?

2010-04-18 Thread Derek Ogle
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

Re: [R] piecewise nls?

2010-04-17 Thread Christian Ritz
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

[R] piecewise nls?

2010-04-16 Thread Derek Ogle
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

[R] piecewise regression using nlme function

2010-01-07 Thread Carlson, Erik A (GE, Research)
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

Re: [R] Piecewise regression in lmer

2010-01-04 Thread Douglas Bates
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

Re: [R] Piecewise regression in lmer

2010-01-04 Thread Walmes Zeviani
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

Re: [R] Piecewise regression in lmer

2010-01-04 Thread Dieter Menne
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

[R] Piecewise regression in lmer

2010-01-04 Thread AD Hayward
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

[R] Piecewise Aggregate approximation

2009-05-25 Thread Anirudh Kondaveeti
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

Re: [R] Piecewise

2009-03-26 Thread vito muggeo
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

Re: [R] Piecewise

2009-03-25 Thread Ben Bolker
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,

[R] Piecewise

2009-03-25 Thread Joe Waddell
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

Re: [R] piecewise linear regression

2009-03-09 Thread vito muggeo
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

Re: [R] piecewise linear regression

2009-03-08 Thread Rolf Turner
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

Re: [R] piecewise linear regression

2009-03-07 Thread David Winsemius
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/

[R] piecewise linear regression

2009-03-07 Thread David Freedman
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

Re: [R] Piecewise Linear Regression

2007-11-14 Thread Vadim Ogranovich
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