In JMP Multivariate Methods, REML is used to estimate correlation when there are missing data values (pg. 28). However, there is no documentation describing how this is done.
I'm trying to compare my results in R with my results in JMP. However, in R, I don't know of a way to calculate correlation or covariance when there are NAs (without removing the row with the NA value). In JMP it appears they don't drop the row, so JMP somehow includes the data in the estimation of correlation and covariance. Is there a way to replicate the JMP results in R? Here is an example dataset:
Var1 Var2
0.0079 0.0046
0.0136 0.0080
0.0270 0.0108
0.0287 0.0263
0.0325 0.0400
0.0228 0.0163
0.0015 0.0014
0.1198 0.0869
0.0054 0.0046
In R:
# No NAs
df <- data.frame("Var1" = c(0.0079, 0.0136, 0.0270, 0.0287, 0.0325, 0.0228, 0.0015, 0.1198, 0.0054),
"Var2" = c(0.0046, 0.0080, 0.0108, 0.0263, 0.0400, 0.0163, 0.0014, 0.0869, 0.0046))
df_cor <- cor(df$Var1, df$Var2) # result: 0.9685043
# With NA in first row
df_withNA <- data.frame("Var1" = c(0.0079, 0.0136, 0.0270, 0.0287, 0.0325, 0.0228, 0.0015, 0.1198, 0.0054),
"Var2" = c(NA, 0.0080, 0.0108, 0.0263, 0.0400, 0.0163, 0.0014, 0.0869, 0.0046))
df_withNA_cor <- cor(df_withNA$Var1, df_withNA$Var2) # result: NA
# Drop row with NA
df_dropNA_cor <- cor(df_withNA$Var1, df_withNA$Var2, use = "pairwise.complete.obs")
# result: 0.9670248
Here is the output in JMP where they use REML to estimate the correlation when the first value of Var1 is empty (equivalent to NA):
# JMP Correlation between Var1 and Var2 with missing value: 0.9646
Can anyone explain to me how the JMP value is calculated when there is a missing value? Is there a way to calculate correlation in R when there are missing values?