you might look at partial.r in the psych package
dadrivr wrote:
>
> I'm trying to write code to calculate partial correlations (along with
> p-values). I'm new to R, and I don't know how to do this. I have
> searched and come across different functions, but I haven't been able to
> get any of
On Sat, 5 Dec 2009, Juliet Hannah wrote:
Your R code looks correct.
There are a couple of hiccups.
First the degrees of freedom for the partial correlation would be wrong
even if there was no missing data.
Because this is a straightforward calculation, I would be surprised if there
were
Your R code looks correct.
Because this is a straightforward calculation, I would be surprised if there
were any differences with SPSS. It may be worthwhile to check
if SPSS gives partial correlations or semipartial correlations. For example,
if you take the correlation between
py <- resid(lm(y
I am trying to calculate a partial correlation and p-values. Unfortunately,
the results in R are different than what SPSS gives.
Here is an example in R (calculating the partial correlation of x and y,
controlling for z1 and z2):
x <- c(1,20,14,30,9,4,8)
y <- c(5,6,7,9,NA,10,6)
z1 <- c(13,8,16,
dadrivr wrote:
The variables have the same length, but with different numbers of missing
values (NA). As a result, the residuals calculations (xres & yres) have
different lengths, and I cannot compute the correlation between the two
(error of incompatible dimensions - see example below). Is th
The variables have the same length, but with different numbers of missing
values (NA). As a result, the residuals calculations (xres & yres) have
different lengths, and I cannot compute the correlation between the two
(error of incompatible dimensions - see example below). Is there a way,
when c
1) Think about what you did wrong. It doesn't make sense to do
correlation/regression with variables of different lengths. You can
have missing values in one or more variables, if that's what you mean.
Just code them NA.
2) Just add in the predictors, e.g.
residuals(lm(y ~ z1 + z2))
-Ista
On Wed
Awesome, that's what I was looking for. I have two additional questions: (1)
What can I do if the variables are of different lengths? (2) How do I update
the formula if I want to control for more than one variable.
Let's take the following example:
x <- c(1,20,14,7,9)
y <- c(5,6,7,9,10,11)
z <-
dadrivr wrote:
I'm trying to write code to calculate partial correlations (along with
p-values). I'm new to R, and I don't know how to do this. I have searched
and come across different functions, but I haven't been able to get any of
them to work (for example, pcor and pcor.test from the ggm
I'm trying to write code to calculate partial correlations (along with
p-values). I'm new to R, and I don't know how to do this. I have searched
and come across different functions, but I haven't been able to get any of
them to work (for example, pcor and pcor.test from the ggm package).
In the
10 matches
Mail list logo