Assessing rmcorr asumptions: Error in shapiro.test(res) : all 'x' values are identical

Hi guys,
I'am using rmcorr package to make some repeated measures correlations based on a code that a colleague of mine built. code for making the correlation matrix:

library(rmcorr)
for(i in 24:46){#colunas com citocinas
for(n in 1:23){#colunas com OTUs ASVs etc
r=rmcorr(longitudinal_data_f$sampleID,longitudinal_data_f[,i],longitudinal_data_f[,n],dataset = longitudinal_data_f)
Matriz_corr[i-23,n]=r$r#Mudar número para a primeira coluna das citocinas menos 1.
Pvalues[i-23,n]=r$p#Mudar número para a primeira coluna das citocinas menos 1.
}
}

colnames(Matriz_corr)=colnames(longitudinal_data_f)[1:23]
rownames(Matriz_corr)=colnames(Matriz_corr)

Today while assessing the normality of the residuals of the models with the following code:
normal_test=as.data.frame(NULL)
library(rmcorr)
for(i in 24:46){
for(n in 1:23){
r=rmcorr(longitudinal_data_f$sampleID,longitudinal_data_f[,i],longitudinal_data_f[,n],dataset = longitudinal_data_f)
res=residuals(r$model)
shap=shapiro.test(res)[2]
normal_test[i-23,n]=shap
}
}
I was surprised with the following error: Error in shapiro.test(res) : all 'x' values are identical. (and in fact all the residuals of the correlation where it occurred were all zeroes)
I am still learning how to code in R, can anyone help me to modify the code in order to be able to:

  1. remove all the correlations with none residuals variance
    or
  2. to overcome cases like this one and continue testing for the remaining correlations.

thank you in advance, best
Sara

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.