R-squared can only be obtained for a linear model, so we perform linear regression in R as follows:
# Create a model using linear regression
clinical_model <- lm(PHENO ~ Age + Sex + height + weight + physical_activity + meat + smoking + alcohol + father_cancer + mother_cancer + sibling_cancer + polyps + crohns_disease + ulcerative_colitis, data = merged_df, family = binomial)
# Compute R2
clinical_rsq <- summary(clinical_model)$r.squared
# Print R2
print(clinical_rsq)
Area under the curve (AUC)
# Get predicted probabilities
probs_clinical <- predict(model_clinical, type = "response", newdata = merged_df)
# Compute AUC
auc_clinical <- roc(merged_df$PHENO, predict(model_clinical, type = "response"))$auc
# Print AUC
print(auc_clinical)