How would you rank cities? Various organizations rank cities and produce lists of the 10 or the 100 best based on various measures. Create a list of criteria that you would use to rank cities. Include at least eight variables and give reasons for your choices. Say whether each variable is quantitative or categorical.
# 9.26 # Variable selection (step wise selection) (Ch6) data=read.csv(file.choose()) data=data[-1] # x1:x7 are quantative factors # We will try to use all 7 independent varibales (predictors) to predict y (exclude the first column) m1=lm(y~.,data) # m1 is not adequate to predict y # Before fitting regression, check correlations first cor.test(data[,2], data[,3])$p.value cor.test(data[,2], data[,4])$p.value cor.test(data[,2], data[,5])$p.value cor.test(data[,2], data[,6])$p.value cor.test(data[,2], data[,7])$p.value # non is significant # try to apply coding procedure to minimize the standard error # create a new matrix and store the coding procedure variables data1=matrix(0,nrow(data), 8) for (j in 2:9){ data1[,j-1]=(data[,j]-mean(data[,j]))/sd(data[,j])