Re: [R] VIF threshold implying multicollinearity

2015-07-29 Thread John Kane
Quite, but apparently not a boisterous one? 

John Kane
Kingston ON Canada

-Original Message-
From: cfly...@ncsu.edu
Sent: Mon, 27 Jul 2015 14:35:06 -0400
To: jrkrid...@inbox.com
Subject: Re: [R] VIF threshold implying multicollinearity

No actually it is a quiet good paper! :)

On Mon, Jul 27, 2015 at 8:14 AM, John Kane jrkrid...@inbox.com wrote:

+1
 I, originally,  read it as a stringent criticism of the first paper.

 John Kane
 Kingston ON Canada

  -Original Message-
  From: r.tur...@auckland.ac.nz
  Sent: Mon, 27 Jul 2015 15:12:43 +1200
  To: cfly...@ncsu.edu
  Subject: Re: [R] VIF threshold implying multicollinearity
 
 
  On 27/07/15 13:36, Collin Lynch wrote:
 
  The following sources discuss the issues generally and may be a goof
  pointer to the literature ...
 
  SNIP
 
  I think that the foregoing merits fortune status! :-)
 
  cheers,
 
  Rolf
 
  --
  Technical Editor ANZJS
  Department of Statistics
  University of Auckland
  Phone: +64-9-373-7599 ext. 88276
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help 
  [https://stat.ethz.ch/mailman/listinfo/r-help]
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html 
  [http://www.R-project.org/posting-guide.html]
  and provide commented, minimal, self-contained, reproducible code.

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
 Visit http://www.inbox.com/photosharing [http://www.inbox.com/photosharing] to 
find out more!


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] VIF threshold implying multicollinearity

2015-07-27 Thread John Kane
+1
I, originally,  read it as a stringent criticism of the first paper.

John Kane
Kingston ON Canada


 -Original Message-
 From: r.tur...@auckland.ac.nz
 Sent: Mon, 27 Jul 2015 15:12:43 +1200
 To: cfly...@ncsu.edu
 Subject: Re: [R] VIF threshold implying multicollinearity
 
 
 On 27/07/15 13:36, Collin Lynch wrote:
 
 The following sources discuss the issues generally and may be a goof
 pointer to the literature ...
 
 SNIP
 
 I think that the foregoing merits fortune status! :-)
 
 cheers,
 
 Rolf
 
 --
 Technical Editor ANZJS
 Department of Statistics
 University of Auckland
 Phone: +64-9-373-7599 ext. 88276
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] VIF threshold implying multicollinearity

2015-07-27 Thread Collin Lynch
No actually it is a quiet good paper! :)

On Mon, Jul 27, 2015 at 8:14 AM, John Kane jrkrid...@inbox.com wrote:

 +1
 I, originally,  read it as a stringent criticism of the first paper.

 John Kane
 Kingston ON Canada


  -Original Message-
  From: r.tur...@auckland.ac.nz
  Sent: Mon, 27 Jul 2015 15:12:43 +1200
  To: cfly...@ncsu.edu
  Subject: Re: [R] VIF threshold implying multicollinearity
 
 
  On 27/07/15 13:36, Collin Lynch wrote:
 
  The following sources discuss the issues generally and may be a goof
  pointer to the literature ...
 
  SNIP
 
  I think that the foregoing merits fortune status! :-)
 
  cheers,
 
  Rolf
 
  --
  Technical Editor ANZJS
  Department of Statistics
  University of Auckland
  Phone: +64-9-373-7599 ext. 88276
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  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.

 
 FREE ONLINE PHOTOSHARING - Share your photos online with your friends and
 family!
 Visit http://www.inbox.com/photosharing to find out more!




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] VIF threshold implying multicollinearity

2015-07-26 Thread Wensui Liu
Dear All
I have a general question about VIF.
While there are multiple rules of thumb about the threshold value of
VIF, e.g. 4 or 10, implying multicollinearity, I am wondering if
anyone can point me to some literature supporting these rules of
thumb.

Thank you so much!
wensui

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] VIF threshold implying multicollinearity

2015-07-26 Thread Rolf Turner


On 27/07/15 13:36, Collin Lynch wrote:


The following sources discuss the issues generally and may be a goof
pointer to the literature ...


SNIP

I think that the foregoing merits fortune status! :-)

cheers,

Rolf

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] VIF threshold implying multicollinearity

2015-07-26 Thread Collin Lynch
The following sources discuss the issues generally and may be a goof
pointer to the literature on VIF.  Particularly the Schroeder paper.

@article{Yi:Evaluation,
   AUTHOR = {Youjae Yi},
   TITLE  = {On the Evaluation of Main Effects in Multiplicative
 Regression Models.},
   JOURNAL = {Journal of the Market Research Society},
   VOLUME  = {31},
   NUMBER  = {1},
   MONTH   = {January},
   YEAR= {1989},
   PAGES   = {133-138}
}


@article{Gordon:Issues,
   AUTHOR  = {Robert A. Gordon},
   TITLE   = {Issues in Multiple Regression},
   JOURNAL = {American Journal of Sociology},
   VOLUME  = {73},
   NUMBER  = {5},
   MONTH   = {March},
   YEAR= {1968},
   PAGES   = {592-616}
}


@misc{Lynch:Multicollinearity,
   author = {Scott M. Lynch},
   title  = {Multicollinearity},
   year   = {2003},
   url= {\url{
http://www.princeton.edu/~slynch/soc504/multicollinearity.pdf}},
   note   = [Online; accessed 11-October-2013]
 }


@article{Schroeder:Multicollinearity,
   AUTHOR  = {Mary Ann Schroeder
   and Janice Lander
   and Stacey Levine-Silverman},
   TITLE   = {Diagnosing and Dealing with Multicollinearity},
   JOURNAL = {Western Journal of Nursing Research},
   VOLUME  = {12},
   NUMBER  = {2},
   YEAR= {1990},
   PAGES   = {175-187}
}


@book{Afifi:Computer,
  AUTHOR= {A. Afifi and V. Clark},
  TITLE = {Computer-aided Multivariate Analysis},
  PUBLISHER = {Wadsworth, Belmont California},
  YEAR  = {1984}
}


On Sun, Jul 26, 2015 at 5:00 PM, Wensui Liu liuwen...@gmail.com wrote:

 Dear All
 I have a general question about VIF.
 While there are multiple rules of thumb about the threshold value of
 VIF, e.g. 4 or 10, implying multicollinearity, I am wondering if
 anyone can point me to some literature supporting these rules of
 thumb.

 Thank you so much!
 wensui

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] vif in package car: there are aliased coefficients in the model

2015-03-30 Thread Rodolfo Pelinson
 Of
 Rodolfo
Pelinson
Sent: March-27-15 3:07 PM
To: r-help@r-project.org
Subject: [R] vif in package car: there are aliased coefficients in
 the
   model
   
Hello. I'm trying to use the function vif from package car in a lm.
   However it
returns the following error:
Error in vif.default(lm(MDescores.sitescores ~ hidroperiodo +
   localizacao
+  : there are aliased coefficients in the model
   
When I exclude any predictor from the model, it returns this warning
message:
Warning message: In cov2cor(v) : diag(.) had 0 or NA entries;
 non-finite
result is doubtful
   
When I exclude any other predictor from the model vif finally works.
 I
   can't
figure it out whats the problem. This are the results that R returns
me:
   
 vif(lm(MDescores.sitescores ~ hidroperiodo + localizacao + area +
profundidade + NTVM +  NTVI + PCs...c.1.., data = MDVIF)) Error in
vif.default(lm(MDescores.sitescores ~ hidroperiodo + localizacao +
 :   there are aliased coefficients in the model
   
 vif(lm(MDescores.sitescores ~ localizacao + area + profundidade +
 NTVM
 +
 NTVI + PCs...c.1.., data = MDVIF))
 GVIF Df GVIF^(1/(2*Df))
localizacao   NaN  2 NaN
area  NaN  1 NaN
profundidade  NaN  1 NaN
NTVM  NaN  1 NaN
NTVI  NaN  1 NaN
PCs...c.1..   NaN  1 NaN
Warning message:
In cov2cor(v) : diag(.) had 0 or NA entries; non-finite result is
   doubtful
   
Thanks.
--
Rodolfo Mei Pelinson.
   
  [[alternative HTML version deleted]]
   
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
  
  
   ---
   This email has been checked for viruses by Avast antivirus software.
   http://www.avast.com
  
  
 
 
  --
  Rodolfo Mei Pelinson.

 
 John Fox, Professor
 McMaster University
 Hamilton, Ontario, Canada
 http://socserv.mcmaster.ca/jfox/






-- 
Rodolfo Mei Pelinson.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] vif in package car: there are aliased coefficients in the model

2015-03-28 Thread John Fox
Dear Rodolfo,

Sending the data helps, though if you had done what I suggested, you would have 
seen what's going on:

 snip --

 dim(data)
[1] 8 8

 summary(lm(response_variable ~ predictor_1 + predictor_2 + predictor_3 + 
 predictor_4 
+ + predictor_5 + predictor_6 + predictor_7, data = data))

Call:
lm(formula = response_variable ~ predictor_1 + predictor_2 + 
predictor_3 + predictor_4 + predictor_5 + predictor_6 + predictor_7, 
data = data)

Residuals:
ALL 8 residuals are 0: no residual degrees of freedom!

Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(|t|)
(Intercept)  -5.1905 NA  NA   NA
predictor_1yellow 2.4477 NA  NA   NA
predictor_2fora   6.5056 NA  NA   NA
predictor_2interior   6.0769 NA  NA   NA
predictor_3   0.6750 NA  NA   NA
predictor_4   3.0742 NA  NA   NA
predictor_5   0.6715 NA  NA   NA
predictor_6  -0.9850 NA  NA   NA
predictor_7   NA NA  NA   NA

Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared:  1, Adjusted R-squared:NaN 
F-statistic:   NaN on 7 and 0 DF,  p-value: NA

 snip --

So the data set that you're using has 8 cases and 8 variables, one of which is 
a factor with 3 levels. Consequently, the model you're fitting my LS has 9 
coefficients. Necessarily the rank of the model matrix is deficient. When you 
eliminate a coefficient, you get a perfect fit: 8 coefficients fit to 8 cases 
with 0 df for error.

This is of course nonsense: You don't have enough data to fit a model of this 
complexity. In fact, you might not have enough data to reasonably fit a model 
with just 1 predictor.

I'm cc'ing this response to the r-help email list, where you started this 
thread.

Best,
 John

On Sat, 28 Mar 2015 12:04:05 -0300
 Rodolfo Pelinson rodolfopelin...@gmail.com wrote:
 Thanks a lot for your answer and your time! But Im still having the same
 problem.
 
 That's the script I am using:
 
 library(car)
 
 data -read.table(data_vif.txt, header = T, sep = \t, row.names = 1)
 data
 
 vif(lm(response_variable ~ predictor_1 + predictor_2 + predictor_3 +
 predictor_4 + predictor_5 + predictor_6 + predictor_7, data = data))
 
 vif(lm(response_variable ~ predictor_1 + predictor_2 + predictor_3 +
 predictor_4 + predictor_5 + predictor_6, data = data))
 
 
 the first vif function above returns me the following error:
 
 Error in vif.default(lm(response_variable ~ predictor_1 + predictor_2 +  :
   there are aliased coefficients in the model
 
 Then if I remove any one of the predictors (in the script I removed
 predictor_7 as an example), it returns this:
 
 GVIF Df GVIF^(1/(2*Df))
 predictor_1  NaN  1 NaN
 predictor_2  NaN  2 NaN
 predictor_3  NaN  1 NaN
 predictor_4  NaN  1 NaN
 predictor_5  NaN  1 NaN
 predictor_6  NaN  1 NaN
 Warning message:
 In cov2cor(v) : diag(.) had 0 or NA entries; non-finite result is doubtful
 
 
 Can you help me with this? I even attached to this e-mail my data set. It's
 a small table.
 
 Sorry for the question.
 
 
 
 2015-03-27 21:51 GMT-03:00 John Fox j...@mcmaster.ca:
 
  Dear Rodolfo,
 
  It's apparently the case that at least one of the columns of the model
  matrix for your model is perfectly collinear with others.
 
  There's not nearly enough information here to figure out exactly what the
  problem is, and the information that you provided certainly falls short of
  allowing me or anyone else to reproduce your problem and diagnose it
  properly. It's not even clear from your message exactly what the structure
  of the model is, although localizacao  is apparently a factor with 3
  levels.
 
 
  If you look at the summary() output for your model or just print it, you
  should at least see which coefficients are aliased, and that might help you
  understand what went wrong.
 
  I hope this helps,
   John
 
  ---
  John Fox, Professor
  McMaster University
  Hamilton, Ontario, Canada
  http://socserv.mcmaster.ca/jfox/
 
 
   -Original Message-
   From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rodolfo
   Pelinson
   Sent: March-27-15 3:07 PM
   To: r-help@r-project.org
   Subject: [R] vif in package car: there are aliased coefficients in the
  model
  
   Hello. I'm trying to use the function vif from package car in a lm.
  However it
   returns the following error:
   Error in vif.default(lm

[R] vif in package car: there are aliased coefficients in the model

2015-03-27 Thread Rodolfo Pelinson
Hello. I'm trying to use the function vif from package car in a lm. However
it returns the following error:
Error in vif.default(lm(MDescores.sitescores ~ hidroperiodo + localizacao
+  : there are aliased coefficients in the model

When I exclude any predictor from the model, it returns this warning
message:
Warning message: In cov2cor(v) : diag(.) had 0 or NA entries; non-finite
result is doubtful

When I exclude any other predictor from the model vif finally works. I
can't figure it out whats the problem. This are the results that R returns
me:

 vif(lm(MDescores.sitescores ~ hidroperiodo + localizacao + area +
profundidade + NTVM +  NTVI + PCs...c.1.., data = MDVIF))
Error in vif.default(lm(MDescores.sitescores ~ hidroperiodo + localizacao +
 :   there are aliased coefficients in the model

 vif(lm(MDescores.sitescores ~ localizacao + area + profundidade + NTVM +
 NTVI + PCs...c.1.., data = MDVIF))
 GVIF Df GVIF^(1/(2*Df))
localizacao   NaN  2 NaN
area  NaN  1 NaN
profundidade  NaN  1 NaN
NTVM  NaN  1 NaN
NTVI  NaN  1 NaN
PCs...c.1..   NaN  1 NaN
Warning message:
In cov2cor(v) : diag(.) had 0 or NA entries; non-finite result is doubtful

Thanks.
-- 
Rodolfo Mei Pelinson.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] vif in package car: there are aliased coefficients in the model

2015-03-27 Thread John Fox
Dear Rodolfo,

It's apparently the case that at least one of the columns of the model
matrix for your model is perfectly collinear with others. 

There's not nearly enough information here to figure out exactly what the
problem is, and the information that you provided certainly falls short of
allowing me or anyone else to reproduce your problem and diagnose it
properly. It's not even clear from your message exactly what the structure
of the model is, although localizacao  is apparently a factor with 3 levels.


If you look at the summary() output for your model or just print it, you
should at least see which coefficients are aliased, and that might help you
understand what went wrong.

I hope this helps,
 John

---
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/


 -Original Message-
 From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rodolfo
 Pelinson
 Sent: March-27-15 3:07 PM
 To: r-help@r-project.org
 Subject: [R] vif in package car: there are aliased coefficients in the
model
 
 Hello. I'm trying to use the function vif from package car in a lm.
However it
 returns the following error:
 Error in vif.default(lm(MDescores.sitescores ~ hidroperiodo + localizacao
 +  : there are aliased coefficients in the model
 
 When I exclude any predictor from the model, it returns this warning
 message:
 Warning message: In cov2cor(v) : diag(.) had 0 or NA entries; non-finite
 result is doubtful
 
 When I exclude any other predictor from the model vif finally works. I
can't
 figure it out whats the problem. This are the results that R returns
 me:
 
  vif(lm(MDescores.sitescores ~ hidroperiodo + localizacao + area +
 profundidade + NTVM +  NTVI + PCs...c.1.., data = MDVIF)) Error in
 vif.default(lm(MDescores.sitescores ~ hidroperiodo + localizacao +
  :   there are aliased coefficients in the model
 
  vif(lm(MDescores.sitescores ~ localizacao + area + profundidade + NTVM
  +
  NTVI + PCs...c.1.., data = MDVIF))
  GVIF Df GVIF^(1/(2*Df))
 localizacao   NaN  2 NaN
 area  NaN  1 NaN
 profundidade  NaN  1 NaN
 NTVM  NaN  1 NaN
 NTVI  NaN  1 NaN
 PCs...c.1..   NaN  1 NaN
 Warning message:
 In cov2cor(v) : diag(.) had 0 or NA entries; non-finite result is doubtful
 
 Thanks.
 --
 Rodolfo Mei Pelinson.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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.


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] vif

2013-10-04 Thread eliza botto
Dear Arun,Thanks indeed

 Date: Thu, 3 Oct 2013 10:22:38 -0700
 From: smartpink...@yahoo.com
 To: r-help@r-project.org
 Subject: Re: [R] vif
 
 Hi Eliza,
 
 Then, res needs a slight modification
 
 
 library(car)
  res- lapply(colnames(h),function(x) {x1- h[,x];dat1- 
 do.call(rbind,lapply(seq_len(ncol(mat1)),function(i){ x2- m[,mat1[,i]];GG- 
 lm(x1~x2[,1]+x2[,2]+x2[,3]+x2[,4]);GGsum- summary(GG); data.frame( 
 Models=paste(colnames(x2),collapse=,), Multiple_Rsq= GGsum$r.squared, 
 Adjusted_Rsq = GGsum$adj.r.squared, Pval = 
 paste(GGsum$coef[-1,4],collapse=,),Vif=paste(vif(GG),collapse=,),stringsAsFactors=FALSE)
   })); dat1[rev(order(dat1[,3])),][1:10,]})
 
 names(res)- colnames(h)
 A.K.
 
 
 
 
 
 
 From: eliza botto eliza_bo...@hotmail.com
 To: smartpink...@yahoo.com smartpink...@yahoo.com 
 Sent: Thursday, October 3, 2013 12:42 PM
 Subject: vif
 
 
 
 Dear Arun,
 There is one small question however. 
 what if i also want in the table a column for vif values of each model. 
 vif values can be generated for any model in the following way
 
 GG-lm(h[,any column]~m[,any column]+m[,any other column] +m[,any other 
 column] +m[,any other column])
 library(car)
 vif(GG)
 
 Here will be get 4 vif values. I want to make a new column which could 
 contain these values seperated by comma, very much similar to the way we did 
 with Pr(|t|) values.
 
 thanks in advance
 
 elisa
 
 
  Date: Thu, 3 Oct 2013 09:01:53 -0700
  From: smartpink...@yahoo.com
  To: r-help@r-project.org
  Subject: Re: [R] a simple question
  
  Hi,
  Try:
  
  
  set.seed(494)
   h- matrix(sample(1:40,4*124,replace=TRUE),ncol=4)
  
   set.seed(39)
   m- matrix(sample(1:100,10*124,replace=TRUE),ncol=10)
   colnames(h)- paste0(h,1:4)
   colnames(m)- paste0(m,1:10)
  mat1-combn(colnames(m),4)
  
   res- lapply(colnames(h),function(x) {x1- h[,x];dat1- 
  do.call(rbind,lapply(seq_len(ncol(mat1)),function(i){ x2- 
  m[,mat1[,i]];GG- lm(x1~x2[,1]+x2[,2]+x2[,3]+x2[,4]);GGsum- summary(GG); 
  data.frame( Models=paste(colnames(x2),collapse=,), Multiple_Rsq= 
  GGsum$r.squared, Adjusted_Rsq = GGsum$adj.r.squared, Pval = 
  paste(GGsum$coef[-1,4],collapse=,),stringsAsFactors=FALSE)  })); 
  dat1[rev(order(dat1[,3])),][1:10,]})
  
  names(res)- colnames(h)
  
  
  A.K.
  
  
  
  
  
  
  From: eliza botto eliza_bo...@hotmail.com
  To: smartpink...@yahoo.com smartpink...@yahoo.com 
  Sent: Thursday, October 3, 2013 11:07 AM
  Subject: a simple question
  
  
  
  
  Dear Arun,
  I hope you are fine. I actually
  wanted to discuss the following problem.
  I have a linear model of the
  following form. 
  GG-lm(h[,any column]~m[,any
  column]+m[,any other column] +m[,any other column] +m[,any other column])
  where,
  h is matrix with 4 columns and
  124 rows
  m is matrix with 10 columns and
  124 rows
  what I want is the following
  make a loop command to run the
  linear model of all the possible combinations of columns of “m” with each
  column of “h”. 
  more precisely, if i take column
  1 of matrix “h”, it should be linear modeled with every combination of 10 
  (210
  combinations) columns of “m”.
  All the columns of “h”  “m”
  have certain names (you can suppose any).  The summary(GG) will give 
  Multiple R-squared,Adjusted R-squared  and 4 values of Pr(|t|). 
  I want in the end a table in the
  following format.
  
  Models  
   Multiple R-squaredAdjusted R-squared   Pr(|t|)
  Name of columns of m separated by
  comma  Multiple R-squared Adjusted R-squared   Pr(|t|) 
  separated by comma
  
  For Example 
  
  Models  
   Multiple R-squaredAdjusted R-squared   Pr(|t|)
  eliza, allen, murphy, jack 
  0.544 0.56 
  0.000114,0.000112,0.01114,0.002114
  
  where,
  eliza, allen, murphy, jack are column names.
  
  The models are to be enlisted in the order of their Adjusted R-squared 
  values. The models with highest Adjusted R-squared value should be on the 
  top and so on. i m only interested in top 10 models. so the remaining 
  should be ignored. 
  
  I tried to put in my question everything but if there is anything wrong plz 
  inform me.
  
  Thankyou very much in advance,
  
  Eliza
  
  __
  R-help@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.
 
 __
 R-help@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

Re: [R] vif

2013-10-03 Thread arun
Hi Eliza,

Then, res needs a slight modification


library(car)
 res- lapply(colnames(h),function(x) {x1- h[,x];dat1- 
do.call(rbind,lapply(seq_len(ncol(mat1)),function(i){ x2- m[,mat1[,i]];GG- 
lm(x1~x2[,1]+x2[,2]+x2[,3]+x2[,4]);GGsum- summary(GG); data.frame( 
Models=paste(colnames(x2),collapse=,), Multiple_Rsq= GGsum$r.squared, 
Adjusted_Rsq = GGsum$adj.r.squared, Pval = 
paste(GGsum$coef[-1,4],collapse=,),Vif=paste(vif(GG),collapse=,),stringsAsFactors=FALSE)
  })); dat1[rev(order(dat1[,3])),][1:10,]})

names(res)- colnames(h)
A.K.






From: eliza botto eliza_bo...@hotmail.com
To: smartpink...@yahoo.com smartpink...@yahoo.com 
Sent: Thursday, October 3, 2013 12:42 PM
Subject: vif



Dear Arun,
There is one small question however. 
what if i also want in the table a column for vif values of each model. 
vif values can be generated for any model in the following way

GG-lm(h[,any column]~m[,any column]+m[,any other column] +m[,any other column] 
+m[,any other column])
library(car)
vif(GG)

Here will be get 4 vif values. I want to make a new column which could 
contain these values seperated by comma, very much similar to the way we did 
with Pr(|t|) values.

thanks in advance

elisa


 Date: Thu, 3 Oct 2013 09:01:53 -0700
 From: smartpink...@yahoo.com
 To: r-help@r-project.org
 Subject: Re: [R] a simple question
 
 Hi,
 Try:
 
 
 set.seed(494)
  h- matrix(sample(1:40,4*124,replace=TRUE),ncol=4)
 
  set.seed(39)
  m- matrix(sample(1:100,10*124,replace=TRUE),ncol=10)
  colnames(h)- paste0(h,1:4)
  colnames(m)- paste0(m,1:10)
 mat1-combn(colnames(m),4)
 
  res- lapply(colnames(h),function(x) {x1- h[,x];dat1- 
 do.call(rbind,lapply(seq_len(ncol(mat1)),function(i){ x2- m[,mat1[,i]];GG- 
 lm(x1~x2[,1]+x2[,2]+x2[,3]+x2[,4]);GGsum- summary(GG); data.frame( 
 Models=paste(colnames(x2),collapse=,), Multiple_Rsq= GGsum$r.squared, 
 Adjusted_Rsq = GGsum$adj.r.squared, Pval = 
 paste(GGsum$coef[-1,4],collapse=,),stringsAsFactors=FALSE)  })); 
 dat1[rev(order(dat1[,3])),][1:10,]})
 
 names(res)- colnames(h)
 
 
 A.K.
 
 
 
 
 
 
 From: eliza botto eliza_bo...@hotmail.com
 To: smartpink...@yahoo.com smartpink...@yahoo.com 
 Sent: Thursday, October 3, 2013 11:07 AM
 Subject: a simple question
 
 
 
 
 Dear Arun,
 I hope you are fine. I actually
 wanted to discuss the following problem.
 I have a linear model of the
 following form. 
 GG-lm(h[,any column]~m[,any
 column]+m[,any other column] +m[,any other column] +m[,any other column])
 where,
 h is matrix with 4 columns and
 124 rows
 m is matrix with 10 columns and
 124 rows
 what I want is the following
 make a loop command to run the
 linear model of all the possible combinations of columns of “m” with each
 column of “h”. 
 more precisely, if i take column
 1 of matrix “h”, it should be linear modeled with every combination of 10 (210
 combinations) columns of “m”.
 All the columns of “h”  “m”
 have certain names (you can suppose any).  The summary(GG) will give Multiple 
 R-squared,    Adjusted R-squared  and 4 values of Pr(|t|). 
 I want in the end a table in the
 following format.
 
 Models                                                                        
    Multiple R-squared        Adjusted R-squared       Pr(|t|)
 Name of columns of m separated by
 comma  Multiple R-squared Adjusted R-squared   Pr(|t|) 
 separated by comma
 
 For Example 
 
 Models                                                                        
    Multiple R-squared        Adjusted R-squared       Pr(|t|)
 eliza, allen, murphy, jack                                                 
 0.544                                     0.56                         
 0.000114,0.000112,0.01114,0.002114
 
 where,
 eliza, allen, murphy, jack are column names.
 
 The models are to be enlisted in the order of their Adjusted R-squared 
 values. The models with highest Adjusted R-squared value should be on the top 
 and so on. i m only interested in top 10 models. so the remaining should be 
 ignored. 
 
 I tried to put in my question everything but if there is anything wrong plz 
 inform me.
 
 Thankyou very much in advance,
 
 Eliza
 
 __
 R-help@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.

__
R-help@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.


[R] vif calculation with car and HH packages

2012-04-13 Thread Özgür Asar
Dear all,

I have faced a problem while calculating VIF values via the packages, car
and HH for the models witout intercepts. Below is an illustrative example:

1) via the car package

 y-rnorm(100,0,1)
 x1-rnorm(100,0,1)
 x2-rnorm(100,0,1)
 x3-rnorm(100,0,1)
 model1-lm(y~-1+x1+x2+x3)
 model2-lm(y~-1+x1+x2)
library(car)
 vif(model1)
  x1   x2   x3 
1.000279 1.019231 1.019376 
Warning message:
In vif.lm(model1) : No intercept: vifs may not be sensible.
 vif(model2)
  x1   x2 
1.85 1.85 
Warning message:
In vif.lm(model2) : No intercept: vifs may not be sensible.

2) via the HH package
 library(HH)
 vif(model1)
  x2   x3 
1.000557 1.000557 
 vif(model2)
Error in vif.default(xx, na.action = na.action) : 
  vif requires two or more X-variables.

I could not understand why this occured. Does anyone have any idea about it?

Best
Ozgur




-


Ozgur ASAR

Research Assistant
Middle East Technical University
Department of Statistics
06531, Ankara Turkey
Ph: 90-312-2105309
--
View this message in context: 
http://r.789695.n4.nabble.com/vif-calculation-with-car-and-HH-packages-tp4555402p4555402.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] vif calculation with car and HH packages

2012-04-13 Thread John Fox
Dear Özgür,

car::vif() produces a warning, not an error. It will proceed to compute VIFs 
based on the correlation matrix of the coefficients (take a look at 
car:::vif.lm) even if there is no intercept, and even though this would not 
normally correspond to variance inflation due to correlation of the predictors. 
If you think that makes sense, then by all means use the VIFs.

Best,
 John


John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

On Fri, 13 Apr 2012 09:49:54 -0700 (PDT)
 Özgür Asar oa...@metu.edu.tr wrote:
 Dear all,
 
 I have faced a problem while calculating VIF values via the packages, car
 and HH for the models witout intercepts. Below is an illustrative example:
 
 1) via the car package
 
  y-rnorm(100,0,1)
  x1-rnorm(100,0,1)
  x2-rnorm(100,0,1)
  x3-rnorm(100,0,1)
  model1-lm(y~-1+x1+x2+x3)
  model2-lm(y~-1+x1+x2)
 library(car)
  vif(model1)
   x1   x2   x3 
 1.000279 1.019231 1.019376 
 Warning message:
 In vif.lm(model1) : No intercept: vifs may not be sensible.
  vif(model2)
   x1   x2 
 1.85 1.85 
 Warning message:
 In vif.lm(model2) : No intercept: vifs may not be sensible.
 
 2) via the HH package
  library(HH)
  vif(model1)
   x2   x3 
 1.000557 1.000557 
  vif(model2)
 Error in vif.default(xx, na.action = na.action) : 
   vif requires two or more X-variables.
 
 I could not understand why this occured. Does anyone have any idea about it?
 
 Best
 Ozgur
 
 
 
 
 -
 
 
 Ozgur ASAR
 
 Research Assistant
 Middle East Technical University
 Department of Statistics
 06531, Ankara Turkey
 Ph: 90-312-2105309
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/vif-calculation-with-car-and-HH-packages-tp4555402p4555402.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.

__
R-help@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.


Re: [R] vif calculation with car and HH packages

2012-04-13 Thread Özgür Asar
Dear Prof. Fox,

I got the point, things are clear now.

Thank you very much,
Best wishes
Ozgur

-


Ozgur ASAR

Research Assistant
Middle East Technical University
Department of Statistics
06531, Ankara Turkey
Ph: 90-312-2105309
--
View this message in context: 
http://r.789695.n4.nabble.com/vif-calculation-with-car-and-HH-packages-tp4555402p4555653.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] vif function using lm object

2011-12-23 Thread Liviu Andronic
On Wed, Dec 21, 2011 at 9:28 AM, arunkumar akpbond...@gmail.com wrote:
 Hi,

   can anyone please explain why the vif should have more than 2 terms.

 *vif.lm(lmobj) : model contains fewer than 2 terms*

 why it is throwng error if it is one variable.

The _VIF_ is a measure of _multicollinearity_, which occurs between
two or more predictors in a regression model. In other words, you
cannot have collinearity in a single predictor.

Also, to compute the VIF you need to regress one regressor on all the
remaining regressors. If you have a single regressor, then you cannot
estimate a VIF.

See the related articles on Wikipedia.

Regards
Liviu






 -
 Thanks in Advance
        Arun
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/vif-function-using-lm-object-tp4220904p4220904.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.



-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

__
R-help@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.


[R] vif function using lm object

2011-12-21 Thread arunkumar1111
Hi,

   can anyone please explain why the vif should have more than 2 terms.

*vif.lm(lmobj) : model contains fewer than 2 terms*

why it is throwng error if it is one variable.




-
Thanks in Advance
Arun
--
View this message in context: 
http://r.789695.n4.nabble.com/vif-function-using-lm-object-tp4220904p4220904.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] VIF for logit models

2009-08-11 Thread Tomas Zelinsky


Hello,

I wonder whether it's possible to use vif{car} for binary logit models 
(estimated by using glm() function). And what about a case if all 
explanatory variables are binary as well? Is VIF still a good criterion 
for multicollinearity detection?


Thanks a lot.

Tomas

__
R-help@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.