There are ways around this but so far they seem to introduce other complications that are even more annoying.
I really don't like this "read out of the global environment"
thing. I hope Andrew's not writing the new book to lean heavily
on that.
- Bob
I'm only including code that runs!
But, that's right, I don't want to include crap like "data=data" in all of my stan and stan_glm calls.
A
I'm only including code that runs!
But, that's right, I don't want to include crap like "data=data" in all of my stan and stan_glm calls.
A
> On Feb 1, 2017, at 1:17 PM, Bob Carpenter <ca...@alias-i.com> wrote:
>
> I really don't like this "read out of the global environment"
> thing. I hope Andrew's not writing the new book to lean heavily
> on that.
>
> - Bob
>
>> On Feb 1, 2017, at 11:44 AM, Jonah Gabry <jga...@gmail.com> wrote:
>>
>> So... kfold attempts to account for the fact that sometimes data is specified using the data argument to stan_glm and other times using the global environment. When no data argument is specified it needs to construct a data frame that it can use to refit the model K times (each time modifying that data frame to drop the right set of observation). So it constructs a data frame consisting of the 2nd through 5th columns of X because that's what you implicitly told it was your data. But now when we need to go refit the model how is the formula including X[, 2:5] supposed to be interpreted relative to this data frame? There are ways around this but so far they seem to introduce other complications that are even more annoying.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
On Feb 1, 2017, at 4:47 PM, Jonah Gabry <jga...@gmail.com> wrote:
On Wednesday, February 1, 2017 at 4:06:31 PM UTC-5, Andrew Gelman wrote:I'm only including code that runs!
But, that's right, I don't want to include crap like "data=data" in all of my stan and stan_glm calls.
AWell, not "data=data" but maybe "data=wells" isn't so bad? Unlike the list you need to (or needed to) manually create for rstan, for rstanarm it would just be the name of the data frame where the variables in the formula can be found. I understand the appeal of not needing to do that, but I think that's outweighed by the mess it causes for software development. Here's a pros/cons list:Cons of searching for data in global (or local) environment if not specified:1) Takes developers a lot more time to add anything new to rstanarm because it's not easy to ensure that the data is handled appropriately. This is not an exaggeration: at most 1/4 of the time I spent implementing kfold was getting the algorithm right and the rest was spent on avoiding errors when people specify data without a data argument. And even after all that time there are apparently still cases when it doesn't work!)2) Inevitably more bugs because the internal code needs to be much more complicated and is harder to test3) Easier for the user to make mistakes (need to be very vigilant about what's already in the global environment)4) I could probably come up with a bunch more!Pros of searching for data in global (or local) environment if not specified:1) A little bit less typing for the user
Am I missing any other advantages other than a bit less typing? I really don't want to sacrifice the quality of the software just to avoid typing something like data=wells, but if there are other advantages I'm missing then maybe those well tip the scale.
Jonah
On Wednesday, February 1, 2017 at 4:06:31 PM UTC-5, Andrew Gelman wrote:I'm only including code that runs!
But, that's right, I don't want to include crap like "data=data" in all of my stan and stan_glm calls.
A
> On Feb 1, 2017, at 1:17 PM, Bob Carpenter <ca...@alias-i.com> wrote:
>
> I really don't like this "read out of the global environment"
> thing. I hope Andrew's not writing the new book to lean heavily
> on that.
>
> - Bob
>
>> On Feb 1, 2017, at 11:44 AM, Jonah Gabry <jga...@gmail.com> wrote:
>>
>> So... kfold attempts to account for the fact that sometimes data is specified using the data argument to stan_glm and other times using the global environment. When no data argument is specified it needs to construct a data frame that it can use to refit the model K times (each time modifying that data frame to drop the right set of observation). So it constructs a data frame consisting of the 2nd through 5th columns of X because that's what you implicitly told it was your data. But now when we need to go refit the model how is the formula including X[, 2:5] supposed to be interpreted relative to this data frame? There are ways around this but so far they seem to introduce other complications that are even more annoying.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to stan-...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
So here's my question: can I do this:dist100 <- dist/100 INSIDE "wells"in a reasonable way?
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
On Feb 1, 2017, at 4:47 PM, Jonah Gabry <jga...@gmail.com> wrote:
On Wednesday, February 1, 2017 at 4:06:31 PM UTC-5, Andrew Gelman wrote:I'm only including code that runs!
But, that's right, I don't want to include crap like "data=data" in all of my stan and stan_glm calls.
AWell, not "data=data" but maybe "data=wells" isn't so bad? Unlike the list you need to (or needed to) manually create for rstan, for rstanarm it would just be the name of the data frame where the variables in the formula can be found. I understand the appeal of not needing to do that, but I think that's outweighed by the mess it causes for software development. Here's a pros/cons list:Cons of searching for data in global (or local) environment if not specified:1) Takes developers a lot more time to add anything new to rstanarm because it's not easy to ensure that the data is handled appropriately. This is not an exaggeration: at most 1/4 of the time I spent implementing kfold was getting the algorithm right and the rest was spent on avoiding errors when people specify data without a data argument. And even after all that time there are apparently still cases when it doesn't work!)2) Inevitably more bugs because the internal code needs to be much more complicated and is harder to test3) Easier for the user to make mistakes (need to be very vigilant about what's already in the global environment)4) I could probably come up with a bunch more!Pros of searching for data in global (or local) environment if not specified:1) A little bit less typing for the user
Am I missing any other advantages other than a bit less typing? I really don't want to sacrifice the quality of the software just to avoid typing something like data=wells, but if there are other advantages I'm missing then maybe those well tip the scale.
Jonah
On Wednesday, February 1, 2017 at 4:06:31 PM UTC-5, Andrew Gelman wrote:I'm only including code that runs!
But, that's right, I don't want to include crap like "data=data" in all of my stan and stan_glm calls.
A
> On Feb 1, 2017, at 1:17 PM, Bob Carpenter <ca...@alias-i.com> wrote:
>
> I really don't like this "read out of the global environment"
> thing. I hope Andrew's not writing the new book to lean heavily
> on that.
>
> - Bob
>
>> On Feb 1, 2017, at 11:44 AM, Jonah Gabry <jga...@gmail.com> wrote:
>>
>> So... kfold attempts to account for the fact that sometimes data is specified using the data argument to stan_glm and other times using the global environment. When no data argument is specified it needs to construct a data frame that it can use to refit the model K times (each time modifying that data frame to drop the right set of observation). So it constructs a data frame consisting of the 2nd through 5th columns of X because that's what you implicitly told it was your data. But now when we need to go refit the model how is the formula including X[, 2:5] supposed to be interpreted relative to this data frame? There are ways around this but so far they seem to introduce other complications that are even more annoying.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to stan-...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
Also I think that things that can be done in lm() and glm() should be doable in stan_lm() and stan_glm().
So here's my question: can I do this:dist100 <- dist/100 INSIDE "wells"in a reasonable way?
If I have to keep putting things into the data frame just to run my regressions, that's a pain in the ass. It's _not_ just "a bit more typing," it's actual additional lines of code, it makes things harder to follow.
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/gwaEpERn1Io/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
Oh, I didn't know about this:wells$dist100 <- wells$dist / 100
We're not talking about a data frame here, but
a list, right? Don't data frames have to be square?
I have no idea what Stata does.
> Here's an example. I start with this model (for simplicity I'm assuming we have a stan_logit() alias):
>
> stan_logit(y ~ dist + arsenic)
> or
> stan_logit(y ~ dist + arsenic, data="wells")
Are you passing the name of a list or something here?
> Ok, fine so far. Now I decide I want to code as dist/100:
> dist100 <- dist/100
> stan_logit(y ~ dist100 + arsenic)
This is where I think it's super helpful for those *reading*
your work (which includes you in the future) to keep
everything together. At this point, you have defined y somewere
before the last fit and define a new dist100 here and everything's
just sitting in the global environment ready to be modified.
I'm confused. And rather frightened by this behavior.
- Bob
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/gwaEpERn1Io/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
Yes. maybe I should try this. Currently I'm saying:
fit_1 <- stan_glm(...)
sim_1 <- as.matrix(fit_1)
beta <- fit1_1[1:k,]
But I could just do
fit_1 <- stan_glm(...)
beta <- as_matrix(sim_1)[1:k,]
I'm doing some predictions "by hand" (y = X*beta), also plotting some fitted regression lines on top of data. I will send you book draft and I hope you can suggest some ways for me to make the code clearer!