Re: [R] Partial correlations and p-values

2009-12-05 Thread Juliet Hannah
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

Re: [R] Partial correlations and p-values

2009-12-05 Thread Charles C. Berry
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

Re: [R] Partial correlations and p-values

2009-12-05 Thread David Freedman
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

Re: [R] Partial correlations and p-values

2009-12-01 Thread dadrivr
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 -

Re: [R] Partial correlations and p-values

2009-11-12 Thread Ista Zahn
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

Re: [R] Partial correlations and p-values

2009-11-12 Thread dadrivr
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

Re: [R] Partial correlations and p-values

2009-11-12 Thread Peter Ehlers
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

[R] Partial correlations and p-values

2009-11-11 Thread dadrivr
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

Re: [R] Partial correlations and p-values

2009-11-11 Thread Peter Ehlers
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

Re: [R] Partial correlations and p-values

2009-11-11 Thread dadrivr
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 -