spreg {lazy.stat} | R Documentation |

Spline Regression Analysis: Regress y on spline expanded univariate regressor variable x.

spreg(y, x, degree = 3, knots = NULL, n = 0, nknots = n, intercept = 1, xmin = NULL, xmax = NULL, type = "b", maxiter = 50, eps = 1e-06, epsg = 1e-06, MP = 1, epsSwp = 1e-08, nopermute = 0, rescale = 0, orth = 0, xrange = NULL, plotbase = 0, printbase = 0, print = 0, xlim = NULL, ylim = NULL, title = NULL, xlab = "new", plot = 0)

`y` |
Input criterion variable vector |

`x` |
Input regressor vector. |

`degree` |
Degree of polynomial to be used. |

`knots` |
vector consisting of (interior) knots to be used. |

`n` |
# of knots to be used in [xmin, xmax]. Same as nknots |

`nknots` |
# of knots to be used in [xmin, xmax]. |

`intercept` |
= 0 to omit the intercept when type="p". |

`xmin` |
minimum of interior knots. |

`xmax` |
maximum of interior knots. |

`type` |
= "p" for piecewise spline, |

`maxiter` |
Max # of iterations for monotone spline |

`eps` |
Criterion for relative improvement of rss for monotone spline |

`epsg` |
Criterion for max(abs(gradient)) of rss for monotone spline |

`MP` |
Type of ginv to be used |

`epsSwp` |
Criterion to judge if the pivot is zero in matSwp |

`nopermute` |
= 0 not to permute rows/cols in matSwp |

`rescale` |
= 1 to rescale all the p-spline basis in [0,1]. |

`orth` |
= 1 to orthogonalize the p-spline basis. |

`xrange` |
= new range of x or NULL |

`plotbase` |
= 1 to plot the spline basis matrix. |

`printbase` |
= 1 to print the spline basis matrix. |

`print` |
= 1 to print the result |

`xlim` |
xlim for plot. |

`ylim` |
ylim for plot. |

`title` |
Plot title. |

`xlab` |
="org" to use old value of x when p-spline with xrange. |

`plot` |
= 1 to plot the result |

When knots are present, it has priority over nknots.

When type="m", b-spline base is be created and the regression coefficient
beta will be estimated with the constraints:

beta[1] <= beta[2] <= .... <= beta[ncol(X)]

List of:
x

y

type

rescale, orth, reflect

xrange, xrange0, Xrange0, knots_org

beta

yhat

X=length(x) x (nknots+degree+1) spline basis matrix

knots The interior knots

boundary.knots The boundary knots for bspline

# artificial data set.seed(1701) x <- seq( 0, 3, length=50 ) yhat <- -sin(1*pi*x^(1/2))^3 y <- yhat+0.1*rnorm(length(x)) # data plot plot( x, y, type="p", ylim=c(-1.5,1.5), main="Data and True Func" ) lines( x, yhat ) # Simple Spline Regression res=spreg( y, x, n=5, plot=1, ylim=c(-1.5,1.5) ) # Monotore Spline Regression res=spreg( y, x, n=5, plot=1, ylim=c(-1.5,1.5), type="m" ) # Monotore LS Regression resm=mlsreg( y,x, method=3, print=1, plot=1 )

[Package *lazy.stat* version 0.1.3 Index]