[R] Inversing a non-monotonic spline
Geoff Mercer
baethan at asia.com
Sat Dec 6 19:00:27 CET 2008
I have developed a GAM model in order to predict Y using 4 X variables. 2 of these X's are factors, and 1 is a spline.
Part of the data looks like:
Days WRM variety PWM O_EC
31 75 1 90 234
31 79 1 78 283
31 82 1 92 281
31 84 1 96 213
31 99 2 69 247
31 100 2 77 324
31 104 2 74 259
31 118 2 81 282
31 61 3 58 478
31 98 3 83 429
31 98 3 70 379
31 156 3 87 467
31 78 4 56 283
31 97 4 67 282
31 106 4 69 368
31 184 4 78 386
39 66 1 204 233
39 83 1 265 360
39 87 1 270 308
39 236 1 243 323
39 174 2 244 300
39 181 2 257 366
39 241 2 305 408
39 282 2 299 599
39 125 3 153 402
39 156 3 213 384
39 183 3 227 408
39 217 3 235 360
39 159 4 205 362
39 180 4 182 314
39 189 4 224 488
39 246 4 265 468
fdays = factor(Days)
fvar = factor(variety)
my model is:
test1 <- gam(O_EC~s(WRM)+PWM+fdays+fvar)
Now, I can easily measure O_EC, PWM, fvar, and fdays, but not WRM.
I can get a good estimate for s(WRM) by straight algebra and get a rough eyeball estimate of WRM from the s(WRM) vs WRM plot:
s(WRM) ~ O_EC - B0 - B1*PWM - B2*fdays - B3*fvar
Is there any way of using a backSpline or other inverse spline since s(WRM) is not monotone? Or is it possible to obtain a formula for the smooth that I can
mathematically solve for?
Thank you,
Geoff
--
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com
More information about the R-help
mailing list