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.

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

2013-12-19 Thread William Dunlap
: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 make the model type an argument to the function so that you can specify

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

2013-12-19 Thread David Winsemius
- 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: [R] Help using mapply to run multiple models Hello Bill, that is fantastic and it's quite a bit above what I could write

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

2013-12-19 Thread David Winsemius
, 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 make the model type an argument to the function so

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

2013-12-19 Thread William Dunlap
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: [R] Help using mapply to run multiple models Hello Bill, that is fantastic

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

2013-12-19 Thread David Winsemius
: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: call[[1]] - quote(modelType) # ' makes call[[1]] the same as as.name(modelType). You want as.name

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 William Dunlap
(...) 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 Murphy; r-help@r-project.org Subject: Re: [R] Help using mapply to run multiple models

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

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 then using

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) ## y

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

2013-12-18 Thread William Dunlap
Subject: Re: [R] Help using mapply to run multiple models 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

[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

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),