[R] create a function from a model
jp d
yoyoq at yahoo.com
Thu Jul 17 03:11:11 CEST 2008
hi,
I am sure this is an obvious question,
I have a optimized model with coefficients from
stepAIC. I can't figure out how to find the
max value of a function with those coefficients.
Its part of a dynamic web page or else i would
have done it by hand. The code works fine, so you probably
don't need it, but here it is:
library(MASS)
dd<-read.csv("Guest.dat", header = TRUE, sep = "," )
res <- stepAIC(glm(Yield ~ (1 + NTP + DNA + T7pol)^2 , data=dd ), list(upper = Yield ~ (1 + NTP + DNA + T7pol )^2 , lower = Yield ~ 1 ) , trace=0 )
coef(res)
(Intercept) NTP DNA T7pol DNA:T7pol
1776 -19 -8.64 -10 1.5
I need the function back out
y = 1776 - 19*NTP -8.64*DNA -10*T7pol + 1.5 *DNA*T7pol
in order to send it to optim() or some optimizer
thanks
ld
More information about the R-help
mailing list