Product: TIBCO Spotfire®
Find the Curve Fit Equation for the smooth.spline function
In order to evaluate a trend in data the user might take advantage of the smooth.spline function. How can they get the curve fit equation for the output?
Unfortunately there is not a way to get the smoothing equation out of the smooth.spline() function. It is possible to extract a list containing the details of the fit. This list contains the knot locations, coefficients, etc. Please see the following example:
---------------------------
> attach(air)
test <- smooth.spline(ozone, temperature)
#Extract the 'fit':
> test$fit
$knot:
[1] 0.0 0.0 0.0 0.0 0.1 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.4 0.5 0.5
[22] 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.7 0.7 0.7 0.7 0.7
[43] 0.7 0.7 0.7 0.7 0.7 0.8 0.8 0.8 0.8 0.8 0.9 0.9 0.9 1.0 1.0 1.0 1.0
$nk:
[1] 55
$min:
[1] 1
$range:
[1] 5
$coef:
[1] 59 156 57 48 80 63 83 60 83 58 85 65 61 82 74 74 67 81 82 64 92
[22] 50 85 76 70 97 53 88 76 86 82 85 91 73 84 87 75 93 87 100 89 90
[43] 84 89 96 86 96 94 86 98 73 99 55 127 81
attr(, "class"):
[1] "smooth.spline.fit"
-------------------------------------------
For additional information on the attributes of the smooth.spline object please type at the command prompt:
> attributes(test)
$names:
[1] "x" "y" "w" "yin" "lev" "cv.crit" "pen.crit"
[8] "df" "spar" "fit" "call"
$class:
[1] "smooth.spline"
You can extract any of these attributes by using the '$':
> test$spar
[1] 7e-009
Comments
0 comments
Article is closed for comments.