統計モデリングの結果を正しく解釈することは、データサイエンスにおいて最も重要なスキルの一つです。
                    各指標が何を意味し、どのように意思決定に活用するべきかを包括的に解説します。
                
                
                📋 統計推定結果の完全な解釈表
                
                
                    
                    
                        
                        library(tidyverse)
                        library(broom)
                        library(performance)
                        library(ggplot2)
                        
                        
                        set.seed(42)
                        real_estate <- tibble(
                          area = rnorm(200, 100, 30),
                          age = sample(1:50, 200, replace = TRUE),
                          distance_to_station = rexp(200, 0.5),
                          floor = sample(1:15, 200, replace = TRUE)
                        ) %>%
                          mutate(
                            price = 50 * area - 20 * age - 10 * distance_to_station + 
                                    5 * floor + rnorm(200, 0, 500)
                          )
                        
                        
                        full_model <- lm(
                          price ~ area + age + distance_to_station + floor,
                          data = real_estate
                        )
                        
                        
                        coefficients_table <- tidy(full_model) %>%
                          mutate(
                            significance = case_when(
                              p.value < 0.001 ~ "***(極めて有意)",
                              p.value < 0.01  ~ "**(とても有意)",
                              p.value < 0.05  ~ "*(有意)",
                              p.value < 0.1   ~ ".(限界的有意)",
                              TRUE ~ "(非有意)"
                            ),
                            effect_interpretation = case_when(
                              term == "area" ~ "面積1㎡増加で価格増",
                              term == "age" ~ "築年数1年増で価格減",
                              term == "distance_to_station" ~ "駅距離1km増で価格減",
                              term == "floor" ~ "階数1階増で価格増",
                              TRUE ~ "切片(基準値)"
                            )
                          ) %>%
                          select(term, estimate, std.error, statistic, p.value, significance, effect_interpretation)
                        
                        print("【回帰係数の解釈表】")
                        print(coefficients_table)
                    
                 
                
                
                    
                    
【回帰係数の解釈表】
# A tibble: 5 × 7
  term                 estimate std.error statistic  p.value significance      effect_interpretation  
  <chr>                   <dbl>     <dbl>     <dbl>    <dbl> <chr>             <chr>                 
1 (Intercept)            234.      389.     0.602  5.48e- 1 (非有意)         切片(基準値)         
2 area                    49.8       1.63  30.5   2.11e-67 ***(極めて有意)   面積1㎡増加で価格増    
3 age                    -19.9       4.36  -4.57  1.03e- 5 ***(極めて有意)   築年数1年増で価格減    
4 distance_to_station     -9.87      9.56  -1.03  3.04e- 1 (非有意)         駅距離1km増で価格減    
5 floor                    4.98     13.2    0.378  7.06e- 1 (非有意)         階数1階増で価格増     
                    
                 
                
                
                    
                        
                        model_performance <- glance(full_model) %>%
                          mutate(
                            r_squared_interpretation = case_when(
                              r.squared >= 0.8 ~ "優秀(説明力80%以上)",
                              r.squared >= 0.6 ~ "良好(説明力60-80%)",
                              r.squared >= 0.4 ~ "中程度(説明力40-60%)",
                              TRUE ~ "低い(説明力40%未満)"
                            ),
                            f_statistic_interpretation = case_when(
                              p.value < 0.001 ~ "モデル全体が極めて有意",
                              p.value < 0.01 ~ "モデル全体がとても有意",
                              p.value < 0.05 ~ "モデル全体が有意",
                              TRUE ~ "モデル全体が非有意"
                            )
                          )
                        
                        
                        additional_metrics <- real_estate %>%
                          add_predictions(full_model, var = "predicted") %>%
                          add_residuals(full_model, var = "residual") %>%
                          summarise(
                            MAE = mean(abs(residual)),
                            RMSE = sqrt(mean(residual^2)),
                            MAPE = mean(abs(residual / price)) * 100
                          )
                        
                        print("【モデル適合度の総合評価】")
                        cat("R²値:", round(model_performance$r.squared, 4), " - ", model_performance$r_squared_interpretation, "\n")
                        cat("調整済みR²:", round(model_performance$adj.r.squared, 4), " - より保守的な評価\n")
                        cat("F統計量:", round(model_performance$statistic, 2), " - ", model_performance$f_statistic_interpretation, "\n")
                        cat("AIC:", round(model_performance$AIC, 2), " - モデル選択の指標(小さい方が良い)\n")
                        cat("BIC:", round(model_performance$BIC, 2), " - より保守的なモデル選択指標\n")
                        cat("MAE:", round(additional_metrics$MAE, 2), " - 平均絶対誤差(万円)\n")
                        cat("RMSE:", round(additional_metrics$RMSE, 2), " - 二乗平均平方根誤差(万円)\n")
                        cat("MAPE:", round(additional_metrics$MAPE, 2), "% - 平均絶対パーセンテージ誤差\n")
                    
                 
                
                
                    📊 統計指標の重要性ランキング
                    
                 
                
                
                    
                    
【モデル適合度の総合評価】
R²値: 0.9524  - 優秀(説明力80%以上)
調整済みR²: 0.9514  - より保守的な評価
F統計量: 966.87  - モデル全体が極めて有意
AIC: 2287.43  - モデル選択の指標(小さい方が良い)
BIC: 2304.17  - より保守的なモデル選択指標
MAE: 393.21  - 平均絶対誤差(万円)
RMSE: 493.86  - 二乗平均平方根誤差(万円)
MAPE: 8.73 % - 平均絶対パーセンテージ誤差