source('../../Data/get_state_health_data.R') DF = get_state_health_data() target_state ='Missouri' col_sd = apply(DF[, 2:7], 2, sd) ## ## Maybe there is a better way at doing this but I'm going to just randomly look for coefficients ## until I find a set that works ... unfortunately this does not ever seem to find any ... ## n_mc = 1000 for( ii in 1:n_mc ){ ##coeffs = c(abs(rnorm(3)), -abs(rnorm(3))) coeffs = c(abs(rnorm(3, sd=col_sd[1:3])), -abs(rnorm(3, sd=col_sd[4:6]))) health = as.matrix(DF[, 2:dim(DF)[2]]) %*% coeffs os = order(health, decreasing=FALSE) if( DF[os[1], ]$state == target_state ){ print(coeffs) break } }