Skip to main content
added 58 characters in body; edited tags
Source Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
# Model-1
M1X1 <- lm(YHousePriceOfUnitArea~X1TransactionDate, data=rev_data_clean)
summary(M1X1)

M1X2 <- lm(YHousePriceOfUnitArea~X2HouseAge, data=rev_data_clean)
summary(M1X2)

M1X3 <- lm(YHousePriceOfUnitArea~X3distanceToTheNearestMRTstation, data=rev_data_clean)
summary(M1X3)

M1X4 <- lm(YHousePriceOfUnitArea~X4NumberOfConvenienceStores, data=rev_data_clean)
summary(M1X4)

M1X5 <- lm(YHousePriceOfUnitArea~X5Latitude, data=rev_data_clean)
summary(M1X5)

M1X6 <- lm(YHousePriceOfUnitArea~X6Longitude, data=rev_data_clean)
summary(M1X6)

# Comparing the best version of model-1
summary(M1X1)$adj.r.squared
summary(M1X2)$adj.r.squared
summary(M1X3)$adj.r.squared
summary(M1X4)$adj.r.squared
summary(M1X5)$adj.r.squared
summary(M1X6)$adj.r.squared

# p-values for versions of model-1
summary(M1X1)$coefficients[2, 4]
summary(M1X2)$coefficients[2, 4]
summary(M1X3)$coefficients[2, 4]
summary(M1X4)$coefficients[2, 4]
summary(M1X5)$coefficients[2, 4]
summary(M1X6)$coefficients[2, 4]
# Model-1
M1X1 <- lm(YHousePriceOfUnitArea ~ X1TransactionDate, 
              data=rev_data_clean)
summary(M1X1)

M1X2 <- lm(YHousePriceOfUnitArea ~ X2HouseAge, data=rev_data_clean)
summary(M1X2)

M1X3 <- lm(YHousePriceOfUnitArea ~ X3distanceToTheNearestMRTstation, 
            data=rev_data_clean)
summary(M1X3)

M1X4 <- lm(YHousePriceOfUnitArea ~ X4NumberOfConvenienceStores, 
            data=rev_data_clean)
summary(M1X4)

M1X5 <- lm(YHousePriceOfUnitArea ~ X5Latitude, data=rev_data_clean)
summary(M1X5)

M1X6 <- lm(YHousePriceOfUnitArea ~ X6Longitude, data=rev_data_clean)
summary(M1X6)

# Comparing the best version of model-1
summary(M1X1)$adj.r.squared
summary(M1X2)$adj.r.squared
summary(M1X3)$adj.r.squared
summary(M1X4)$adj.r.squared
summary(M1X5)$adj.r.squared
summary(M1X6)$adj.r.squared

# p-values for versions of model-1
summary(M1X1)$coefficients[2, 4]
summary(M1X2)$coefficients[2, 4]
summary(M1X3)$coefficients[2, 4]
summary(M1X4)$coefficients[2, 4]
summary(M1X5)$coefficients[2, 4]
summary(M1X6)$coefficients[2, 4]
# Comparing the best version of model-1
> summary(M1X1)$adj.r.squared
[1] 0.005246001
> summary(M1X2)$adj.r.squared
[1] 0.04201891
> summary(M1X3)$adj.r.squared
[1] 0.4524284
> summary(M1X4)$adj.r.squared
[1] 0.3244108
> summary(M1X5)$adj.r.squared
[1] 0.2967482
> summary(M1X6)$adj.r.squared
[1] 0.2720662
> 
> # p-values for versions of model-1
> summary(M1X1)$coefficients[2, 4]
[1] 0.07537113
> summary(M1X2)$coefficients[2, 4]
[1] 1.560426e-05
> summary(M1X3)$coefficients[2, 4]
[1] 4.639825e-56
> summary(M1X4)$coefficients[2, 4]
[1] 3.413483e-37
> summary(M1X5)$coefficients[2, 4]
[1] 1.387761e-33
> summary(M1X6)$coefficients[2, 4]
[1] 1.765191e-30
# Comparing the best version of model-1
> summary(M1X1)$adj.r.squared
[1] 0.005246001
> summary(M1X2)$adj.r.squared
[1] 0.04201891
> summary(M1X3)$adj.r.squared
[1] 0.4524284
> summary(M1X4)$adj.r.squared
[1] 0.3244108
> summary(M1X5)$adj.r.squared
[1] 0.2967482
> summary(M1X6)$adj.r.squared
[1] 0.2720662
> 
> # p-values for versions of model-1
> summary(M1X1)$coefficients[2, 4]
[1] 0.07537113
> summary(M1X2)$coefficients[2, 4]
[1] 1.560426e-05
> summary(M1X3)$coefficients[2, 4]
[1] 4.639825e-56
> summary(M1X4)$coefficients[2, 4]
[1] 3.413483e-37
> summary(M1X5)$coefficients[2, 4]
[1] 1.387761e-33
> summary(M1X6)$coefficients[2, 4]
[1] 1.765191e-30
# Model-1
M1X1 <- lm(YHousePriceOfUnitArea~X1TransactionDate, data=rev_data_clean)
summary(M1X1)

M1X2 <- lm(YHousePriceOfUnitArea~X2HouseAge, data=rev_data_clean)
summary(M1X2)

M1X3 <- lm(YHousePriceOfUnitArea~X3distanceToTheNearestMRTstation, data=rev_data_clean)
summary(M1X3)

M1X4 <- lm(YHousePriceOfUnitArea~X4NumberOfConvenienceStores, data=rev_data_clean)
summary(M1X4)

M1X5 <- lm(YHousePriceOfUnitArea~X5Latitude, data=rev_data_clean)
summary(M1X5)

M1X6 <- lm(YHousePriceOfUnitArea~X6Longitude, data=rev_data_clean)
summary(M1X6)

# Comparing the best version of model-1
summary(M1X1)$adj.r.squared
summary(M1X2)$adj.r.squared
summary(M1X3)$adj.r.squared
summary(M1X4)$adj.r.squared
summary(M1X5)$adj.r.squared
summary(M1X6)$adj.r.squared

# p-values for versions of model-1
summary(M1X1)$coefficients[2, 4]
summary(M1X2)$coefficients[2, 4]
summary(M1X3)$coefficients[2, 4]
summary(M1X4)$coefficients[2, 4]
summary(M1X5)$coefficients[2, 4]
summary(M1X6)$coefficients[2, 4]
# Comparing the best version of model-1
> summary(M1X1)$adj.r.squared
[1] 0.005246001
> summary(M1X2)$adj.r.squared
[1] 0.04201891
> summary(M1X3)$adj.r.squared
[1] 0.4524284
> summary(M1X4)$adj.r.squared
[1] 0.3244108
> summary(M1X5)$adj.r.squared
[1] 0.2967482
> summary(M1X6)$adj.r.squared
[1] 0.2720662
> 
> # p-values for versions of model-1
> summary(M1X1)$coefficients[2, 4]
[1] 0.07537113
> summary(M1X2)$coefficients[2, 4]
[1] 1.560426e-05
> summary(M1X3)$coefficients[2, 4]
[1] 4.639825e-56
> summary(M1X4)$coefficients[2, 4]
[1] 3.413483e-37
> summary(M1X5)$coefficients[2, 4]
[1] 1.387761e-33
> summary(M1X6)$coefficients[2, 4]
[1] 1.765191e-30
# Model-1
M1X1 <- lm(YHousePriceOfUnitArea ~ X1TransactionDate, 
              data=rev_data_clean)
summary(M1X1)

M1X2 <- lm(YHousePriceOfUnitArea ~ X2HouseAge, data=rev_data_clean)
summary(M1X2)

M1X3 <- lm(YHousePriceOfUnitArea ~ X3distanceToTheNearestMRTstation, 
            data=rev_data_clean)
summary(M1X3)

M1X4 <- lm(YHousePriceOfUnitArea ~ X4NumberOfConvenienceStores, 
            data=rev_data_clean)
summary(M1X4)

M1X5 <- lm(YHousePriceOfUnitArea ~ X5Latitude, data=rev_data_clean)
summary(M1X5)

M1X6 <- lm(YHousePriceOfUnitArea ~ X6Longitude, data=rev_data_clean)
summary(M1X6)

# Comparing the best version of model-1
summary(M1X1)$adj.r.squared
summary(M1X2)$adj.r.squared
summary(M1X3)$adj.r.squared
summary(M1X4)$adj.r.squared
summary(M1X5)$adj.r.squared
summary(M1X6)$adj.r.squared

# p-values for versions of model-1
summary(M1X1)$coefficients[2, 4]
summary(M1X2)$coefficients[2, 4]
summary(M1X3)$coefficients[2, 4]
summary(M1X4)$coefficients[2, 4]
summary(M1X5)$coefficients[2, 4]
summary(M1X6)$coefficients[2, 4]
# Comparing the best version of model-1
> summary(M1X1)$adj.r.squared
[1] 0.005246001
> summary(M1X2)$adj.r.squared
[1] 0.04201891
> summary(M1X3)$adj.r.squared
[1] 0.4524284
> summary(M1X4)$adj.r.squared
[1] 0.3244108
> summary(M1X5)$adj.r.squared
[1] 0.2967482
> summary(M1X6)$adj.r.squared
[1] 0.2720662
> 
> # p-values for versions of model-1
> summary(M1X1)$coefficients[2, 4]
[1] 0.07537113
> summary(M1X2)$coefficients[2, 4]
[1] 1.560426e-05
> summary(M1X3)$coefficients[2, 4]
[1] 4.639825e-56
> summary(M1X4)$coefficients[2, 4]
[1] 3.413483e-37
> summary(M1X5)$coefficients[2, 4]
[1] 1.387761e-33
> summary(M1X6)$coefficients[2, 4]
[1] 1.765191e-30
Post Migrated Here from stackoverflow.com (revisions)
Source Link
NeehanthReddy
NeehanthReddy

Comparing single variable linear model in R

I have a dataset with 6 features and build simple linear regression with one feature at a time. I considered Adjusted R-squared values and p-values to compare and determine the best simple linear regression model among those models.

# Model-1
M1X1 <- lm(YHousePriceOfUnitArea~X1TransactionDate, data=rev_data_clean)
summary(M1X1)

M1X2 <- lm(YHousePriceOfUnitArea~X2HouseAge, data=rev_data_clean)
summary(M1X2)

M1X3 <- lm(YHousePriceOfUnitArea~X3distanceToTheNearestMRTstation, data=rev_data_clean)
summary(M1X3)

M1X4 <- lm(YHousePriceOfUnitArea~X4NumberOfConvenienceStores, data=rev_data_clean)
summary(M1X4)

M1X5 <- lm(YHousePriceOfUnitArea~X5Latitude, data=rev_data_clean)
summary(M1X5)

M1X6 <- lm(YHousePriceOfUnitArea~X6Longitude, data=rev_data_clean)
summary(M1X6)

# Comparing the best version of model-1
summary(M1X1)$adj.r.squared
summary(M1X2)$adj.r.squared
summary(M1X3)$adj.r.squared
summary(M1X4)$adj.r.squared
summary(M1X5)$adj.r.squared
summary(M1X6)$adj.r.squared

# p-values for versions of model-1
summary(M1X1)$coefficients[2, 4]
summary(M1X2)$coefficients[2, 4]
summary(M1X3)$coefficients[2, 4]
summary(M1X4)$coefficients[2, 4]
summary(M1X5)$coefficients[2, 4]
summary(M1X6)$coefficients[2, 4]

Console output:

# Comparing the best version of model-1
> summary(M1X1)$adj.r.squared
[1] 0.005246001
> summary(M1X2)$adj.r.squared
[1] 0.04201891
> summary(M1X3)$adj.r.squared
[1] 0.4524284
> summary(M1X4)$adj.r.squared
[1] 0.3244108
> summary(M1X5)$adj.r.squared
[1] 0.2967482
> summary(M1X6)$adj.r.squared
[1] 0.2720662
> 
> # p-values for versions of model-1
> summary(M1X1)$coefficients[2, 4]
[1] 0.07537113
> summary(M1X2)$coefficients[2, 4]
[1] 1.560426e-05
> summary(M1X3)$coefficients[2, 4]
[1] 4.639825e-56
> summary(M1X4)$coefficients[2, 4]
[1] 3.413483e-37
> summary(M1X5)$coefficients[2, 4]
[1] 1.387761e-33
> summary(M1X6)$coefficients[2, 4]
[1] 1.765191e-30

My comparison: If the Adjusted R-squared value is more and p-value is less, then that model is the better one. I this case, with higher Adjusted R-squared value and lower p-value M1X3 model seems to be the best one.

I want to confirm, whether my comparison is wright or wrong.