I saw the hint but didn't know how to implement it, I learn more every day.
Thanks for spelling it out! I knew there had to be a function like "predict"! // joseph w. clark , phd candidate \\ usc marshall school of business ---------------------------------------- > Subject: Re: [R] outer() or some other function for regression prediction > with 2 IVs > From: pda...@gmail.com > Date: Tue, 10 Jul 2012 08:46:42 +0200 > CC: michael.weyla...@gmail.com; r-help@r-project.org > To: joeclar...@hotmail.com > > > On Jul 10, 2012, at 05:35 , Joseph Clark wrote: > >> >> Thanks. I was able to get what I wanted by doing this: >> >> >> >> predxn <- function(s,d) { coef(m3)[1] + coef(m3)[2]*s + coef(m3)[3]*s^2 + >> coef(m3)[4]*d + coef(m3)[5]*d^2 } >> >> >> But it's not very elegant... >> > > You didn't take Michael's hint: > > coef(m3) %*% cbind(1, s, s^2, d, d^2) > > or even > > predict(m3, newdata=data.frame(x1=s, x2=d)) > > (in which x1, x2 needs replacement to match the names used in m3). > > Also, a quick (but not fast) solution to the generic non-vectorized-function > problem is to Vectorize() it. > >> >> >> >> >> >> // joseph w. clark , phd candidate >> \\ usc marshall school of business >> ______________________________________________ >> R-help@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. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Email: pd....@cbs.dk Priv: pda...@gmail.com > > > > > > > > ______________________________________________ R-help@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.