Hi there: I have a series of linear models in a data frame constructed using tidyr and dplyr. It looks like below. How would I go about generating predicted values from each model with a fixed set of newdata? In reality I have 10 dependent variables, but only two independent variables
#random data
x1<-rnorm(100, mean=10, sd=5)
x2<-rnorm(100, mean=5, sd=2 )
y1<-rnorm(100, mean=5, sd=1)
y2<-rnorm(100, mean=3, sd=1)
#create test data farame
df<-data.frame(y1, y2, x1, x2)
#create models
df%>%
gather(dv, value, y1, y2, -x1,-x2) %>%
group_by(dv)%>%
do(mod=lm(value~x1+x2, data=.))