[R] meaning of glm(value ~ .,

onyourmark william108 at gmail.com
Fri Jun 19 16:34:21 CEST 2009


Thank you for the posts. 
I think that from these posts I can say that the '.' will mean that it will
draw on all the variables in data other than the one listed as the dependent
variable in the formula ('value' in this case). 
And it will also look in the global workspace (although I am not clear what
that is exactly and how far it will search).
Also, I think I can conclude that if I include the 'value' column (as I did
using '922') in data, that this will not be an issue. I was concerned that
listing it as part of data would seem to indicate that it was not the
dependent variable but rather one of the independent ones.
Thanks again.


Gavin Simpson wrote:
> 
> On Fri, 2009-06-19 at 09:24 -0400, David Winsemius wrote:
>> On Jun 19, 2009, at 9:00 AM, onyourmark wrote:
> <snip />
>> > means and also, I see
>> >
>> > data=crs$dataset[,c(1:59,922)]
>> >
>> > I have read that the data argument is optional here
>> > "an optional data frame, list or environment (or object coercible by
>> > as.data.frame to a data frame) containing the variables in the  
>> > model. If not
>> > found in data, the variables are taken from environment(formula),  
>> > typically
>> > the environment from which glm is called"
>> >
>> > when they say "data", is that meant to include the dependent  
>> > variable as
>> > well.
>> 
>> Yes.
> 
> It has to be defined in 'data' or the environment of 'formula', so it
> depends on what the OP meant by "meant to include". You can include it
> in 'data' but don't have to.
> 
>> 
>> > In other words,
>> > in the above statement 'value' is the dependent variable and it is  
>> > also
>> > column 922 in the data set.
>> > Is this correct?
>> 
>> Yes.
> 
> No - you can't say that it is variable 922, or even any of 1:59 or 922
> for the reasons mentioned above.
> 
> set.seed(123)
> dat <- data.frame(A = rnorm(100), B = rnorm(100), C = rnorm(100))
> Y <- rpois(100, 2)
> mod <- glm(Y ~ ., data = dat[,c(1,3)], family = poisson)
> mod
> 
> If all you have is this:
> 
> mod <- glm(Y ~ ., data = dat[,c(1,3)], family = poisson)
> 
> You can't say anything more about Y than that it is either in 'dat' or
> in the environment of 'formula ', which in this case is the global
> workspace.
> 
> G
> 
>> 
>> > correct
>> > Thank you.
>> >
>> > -- 
>> 
>> 
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> -- 
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 
> 
>  
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/meaning-of--glm%28value-%7E-.%2C-tp24110747p24112723.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list