[R] partial R

John Fox jfox at mcmaster.ca
Mon Apr 2 17:54:10 CEST 2007


Dear Pedram,

I think that you're confusing component+residual ("partial-residual") plots
with added-variable ("partial-regression") plots. The latter shows residuals
for Y and a particular X regressed on all the other X's, and the correlation
in an added-variable plot is therefore the partial correlation between a
particular X and Y "controlling for" all the other X's. This is exactly what
the partial.cor() function computes. If I follow correctly what you want,
you just have to square the partial correlations.

Regards,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
-------------------------------- 

> -----Original Message-----
> From: Pedram Rowhani [mailto:rowhani at geog.ucl.ac.be] 
> Sent: Monday, April 02, 2007 11:06 AM
> To: John Fox; 'Michael Kubovy'
> Cc: r-help at stat.math.ethz.ch
> Subject: RE: [R] partial R
> 
> Dear John and Michael,
> 
> sorry for the poor explanation of my question.
> 
> What I am looking for is the partial R-squares, to estimate 
> the proportion of unexplained variation of y that becomes 
> explained with the addition of variable x cr.plots does give 
> me the plots but I am looking for a way to get the actual 
> partial R squares, which would correspond to the R squares of 
> those plots
> 
> I hope that things are a bit more clear now
> 
> I guess I can calculate the SSE's and SSR's of the different 
> models myself and then use the formula for partial R square 
> but things would be just simpler if there was already a 
> function implemented in R
> 
> Thanks again
> Pedram
> 
> At 16:20 02/04/2007, John Fox wrote:
> 
> 
> 	Dear Michael and Pedram,
> 	
> 	I'm afraid that Pedram's question is unclear, since the 
> subject line refers
> 	to "partial R" (which might have been intended as 
> "partial r," or "partial
> 	correlation"), while the message itself refers to 
> "partial regression
> 	coefficients." 
> 	
> 	The latter are simply the coefficients returned by 
> lm(); there is a
> 	partial.cor() function in the Rcmdr package that 
> computes partial
> 	correlations. It's so simple, that I'll just reproduce it here:
> 	
> 	partial.cor <-
> 	function (X, ...) 
> 	{
> 	    R <- cor(X, ...)
> 	    RI <- solve(R)
> 	    D <- 1/sqrt(diag(RI))
> 	    R <- -RI * (D %o% D)
> 	    diag(R) <- 0
> 	    rownames(R) <- colnames(R) <- colnames(X)
> 	    R
> 	}
> 	
> 	cr.plots() in the car package produces partial-residual plots
> 	("component+residual plots") but returns neither 
> partial correlations nor
> 	partial-regression coefficients.
> 	
> 	Regards,
> 	 John
> 	
> 	--------------------------------
> 	John Fox
> 	Department of Sociology
> 	McMaster University
> 	Hamilton, Ontario
> 	Canada L8S 4M4
> 	905-525-9140x23604
> 	http://socserv.mcmaster.ca/jfox 
> <http://socserv.mcmaster.ca/jfox>  
> 	-------------------------------- 
> 	
> 	> -----Original Message-----
> 	> From: r-help-bounces at stat.math.ethz.ch 
> 	> [ mailto:r-help-bounces at stat.math.ethz.ch 
> <mailto:r-help-bounces at stat.math.ethz.ch> ] On Behalf Of 
> Michael Kubovy
> 	> Sent: Monday, April 02, 2007 9:16 AM
> 	> To: Pedram Rowhani
> 	> Cc: r-help at stat.math.ethz.ch
> 	> Subject: Re: [R] partial R
> 	> 
> 	> 
> 	> On Apr 2, 2007, at 5:49 AM, Pedram Rowhani wrote:
> 	> 
> 	> > i am wondering if there is a command in R that will 
> give me the 
> 	> > partial regression coefficients
> 	> 
> 	> To answer your question, you could have started with 
> 	> RSiteSearch('partial regression')
> 	> 
> 	> It's then likely that you would figured out that one 
> way to proceed is
> 	> install.packages('car')
> 	> ?cr.plots
> 	> 
> 	> (You may have to restart R to get the help on a 
> newly-installed
> 	> package.)
> 	> _____________________________
> 	> Professor Michael Kubovy
> 	> University of Virginia
> 	> Department of Psychology
> 	> USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
> 	> Parcels:    Room 102        Gilmer Hall
> 	>          McCormick Road    Charlottesville, VA 22903
> 	> Office:    B011    +1-434-982-4729
> 	> Lab:        B019    +1-434-982-4751
> 	> Fax:        +1-434-982-4766
> 	> WWW:    http://www.people.virginia.edu/~mk9y/ 
> <http://www.people.virginia.edu/~mk9y/> 
> 	> 
> 	> ______________________________________________
> 	> R-help at stat.math.ethz.ch mailing list
> 	> 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.
> 	> 
> 
> Pedram Rowhani Ardekani
> University of Louvain
> Department of geography
> Place Louis Pasteur, 3
> 1348 Louvain-la-Neuve (Belgium)
> tel     (+32) 010/47.28.70
> fax     (+32) 010/47.28.77
> e-mail  rowhani at geog.ucl.ac.be
> http://www.geo.ucl.ac.be/Recherche/Teledetection/index.html
> <http://www.geo.ucl.ac.be/Recherche/Teledetection/index.html> 
>



More information about the R-help mailing list