以下のコードを入力すると、表にそのままコピペできる形になります。
output に、本文中で使える (Estimate = ., SE = ., = . , z = ., p < .) の形に出力してくれます。
outputTable に、エクセルでデータ分割をすればそのまま貼り付けられるようにできるデータが入っています。
# GLMMを実行し、summaryの結果を表示する
summary_result <- summary(作成したモデルの名前)
# 固定効果の抽出
fixed_effects <- round(summary_result$coefficients[,"Estimate"], 3)
se <- round(summary_result$coefficients[,"Std. Error"], 3)
z_values <- round(summary_result$coefficients[,"z value"], 3)
p_values <- summary_result$coefficients[,"Pr(>|z|)"]
#p値の整形
p_values_text <- ifelse(p_values < 0.001, "p < .001", paste("p =", gsub("^0", "", formatC(p_values, format = "f", digits = 3))))
#整形した結果の出力
output <- matrix(paste("Estimate =", fixed_effects, ", SE =", se, ", z value =", z_values, ",", p_values_text, sep = " "), ncol = 1)
outputTable <- matrix(paste(fixed_effects, se, z_values, p_values_text, sep = ","), ncol = 1)
colnames(output) <- "Fixed Effects"
print(output)
print(outputTable)