[R] Automating regression
    Steven Yen 
    syen04 at gmail.com
       
    Mon Dec 22 23:53:54 CET 2014
    
    
  
How do I specify the type of regression in calling a procedure/
In the following I call the procedure to do a probit regression. Of 
course, I can change "probit" into "lm" in procedure "myreg" to do a 
linear regression.
My question is, how do I automate this (choice of lm or probit) in 
calling "myreg", with a proper input (e.g., model=lm)? Thank you.
---
eq1<-d~sex+age+children
b<-myreg(eq1,data=mydata); summary(b)
myreg<-function(formula,data){
data<-model.frame(formula,data)
reg<-probit(formula,data=data)
return(reg)
}
    
    
More information about the R-help
mailing list