d <- read.csv('https://stats.dip.jp/01_ds/data/real_estate_price.csv')[,-1]
library(DT)
datatable(d)
library(psych)
pairs.panels(d)

library(ggcorrplot)
library(plotly)
cor(d) |> ggcorrplot(lab = T, hc.order = T, outline.color = "white", p.mat = cor_pmat(d)) |> ggplotly() |>
layout(font = list(size = 11, color = 'blue', family = 'UD Digi Kyokasho NK-R'),
title = '新台湾市の住宅価格',
xaxis = list(title = 'x軸'),
yaxis = list(title = 'y軸'))
fit <- lm(price ~ yr + yrs_old + m_sta + nstores + lat + lon, data = d)
summary(fit)
##
## Call:
## lm(formula = price ~ yr + yrs_old + m_sta + nstores + lat + lon,
## data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -35.520 -5.272 -0.992 4.165 75.338
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.860e+03 6.349e+03 -1.553 0.12124
## yr 2.937e+00 9.503e-01 3.091 0.00213 **
## yrs_old -2.747e-01 3.864e-02 -7.110 5.25e-12 ***
## m_sta -4.370e-03 7.168e-04 -6.097 2.51e-09 ***
## nstores 1.162e+00 1.883e-01 6.171 1.64e-09 ***
## lat 2.345e+02 4.450e+01 5.269 2.23e-07 ***
## lon -1.534e+01 4.870e+01 -0.315 0.75301
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.872 on 407 degrees of freedom
## Multiple R-squared: 0.581, Adjusted R-squared: 0.5748
## F-statistic: 94.06 on 6 and 407 DF, p-value: < 2.2e-16
library(sjPlot)
tab_model(fit, show.stat = T, show.aic = T)
|
price
|
Predictors
|
Estimates
|
CI
|
Statistic
|
p
|
(Intercept)
|
-9859.50
|
-22341.02 – 2622.02
|
-1.55
|
0.121
|
yr
|
2.94
|
1.07 – 4.81
|
3.09
|
0.002
|
yrs old
|
-0.27
|
-0.35 – -0.20
|
-7.11
|
<0.001
|
m sta
|
-0.00
|
-0.01 – -0.00
|
-6.10
|
<0.001
|
nstores
|
1.16
|
0.79 – 1.53
|
6.17
|
<0.001
|
lat
|
234.47
|
147.00 – 321.94
|
5.27
|
<0.001
|
lon
|
-15.34
|
-111.08 – 80.40
|
-0.31
|
0.753
|
Observations
|
414
|
R2 / R2 adjusted
|
0.581 / 0.575
|
AIC
|
2991.283
|
plot_model(fit, show.values = T, show.intercept = T, width = 0.1)

plot(fit)



