Displaying 1 result from an estimated 1 matches for "d_vector".
Did you mean:
  ud_vector
  
2012 Jul 10
1
outer() or some other function for regression prediction with 2 IVs
...erms,
and 2 squared terms.  The coefficients are given by coef(m3).
 
My approach to generating the predictions for a range of each of my IVs,
"s" and "d" was to use outer() like so:
 
predxn <- function(s,d) { sum( coef(m3) * c(1,s,s^2,d,d^2) ) }
z <- outer(s_vector,d_vector,predxn)
 
I can't see what's wrong with this.  For each value of s_vector and d_vector,
it should multiply each coefficient by its term and give me a nice 
two-dimensional array "z" containing the predictions.
 
The problem is that the c() vector ends up with 1601 elements i...