[R] newbie problem using Design.rcs
dwinsemius at comcast.net
Tue Dec 23 14:20:35 CET 2008
On Dec 22, 2008, at 11:38 PM, sp wrote:
> I read data from a file. I'm trying to understand how to use
> Design.rcs by using simple test data first. I use 1000 integer
> values (1,...,1000) for x (the predictor) with some noise (x+.02*x)
> and I set the response variable y=x. Then, I try rcs and ols as
Not sure what sort of noise that is.
> m = ( sqrt(y1) ~ ( rcs(x1,3) ) ); #I tried without sqrt also
> f = ols(m, data=data_train.df);
> [I plot original x1,y1 vectors and the regression as in
> y <- coef2 + coef2*x1 + coef2*x1*x1]
That does not look as though it would capture the structure of a
restricted **cubic** spline. The usual method in Design for plotting a
model prediction would be:
plot(f, x1 = NA)
> But this gives me a VERY bad fit:
Can you give some hint why you consider this to be a "VERY bad fit"?
It appears a rather good fit to me, despite the test case apparently
not being construct with any curvature which is what the rcs modeling
strategy should be detecting.
> Linear Regression Model
> ols(formula = m, data = data_train.df)
> n Model L.R. d.f. R2 Sigma
> 1000 4573 2 0.9897 0.76
> Min 1Q Median 3Q Max
> -4.850930 -0.414008 -0.009648 0.418537 3.212079
> Value Std. Error t Pr(>|t|)
> Intercept 5.90958 0.0672612 87.86 0
> x1 0.03679 0.0002259 162.88 0
> x1' -0.01529 0.0002800 -54.60 0
> Residual standard error: 0.76 on 997 degrees of freedom
> Adjusted R-Squared: 0.9897
> I appreciate any and all help!
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help