[R] which coefficients for a gam(mgcv) model equation?
Darren Norris
doon75 at hotmail.com
Thu Mar 11 17:22:42 CET 2010
I have spent a few days trying to figure this from the reply out but am still
stuck!
I need the equation to reply to a request from a referee that was to: "show
the specific estimating equation associated with the fitted line".
the model I am running is (I hope the data frame is not necessary as I think
I am just not getting some basic concept, but it can be provided off list):
gam1<-gam(LR~s(Property_lg),data=property) ## use default family
gaussian(link = "identity")
coef(gam1) returns:
(Intercept) s(Property_lg).1 s(Property_lg).2 s(Property_lg).3
s(Property_lg).4 s(Property_lg).5
44.1777350 -9.4673457 -1.5743877 0.5658906
2.2219434 0.4118942
s(Property_lg).6 s(Property_lg).7 s(Property_lg).8 s(Property_lg).9
2.4477335 -0.6590291 14.6142365 3.4184510
so is the "estimating equation":
E(y_i) ~ 44.1777 + f_1(-9.467) + f_2(-1.574) + f_3(0.565) +f_4(2.221) +
f_5(0.411) + f_6(2.447) + f_7(-0.659) +f_8(14.614)+f_9(3.418)
>From the “predict” function I know the fitted value at x = 0 (intercept) is
-25.5256255 and at x = 1 is -1.3417508. How do I calculate these values from
the “estimating equation” above?
For x=1, I am doing the calculation below which is obviously incorrect, but
how do I calculate the predicted values by hand, I must be missing something
incredibly obvious?
44.1777 + (1*-9.467) + (1*-1.574) + (1*0.565) + (1*2.221) + (1*0.411) +
(1*2.447) + (1*-1*0.659) + (1*4.614)+ (1*3.418)
Many thanks for any further guidance,
Darren
coef(b)
will give you the coefficients for the smooth terms + the intercept for
that model. ?gamObject describes thus a little.
The coefficients for the smooth/spline terms here are of length 9 each,
and each set of 9 coefficients pertains to an f(), so the model in the R
code you gave would be something like
E(y_i) ~ alpha + f_1(x0_i) + f_2(x1_i) + f_3(x2_i) +f_4(x3_i)
or
E(y_i) = alpha + f_1(x0_i) + f_2(x1_i) + f_3(x2_i) +f_4(x3_i) + e, where
e ~ N(0, sigma)
If so, perhaps you could provide more details on why you want the
equation for the model?
--
View this message in context: http://n4.nabble.com/which-coefficients-for-a-gam-mgcv-model-equation-tp1578925p1589223.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list