[R] newbie problem using Design.rcs
David Winsemius
dwinsemius at comcast.net
Tue Dec 23 14:20:35 CET 2008
On Dec 22, 2008, at 11:38 PM, sp wrote:
> Hi,
>
> 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
> follows:
>
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);
> print(f);
>
> [I plot original x1,y1 vectors and the regression as in
> y <- coef2[1] + coef2[2]*x1 + coef2[3]*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.
--
David Winsemius
> 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
>
> Residuals:
> Min 1Q Median 3Q Max
> -4.850930 -0.414008 -0.009648 0.418537 3.212079
>
> Coefficients:
> 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!
>
> Sincerely,
> sp
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> 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
mailing list