Displaying 1 result from an estimated 1 matches for "predict_vari".
2006 Aug 31
3
predict.lm within a function
...response within each of these levels evaluated at the
mean value of all other variables in the model (as indicated below by
replicating the means for the data 3 times in the data.frame part of
predict.lm).
The simplest of all my attempts looks like this:
my.fun <- function(formula, mydata, predict_variable){
my.lm <- lm(formula=formula, data=mydata)
my.predict <-
predict.lm(my.lm,(data.frame(predict_variable=y,rbind(mean(mydata,
na.rm=T),mean(mydata, na.rm=T), mean(mydata,na.rm=T)),
row.names=as.numeric(names(table(mydata$predict_variable))))))
}
outside of the f...