Re: [R] Help using mapply to run multiple models

2013-12-19 Thread William Dunlap
="glm", ...) where you want it to make the call glm(...) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: Simon Kiss [mailto:sjk...@gmail.com] > Sent: Thursday, December 19, 2013 1:49 PM > To: William Dunlap > Cc: Dennis Murph

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread Simon Kiss
Hi there: Just to tie this altogether. Here is the final function f<- function (modelType, responseName, predictorNames, data, ..., envir = parent.frame()) { call <- match.call() call$formula <- formula(envir = envir, paste(responseName, sep = " ~ ",

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread David Winsemius
nd as.name() would make a hash of it as we saw in the original portion of this question. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > >> -Original Message- >> From: David Winsemius [mailto:dwinsem...@comcast.net] >> Sent: Thursda

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread William Dunlap
sem...@comcast.net] > Sent: Thursday, December 19, 2013 11:31 AM > To: William Dunlap > Cc: Simon Kiss; r-help@r-project.org > Subject: Re: [R] Help using mapply to run multiple models > > > On Dec 19, 2013, at 11:10 AM, William Dunlap wrote: > > >>>

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread David Winsemius
Bill Dunlap >> Spotfire, TIBCO Software >> wdunlap tibco.com >> >> >>> -Original Message- >>> From: Simon Kiss [mailto:sjk...@gmail.com] >>> Sent: Thursday, December 19, 2013 10:56 AM >>> To: William Dunlap >>> Cc: D

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread David Winsemius
gt; Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > >> -Original Message- >> From: Simon Kiss [mailto:sjk...@gmail.com] >> Sent: Thursday, December 19, 2013 10:56 AM >> To: William Dunlap >> Cc: Dennis Murphy; r-help@r-project.org >> Subject: Re

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread William Dunlap
> Sent: Thursday, December 19, 2013 10:56 AM > To: William Dunlap > Cc: Dennis Murphy; r-help@r-project.org > Subject: Re: [R] Help using mapply to run multiple models > > Hello Bill, that is fantastic and it's quite a bit above what I could write. > Is there a way to >

Re: [R] Help using mapply to run multiple models

2013-12-19 Thread Simon Kiss
Hello Bill, that is fantastic and it's quite a bit above what I could write. Is there a way to make the model type an argument to the function so that you can specify whether one is running glm, lm and such? I tried to modify it by inserting an argument modelType below, but that doesn't work. Y

Re: [R] Help using mapply to run multiple models

2013-12-18 Thread William Dunlap
r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Simon Kiss > Sent: Wednesday, December 18, 2013 9:11 AM > To: Dennis Murphy > Cc: r-help@r-project.org > Subject: Re: [R] Help using mapply to run multiple models > > Dennis, how would your

Re: [R] Help using mapply to run multiple models

2013-12-18 Thread Bert Gunter
Folks: 1. Haven't closely followed the thread. I'm responding only to Simon's post. 2. ?formula ## Especially note the use of "." So just make an appropriately constructed data frame for the data argument of glm: ## example > df <- data.frame(y=rnorm(9),x1=runif(9), x2=1:9) > glm(y~.,data=df)

Re: [R] Help using mapply to run multiple models

2013-12-18 Thread Simon Kiss
Dennis, how would your function be modified to allow it to be more flexible in future. I'm thinking like: > f <- function(x='Dependent variable', y='List of Independent Variables', > z='Data Frame') > { >form <- as.formula(paste(x, y, sep = " ~ ")) >glm(form, data =z) > } I tried that t

Re: [R] Help using mapply to run multiple models

2013-12-18 Thread Simon Kiss
Thanks! that works, more or less. Although the wonky behaviour of mapply that David pointed out is irritating. I tried deleting the $call item from the models produced and passing them to stargazer for reporting the results, but stargazer won't recognize the results even though the class is expl

Re: [R] Help using mapply to run multiple models

2013-12-17 Thread David Winsemius
On Dec 17, 2013, at 5:53 PM, Simon Kiss wrote: > I think I'm missing something. I have a data frame that looks below. > sample.df<-data.frame(var1=rbinom(50, size=1, prob=0.5), var2=rbinom(50, > size=2, prob=0.5), var3=rbinom(50, size=3, prob=0.5), var4=rbinom(50, size=2, > prob=0.5), var5=r

[R] Help using mapply to run multiple models

2013-12-17 Thread Simon Kiss
I think I'm missing something. I have a data frame that looks below. sample.df<-data.frame(var1=rbinom(50, size=1, prob=0.5), var2=rbinom(50, size=2, prob=0.5), var3=rbinom(50, size=3, prob=0.5), var4=rbinom(50, size=2, prob=0.5), var5=rbinom(50, size=2, prob=0.5)) I'd like to run a series of