Displaying 20 results from an estimated 3000 matches similar to: "Automatic Knot selection in Piecewise linear splines"
2024 Jul 16
2
Automatic Knot selection in Piecewise linear splines
>>>>> Anupam Tyagi
>>>>> on Tue, 9 Jul 2024 16:16:43 +0530 writes:
> How can I do automatic knot selection while fitting piecewise linear
> splines to two variables x and y? Which package to use to do it simply? I
> also want to visualize the splines (and the scatter plot) with a graph.
> Anupam
NB: linear splines, i.e. piecewise
2024 Jul 26
1
Automatic Knot selection in Piecewise linear splines
dear all,
I apologize for my delay in replying you. Here my contribution, maybe
just for completeness:
Similar to "earth", "segmented" also fits piecewise linear relationships
with the number of breakpoints being selected by the AIC or BIC
(recommended).
#code (example and code from Martin Maechler previous email)
library(segmented)
o<-selgmented(y, ~x, Kmax=20,
2001 Dec 05
4
Questions about piecewise spline fitting
Hi All,
I want to fit a piecewise spline of degree 1, i.e. a spline consisting of a
straight line over each piece. I downloaded the R package pspline, then I
have following questions:
1. in the program, the degree of the spline is specified by 2*norder-1. Why
do they adopt such scheme that we can only fit a spline with odd degree?
2. norder cannot be set to 1. Is there any specific reason
2017 Jun 23
1
Piecewise continuous logistic regression with one knot
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 Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
2010 Feb 09
1
lm combined with splines
Hello,
In the following I tried 3 versions of an example in R help. Only the two first predict command work.
After :
library(splines)
require(stats)
1)
fm1 <- lm(weight ~ bs(height, df = 5), data = women)
ht1 <- seq(57, 73, len = 200)
ph1 <- predict(fm1, data.frame(height=ht1)) # OK
plot(women, xlab = "Height (in)", ylab = "Weight (lb)")
lines(ht1, ph1)
2)
2008 Jan 01
3
Specify a correct formula in R for Piecewise Linear Functions?
Dear all,
I have two variables, y and x. It seems that the relationship between them
is Piecewise Linear Functions. The cutpoint is 20. That is, when x<20, there
is a linear relationship between y and x; while x>=20, there is another
different linear relationship between them.
How can i specify their relationships in R correctly?
# glm(y~I(x<20)+I(x>=20),family = binomial, data =
2009 Mar 07
2
piecewise linear regression
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 1988 30.6 0.32
2 1989 31.5 0.31
3 1990 30.9 0.30
4 1991 30.6 0.28
5 1992 29.3 0.25
6 1994 30.3
2008 May 01
1
Optimal knot locations for splines
Suppose I have two variables, x and y. For a fixed number of knots, I want
to create a spline transformation of x such that a loss function is
minimized. Presumably, this loss function would be least squares, i.e. sum
(f(x)-y)^2. The spline transformations would be linear, quadratic or
cubic. I know I can solve this problem using some optimization function in
R, but I was wondering if anyone
2008 Mar 24
1
Great difference for piecewise linear function between R and SAS
Dear Rusers,
I am now using R and SAS to fit the piecewise linear functions, and what
surprised me is that they have a great differrent result. See below.
#R code--Knots for distance are 16.13 and 24, respectively, and Knots for y
are -0.4357 and -0.3202
m.glm<-glm(mark~x+poly(elevation,2)+bs(distance,degree=1,knots=c(16.13,24))
+bs(y,degree=1,knots=c(-0.4357,-0.3202
2013 Jan 10
2
piece-wise linear regression nls function
windows 7, R 2.12
I am trying to run a piecewise linear regression with a single knot, i.e. a regression composed of two straight lines where the two lines intersect at an x value given by the variable knot. I wish to estimate the slope of both lines, the value of knot, the x value where the two lines intersect, and an intercept. I am using the nls code below, and get the following error
2009 Nov 05
1
Simulate data for spline/piecewise regression model
Dear All,
I am trying to simulate data for a spline/piecewise regression model. I am missing something fundamental in my simulation procedure because when I try to fit my simulated data using the Gauss-Newton method in SAS, I am getting some wacky parameter estimates. Can anyone please check my simulation code and tell me what mistake I am making in generating data for spline model?
Thank you
2008 May 27
3
How to test significant differences for non-linear relationships for two locations
Hi List,
I have to compare a relationship between y and x for two locations. I found logistic regression fits both datasets well, but I am not sure how to test if relationships for both sites are significantly different. I searched the r site, however no answers exactly match the question.
I used Tukey's HSD to compare two means, but the relationship in my study was not simply linear. So I
2012 Jan 17
1
MuMIn package, problem using model selection table from manually created list of models
The subject says it all really.
Question 1.
Here is some code created to illustrate my problem, can anyone spot where I'm going wrong?
Question 2.
The reason I'm following a manual specification of models relates to the fact that in reality I am using mgcv::gam, and I'm not aware that dredge is able to separate individual smooth terms out of say s(a,b). Hence an additional request,
2006 Nov 15
1
splineDesign and not-a-knot conditions
Hi,
I would like to fit an (interpolating) spline to data where the
derivatives at the endpoints of the interval are nonzero, thus the
natural spline endpoint-specification does not make sense. Books (de
Boor, etc) suggest that in this case I use not-a-knot splines.
I know what not-a-knot splines are (so if I were solving for the
coefficients directly I knew how to do this), but I don't
2011 Feb 06
1
anova() interpretation and error message
Hi there,
I have a data frame as listed below:
> Ca.P.Biomass.A
P Biomass
1 334.5567 0.2870000
2 737.5400 0.5713333
3 894.5300 0.6393333
4 782.3800 0.5836667
5 857.5900 0.6003333
6 829.2700 0.5883333
I have fit the data using logistic, Michaelis?Menten, and linear model,
they all give significance.
> fm1 <- nls(Biomass~SSlogis(P, phi1, phi2, phi3), data=Ca.P.Biomass.A)
2007 Dec 07
1
Make natural splines constant outside boundary
Hi,
I'm using natural cubic splines from splines::ns() in survival
regression (regressing inter-arrival times of patients to a queue on
queue size). The queue size fluctuates between 3600 and 3900.
I would like to be able to run predict.survreg() for sizes <3600 and
>3900 by assuming that the rate for <3600 is the same as for 3600 and
that for >4000 it's the same as for
2010 Apr 19
3
nls for piecewise linear regression not converging to least square
Hi R experts,
I'm trying to use nls() for a piecewise linear regression with the first
slope constrained to 0. There are 10 data points and when it does converge
the second slope is almost always over estimated for some reason. I have
many sets of these 10-point datasets that I need to do. The following
segment of code is an example, and sorry for the overly precise numbers,
they are just
2008 Jan 25
1
Problem with FollowMe
I'm trying to use the FollowMe app with Asterisk 1.4.17. I've followed
the WIKI page on setting it up but I can't seem to get it to work.
Here is my Asterisk version:
pbx1*CLI> core show version
Asterisk 1.4.17 built by root @ pbx1 on a i686 running Linux on
2008-01-10
12:08:48 UTC
Here is a log of when the FollowMe is being called:
NOTE: I've tried to use the AstDB as
2009 Nov 01
1
package lme4
Hi R Users,
When I use package lme4 for mixed model analysis, I can't distinguish
the significant and insignificant variables from all random independent
variables.
Here is my data and result:
Data:
Rice<-data.frame(Yield=c(8,7,4,9,7,6,9,8,8,8,7,5,9,9,5,7,7,8,8,8,4,8,6,4,8,8,9),
Variety=rep(rep(c("A1","A2","A3"),each=3),3),
2010 Dec 23
2
Piece-wise continuous regression with one knot
Windows Vista
R 2.10 - I know it is old, I will update later today.
How might I perform a piece-wise linear regression where two linear segments are separated by a single knot? In addition to estimating the slopes of the two segments (or the slope in one segment and the difference between the slope of the first and second segment), I would like the analysis to select the optimum knot. My first