[R] partial R
John Fox
jfox at mcmaster.ca
Mon Apr 2 16:20:17 CEST 2007
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
--------------------------------
> -----Original Message-----
> From: 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/
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
More information about the R-help
mailing list