The Economic Performance Ranking is a backward-looking measure based on three important variables: State Gross Domestic Product, Absolute Domestic Migration, Non-Farm Payroll Employment. These are all influenced by state policy. This ranking details states’ individual performances over the past 10 years based on this economic data. This dataset uses data ALEC-LAFFER report from 2021.
# Load the polygon file for data attributes and shapes
mtl<-rgdal::readOGR("tl_2012_us_state.shp")
## OGR data source with driver: ESRI Shapefile
## Source: "/Users/taurean/Library/CloudStorage/Box-Box/Taurean/Year_1/SSNA/tl_2012_us_state.shp", layer: "tl_2012_us_state"
## with 56 features
## It has 14 fields
## Integer64 fields read as strings: ALAND AWATER
"%ni%" <- Negate("%in%") #negate funtion
mtl<-mtl[mtl$NAME %ni% c('Alaska','American Samoa','Commonwealth of the Northern Mariana Islands','Guam','Hawaii','United States Virgin Islands','Puerto Rico', 'District of Columbia'),]
# Create the neighbor object from
sids_nbq<-poly2nb(mtl, queen=TRUE)#neighboring structure
list_neigh<- nb2listw(sids_nbq)#,zero.policy=T)
coords<-coordinates(mtl)
#Read the attributes of state wealth and apply to mtl data object
a<-read.csv("state_wealth_2021.csv", header = TRUE)
head(a)
## Rank State StateGross AbsMigration NonFarmPay ID
## 1 28 Alabama 37 28 18 Alabama
## 2 48 Alaska 50 48 32 Alaska
## 3 7 Arizona 14 7 4 Arizona
## 4 26 Arkansas 36 26 20 Arkansas
## 5 16 California 4 10 49 California
## 6 2 Colorado 6 2 6 Colorado
mtl@data$wealth<-as.numeric(a$Rank[match(mtl@data$NAME,a$ID)])#preserves the structure
mtl@data$gross<-as.numeric(a$StateGross[match(mtl@data$NAME,a$ID)])#preserves the structure
mtl@data$absmigration<-as.numeric(a$AbsMigration[match(mtl@data$NAME,a$ID)])#preserves the structure
mtl@data$nonfarm<-as.numeric(a$NonFarmPay[match(mtl@data$NAME,a$ID)])#preserves the structure
#Check to see if economic data is added to the @data
head(mtl@data)
## REGION DIVISION STATEFP STATENS GEOID STUSPS NAME LSAD MTFCC
## 1 3 7 05 00068085 05 AR Arkansas 00 G4000
## 2 4 8 35 00897535 35 NM New Mexico 00 G4000
## 3 4 8 30 00767982 30 MT Montana 00 G4000
## 4 1 2 36 01779796 36 NY New York 00 G4000
## 5 2 4 38 01779797 38 ND North Dakota 00 G4000
## 6 2 4 46 01785534 46 SD South Dakota 00 G4000
## FUNCSTAT ALAND AWATER INTPTLAT INTPTLON wealth gross
## 1 A 134772564356 2959210006 +34.8955256 -092.4446262 26 36
## 2 A 314161109357 756438507 +34.4346843 -106.1316181 43 44
## 3 A 376963571188 3868564895 +47.0511771 -109.6348174 15 20
## 4 A 122057936950 19238848209 +42.9133974 -075.5962723 23 11
## 5 A 178708828162 4398957088 +47.4421698 -100.4608163 12 1
## 6 A 196348898983 3379914826 +44.4467957 -100.2381762 17 15
## absmigration nonfarm
## 1 26 20
## 2 42 34
## 3 20 14
## 4 17 50
## 5 15 17
## 6 31 19
From our positive Moran’s I we can determine there is spatial dependence based on neighboring states. Our connection weight used the the Queen’s neighbor cluster, meaning states with borders with each other are influencing the ranked wealth of their neighbors. You can see that in the graph of quantiles, where states with high wealth appear next to other similarly quantiled (wealth states). The positive value indicates they are clustering in a way that high wealth states and low wealth states are not randomly distributed and there is clustering. Based on the p-value this spatial dependence is significant (p <.05; p = 0.00783).
library(RColorBrewer)
library(classInt)
nclr <- 9
plotvar <- mtl@data$wealth
plotclr <- brewer.pal(nclr, "YlOrRd")
class <- classIntervals(plotvar, nclr, style = "quantile")
colcode <- findColours(class, plotclr, digits = 2)
plot(mtl, border="gray20", bg="slategray", col=colcode)
plot(sids_nbq, coords, col = rgb(205, 204,0, 255,max=255), lwd = 2, add=T)
legend("bottomright", legend=names(attr(colcode, "table")),
fill = attr(colcode, "palette"), title="Ranked Wealth")
moran.test(mtl@data$wealth,list_neigh, na.action=na.exclude)
##
## Moran I test under randomisation
##
## data: mtl@data$wealth
## weights: list_neigh
##
## Moran I statistic standard deviate = 2.4168, p-value = 0.00783
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.212506980 -0.021276596 0.009357522
title(main=paste("States wealth distribution as of 2021 from neighbors\nMoran's I = ", round(moran.test(mtl@data$wealth,list_neigh, zero.policy=TRUE, na.action=na.exclude)$estimate[1],4), "(p<", round(moran.test(mtl@data$wealth,list_neigh, zero.policy=TRUE, na.action=na.exclude)$ p.value,10), ")"), sub="Data source: American Community Survey, 2021 estimates\nALEC-LAFFER STATE ECONOMIC COMPETITIVENESS INDEX\nAvailable from:https://www.richstatespoorstates.org/app/uploads/2021/05/2021-Rich-States-Poor-States-14th-Edition.pdf")
In graph 2, we create a list of random connections and weights between states. Our Moran I does not indicate spatial significance which is what expected given these random connections that were created and sampled.
# install.packages('gtools')
library(gtools)
z<-(permutations(n=length(as.character(mtl@data$NAME)),r=2,v=as.character(mtl@data$NAME),repeats.allowed=T))
z<-z[z[,1]!=z[,2],]#remove selfselction
z<-as.data.frame(z)
head(z)
## V1 V2
## 1 Alabama Arizona
## 2 Alabama Arkansas
## 3 Alabama California
## 4 Alabama Colorado
## 5 Alabama Connecticut
## 6 Alabama Delaware
set.seed(47)
z<-z[sample(nrow(z), 200), ]
library(igraph)
##
## Attaching package: 'igraph'
## The following object is masked from 'package:gtools':
##
## permute
## The following object is masked from 'package:tigris':
##
## blocks
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
g<-graph.data.frame(z,directed = FALSE)
g
## IGRAPH 276e5a4 UN-- 48 200 --
## + attr: name (v/c)
## + edges from 276e5a4 (vertex names):
## [1] Maine --Arizona Kansas --Washington
## [3] Louisiana --Michigan Connecticut --Missouri
## [5] Michigan --New York Virginia --Tennessee
## [7] Michigan --Indiana Minnesota --Idaho
## [9] Minnesota --Georgia South Carolina--New Mexico
## [11] Pennsylvania --New Hampshire Virginia --Florida
## [13] Iowa --Maryland Vermont --Wisconsin
## [15] Missouri --Arizona Indiana --Rhode Island
## + ... omitted several edges
z<-get.adjacency(g)
dim(z)
## [1] 48 48
z<-as.matrix(z)
#z[z>1]<-1 Only for presence or absence
summary(rowSums(z))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.000 7.000 8.000 8.333 10.000 13.000
g<-graph.adjacency(z)
g
## IGRAPH 9791abc DN-- 48 400 --
## + attr: name (v/c)
## + edges from 9791abc (vertex names):
## [1] Maine ->Louisiana Maine ->Alabama
## [3] Maine ->Mississippi Maine ->Oregon
## [5] Maine ->Arizona Maine ->Wisconsin
## [7] Kansas ->South Carolina Kansas ->Vermont
## [9] Kansas ->Mississippi Kansas ->Arizona
## [11] Kansas ->Delaware Kansas ->South Dakota
## [13] Kansas ->Washington Kansas ->Utah
## [15] Louisiana->Maine Louisiana->Michigan
## + ... omitted several edges
#fix(z)
z <-z /rowSums(z)
summary(rowSums(z))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1 1 1 1 1 1
#z[is.na(z)]<-0#this is for isolates
z <-z[order(rownames(z)), order(colnames(z))]
test.listwNew<-mat2listw(z)
summary(test.listwNew)
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 48
## Number of nonzero links: 388
## Percentage nonzero weights: 16.84028
## Average number of links: 8.083333
## Link number distribution:
##
## 3 4 5 6 7 8 9 10 11 12
## 2 1 3 2 8 14 7 5 2 4
## 2 least connected regions:
## Montana West Virginia with 3 links
## 4 most connected regions:
## Colorado Louisiana Maryland Mississippi with 12 links
##
## Weights style: M
## Weights constants summary:
## n nn S0 S1 S2
## M 48 2304 48 12.50866 197.5756
V(g)$weight<-1
g<-simplify(g)#
g
## IGRAPH f2ad575 DN-- 48 388 --
## + attr: name (v/c), weight (v/n)
## + edges from f2ad575 (vertex names):
## [1] Maine ->Louisiana Maine ->Alabama
## [3] Maine ->Mississippi Maine ->Oregon
## [5] Maine ->Arizona Maine ->Wisconsin
## [7] Kansas ->South Carolina Kansas ->Vermont
## [9] Kansas ->Mississippi Kansas ->Arizona
## [11] Kansas ->Delaware Kansas ->South Dakota
## [13] Kansas ->Washington Kansas ->Utah
## [15] Louisiana->Maine Louisiana->Michigan
## + ... omitted several edges
moran.test(mtl@data$wealth,test.listwNew, zero.policy=TRUE, na.action=na.exclude)
##
## Moran I test under randomisation
##
## data: mtl@data$wealth
## weights: test.listwNew
##
## Moran I statistic standard deviate = 0.45643, p-value = 0.324
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.009702298 -0.021276596 0.004606694
plot(mtl, border="gray20", bg="slategray", col=colcode)
plot(test.listwNew, coords, col = rgb(205, 204,0, 255/4,max=255), lwd = 2, add=T)
legend("bottomright", legend=names(attr(colcode, "table")),
fill = attr(colcode, "palette"), title="Ranked Wealth")
title(main=paste("States wealth distribution as of 2021 from random connections\nMoran's I = ", round(moran.test(mtl@data$wealth,test.listwNew, zero.policy=TRUE, na.action=na.exclude)$estimate[1],4), "(p<", moran.test(mtl@data$wealth,test.listwNew, zero.policy=TRUE, na.action=na.exclude)$ p.value, ")"), sub="Data source: US Census Shapefiles, 2018 estimates\nALEC-LAFFER STATE ECONOMIC COMPETITIVENESS INDEX\nAvailable from:https://www.richstatespoorstates.org/app/uploads/2021/05/2021-Rich-States-Poor-States-14th-Edition.pdf")
Using a dataset of universities, we check to see if tuition 2 varies based on nearest neighbors at the 1000 level.
#approaches based on points tenth assignment
url <- paste( 'http://nces.ed.gov/ipeds/datacenter/data/HD2016.zip')
url2 <- paste('http://nces.ed.gov/ipeds/datacenter/data/IC2016_AY.zip')
##This captures the working directory
a<-getwd()
a
## [1] "/Users/taurean/Library/CloudStorage/Box-Box/Taurean/Year_1/SSNA"
#Using the working directory information we download the data in that folder as follows
download.file(url, destfile = paste(a,"HD2016.zip",sep="/"))
#Loading the dataset
download.file(url2, destfile = paste(a,"IC2016_AY.zip",sep="/"))
a <- read.csv(unz("HD2016.zip", "hd2016.csv"))
names(a)
## [1] "UNITID" "INSTNM" "IALIAS" "ADDR" "CITY" "STABBR"
## [7] "ZIP" "FIPS" "OBEREG" "CHFNM" "CHFTITLE" "GENTELE"
## [13] "EIN" "DUNS" "OPEID" "OPEFLAG" "WEBADDR" "ADMINURL"
## [19] "FAIDURL" "APPLURL" "NPRICURL" "VETURL" "ATHURL" "DISAURL"
## [25] "SECTOR" "ICLEVEL" "CONTROL" "HLOFFER" "UGOFFER" "GROFFER"
## [31] "HDEGOFR1" "DEGGRANT" "HBCU" "HOSPITAL" "MEDICAL" "TRIBAL"
## [37] "LOCALE" "OPENPUBL" "ACT" "NEWID" "DEATHYR" "CLOSEDAT"
## [43] "CYACTIVE" "POSTSEC" "PSEFLAG" "PSET4FLG" "RPTMTH" "INSTCAT"
## [49] "C15BASIC" "C15IPUG" "C15IPGRD" "C15UGPRF" "C15ENPRF" "C15SZSET"
## [55] "CCBASIC" "CARNEGIE" "LANDGRNT" "INSTSIZE" "F1SYSTYP" "F1SYSNAM"
## [61] "F1SYSCOD" "CBSA" "CBSATYPE" "CSA" "NECTA" "COUNTYCD"
## [67] "COUNTYNM" "CNGDSTCD" "LONGITUD" "LATITUDE" "DFRCGID" "DFRCUSCG"
b<- read.csv(unz("IC2016_AY.zip", "ic2016_ay.csv"))
names(b)
## [1] "UNITID" "XTUIT1" "TUITION1" "XFEE1" "FEE1" "XHRCHG1"
## [7] "HRCHG1" "XTUIT2" "TUITION2" "XFEE2" "FEE2" "XHRCHG2"
## [13] "HRCHG2" "XTUIT3" "TUITION3" "XFEE3" "FEE3" "XHRCHG3"
## [19] "HRCHG3" "XTUIT5" "TUITION5" "XFEE5" "FEE5" "XHRCHG5"
## [25] "HRCHG5" "XTUIT6" "TUITION6" "XFEE6" "FEE6" "XHRCHG6"
## [31] "HRCHG6" "XTUIT7" "TUITION7" "XFEE7" "FEE7" "XHRCHG7"
## [37] "HRCHG7" "XISPRO1" "ISPROF1" "XISPFE1" "ISPFEE1" "XOSPRO1"
## [43] "OSPROF1" "XOSPFE1" "OSPFEE1" "XISPRO2" "ISPROF2" "XISPFE2"
## [49] "ISPFEE2" "XOSPRO2" "OSPROF2" "XOSPFE2" "OSPFEE2" "XISPRO3"
## [55] "ISPROF3" "XISPFE3" "ISPFEE3" "XOSPRO3" "OSPROF3" "XOSPFE3"
## [61] "OSPFEE3" "XISPRO4" "ISPROF4" "XISPFE4" "ISPFEE4" "XOSPRO4"
## [67] "OSPROF4" "XOSPFE4" "OSPFEE4" "XISPRO5" "ISPROF5" "XISPFE5"
## [73] "ISPFEE5" "XOSPRO5" "OSPROF5" "XOSPFE5" "OSPFEE5" "XISPRO6"
## [79] "ISPROF6" "XISPFE6" "ISPFEE6" "XOSPRO6" "OSPROF6" "XOSPFE6"
## [85] "OSPFEE6" "XISPRO7" "ISPROF7" "XISPFE7" "ISPFEE7" "XOSPRO7"
## [91] "OSPROF7" "XOSPFE7" "OSPFEE7" "XISPRO8" "ISPROF8" "XISPFE8"
## [97] "ISPFEE8" "XOSPRO8" "OSPROF8" "XOSPFE8" "OSPFEE8" "XISPRO9"
## [103] "ISPROF9" "XISPFE9" "ISPFEE9" "XOSPRO9" "OSPROF9" "XOSPFE9"
## [109] "OSPFEE9" "XCHG1AT0" "CHG1AT0" "XCHG1AF0" "CHG1AF0" "XCHG1AY0"
## [115] "CHG1AY0" "XCHG1AT1" "CHG1AT1" "XCHG1AF1" "CHG1AF1" "XCHG1AY1"
## [121] "CHG1AY1" "XCHG1AT2" "CHG1AT2" "XCHG1AF2" "CHG1AF2" "XCHG1AY2"
## [127] "CHG1AY2" "XCHG1AT3" "CHG1AT3" "XCHG1AF3" "CHG1AF3" "XCHG1AY3"
## [133] "CHG1AY3" "CHG1TGTD" "CHG1FGTD" "XCHG2AT0" "CHG2AT0" "XCHG2AF0"
## [139] "CHG2AF0" "XCHG2AY0" "CHG2AY0" "XCHG2AT1" "CHG2AT1" "XCHG2AF1"
## [145] "CHG2AF1" "XCHG2AY1" "CHG2AY1" "XCHG2AT2" "CHG2AT2" "XCHG2AF2"
## [151] "CHG2AF2" "XCHG2AY2" "CHG2AY2" "XCHG2AT3" "CHG2AT3" "XCHG2AF3"
## [157] "CHG2AF3" "XCHG2AY3" "CHG2AY3" "CHG2TGTD" "CHG2FGTD" "XCHG3AT0"
## [163] "CHG3AT0" "XCHG3AF0" "CHG3AF0" "XCHG3AY0" "CHG3AY0" "XCHG3AT1"
## [169] "CHG3AT1" "XCHG3AF1" "CHG3AF1" "XCHG3AY1" "CHG3AY1" "XCHG3AT2"
## [175] "CHG3AT2" "XCHG3AF2" "CHG3AF2" "XCHG3AY2" "CHG3AY2" "XCHG3AT3"
## [181] "CHG3AT3" "XCHG3AF3" "CHG3AF3" "XCHG3AY3" "CHG3AY3" "CHG3TGTD"
## [187] "CHG3FGTD" "XCHG4AY0" "CHG4AY0" "XCHG4AY1" "CHG4AY1" "XCHG4AY2"
## [193] "CHG4AY2" "XCHG4AY3" "CHG4AY3" "XCHG5AY0" "CHG5AY0" "XCHG5AY1"
## [199] "CHG5AY1" "XCHG5AY2" "CHG5AY2" "XCHG5AY3" "CHG5AY3" "XCHG6AY0"
## [205] "CHG6AY0" "XCHG6AY1" "CHG6AY1" "XCHG6AY2" "CHG6AY2" "XCHG6AY3"
## [211] "CHG6AY3" "XCHG7AY0" "CHG7AY0" "XCHG7AY1" "CHG7AY1" "XCHG7AY2"
## [217] "CHG7AY2" "XCHG7AY3" "CHG7AY3" "XCHG8AY0" "CHG8AY0" "XCHG8AY1"
## [223] "CHG8AY1" "XCHG8AY2" "CHG8AY2" "XCHG8AY3" "CHG8AY3" "XCHG9AY0"
## [229] "CHG9AY0" "XCHG9AY1" "CHG9AY1" "XCHG9AY2" "CHG9AY2" "XCHG9AY3"
## [235] "CHG9AY3"
a<-a[a$SECTOR==1|a$SECTOR==2,]
a<-a[a$LOCALE<14,]
dim(a)
## [1] 1250 72
a<-merge(a,b[,c("UNITID","TUITION2")], by="UNITID")
head(a)
## UNITID INSTNM
## 1 100654 Alabama A & M University
## 2 100663 University of Alabama at Birmingham
## 3 100690 Amridge University
## 4 100706 University of Alabama in Huntsville
## 5 100724 Alabama State University
## 6 100751 The University of Alabama
## IALIAS
## 1 AAMU
## 2
## 3 Southern Christian University |Regions University
## 4 UAH |University of Alabama Huntsville
## 5
## 6
## ADDR CITY STABBR ZIP FIPS OBEREG
## 1 4900 Meridian Street Normal AL 35762 1 5
## 2 Administration Bldg Suite 1070 Birmingham AL 35294-0110 1 5
## 3 1200 Taylor Rd Montgomery AL 36117-3553 1 5
## 4 301 Sparkman Dr Huntsville AL 35899 1 5
## 5 915 S Jackson Street Montgomery AL 36104-0271 1 5
## 6 739 University Blvd Tuscaloosa AL 35487-0166 1 5
## CHFNM CHFTITLE GENTELE EIN DUNS
## 1 Dr. Andrew Hugine, Jr. President 2.563725e+09 636001109 197216455
## 2 Ray L. Watts President 2.059344e+09 636005396 063690705
## 3 Michael Turner President 3.343877e+13 237034324 126307792
## 4 Robert A. Altenkirch President 2.568246e+09 630520830 949687123
## 5 Leon Wilson Interim President 3.342294e+09 636001101 040672685
## 6 Dr. Stuart R. Bell President 2.053486e+09 636001138 045632635
## OPEID OPEFLAG WEBADDR
## 1 100200 1 www.aamu.edu/
## 2 105200 1 www.uab.edu
## 3 2503400 1 www.amridgeuniversity.edu
## 4 105500 1 www.uah.edu
## 5 100500 1 www.alasu.edu
## 6 105100 1 www.ua.edu/
## ADMINURL
## 1 www.aamu.edu/Admissions/Pages/default.aspx
## 2 www.uab.edu/students/undergraduate-admissions
## 3 www.amridgeuniversity.edu/admissions/
## 4 admissions.uah.edu/
## 5 www.alasu.edu/admissions/index.aspx
## 6 gobama.ua.edu
## FAIDURL
## 1 www.aamu.edu/Admissions/fincialaid/Pages/default.aspx
## 2 www.uab.edu/students/paying-for-college
## 3 www.amridgeuniversity.edu/financial-aid/
## 4 finaid.uah.edu/
## 5 www.alasu.edu/cost-aid/index.aspx
## 6 financialaid.ua.edu
## APPLURL
## 1 www.aamu.edu/admissions/undergraduateadmissions/pages/undergraduate-application-checklist.aspx
## 2 https://idm.uab.edu/myuab/login?from=ugadmapp
## 3 https://www.amridgeuniversity.edu/myamridge/
## 4 register.uah.edu
## 5
## 6 apply.ua.edu
## NPRICURL
## 1 www2.aamu.edu/scripts/netpricecalc/npcalc.htm
## 2 uab.studentaidcalculator.com/survey.aspx
## 3 www2.amridgeuniversity.edu:9091/
## 4 finaid.uah.edu/
## 5 www.alasu.edu/cost-aid/forms/calculator/index.aspx
## 6 financialaid.ua.edu/net-price-calculator/
## VETURL
## 1
## 2 www.uab.edu/students/veterans
## 3 www.amridgeuniversity.edu/financial-aid/military/
## 4 www.uah.edu/admissions/graduate/financial-aid/veterans
## 5
## 6 registrar.ua.edu/policies/residency/residency-tuition/
## ATHURL
## 1 www.aamu.edu/administrativeoffices/irpsp/institutionalresearchandplanning/pages/default.aspx
## 2 www.uabsports.com/compliance/prospects-new.html
## 3
## 4 www.uah.edu/heoa
## 5 www.alasu.edu/search-results/index.aspx
## 6 registrar.ua.edu/policies/right-to-know
## DISAURL
## 1 www.aamu.edu/administrativeoffices/VADS/Pages/Disability-Services.aspx
## 2 www.uab.edu/students/disability/
## 3 www.amridgeuniversity.edu/pdf/Amridge%20University%20Academic%20Catalog%202016-2017.pdf
## 4 www.uah.edu/health-and-wellness/disability-support
## 5 www.alasu.edu/about-asu/the-campus/disability-accessibility/index.aspx
## 6 ods.ua.edu
## SECTOR ICLEVEL CONTROL HLOFFER UGOFFER GROFFER HDEGOFR1 DEGGRANT HBCU
## 1 1 1 1 9 1 1 12 1 1
## 2 1 1 1 9 1 1 11 1 2
## 3 2 1 2 9 1 1 12 1 2
## 4 1 1 1 9 1 1 11 1 2
## 5 1 1 1 9 1 1 11 1 1
## 6 1 1 1 9 1 1 11 1 2
## HOSPITAL MEDICAL TRIBAL LOCALE OPENPUBL ACT NEWID DEATHYR CLOSEDAT CYACTIVE
## 1 2 2 2 12 1 A -2 -2 -2 1
## 2 1 1 2 12 1 A -2 -2 -2 1
## 3 2 2 2 12 1 A -2 -2 -2 1
## 4 2 2 2 12 1 A -2 -2 -2 1
## 5 2 2 2 12 1 A -2 -2 -2 1
## 6 2 2 2 13 1 A -2 -2 -2 1
## POSTSEC PSEFLAG PSET4FLG RPTMTH INSTCAT C15BASIC C15IPUG C15IPGRD C15UGPRF
## 1 1 1 1 1 2 18 16 18 10
## 2 1 1 1 1 2 15 14 17 9
## 3 1 1 1 1 2 20 19 13 5
## 4 1 1 1 1 2 16 17 17 9
## 5 1 1 1 1 2 19 13 13 10
## 6 1 1 1 1 2 16 17 15 14
## C15ENPRF C15SZSET CCBASIC CARNEGIE LANDGRNT INSTSIZE F1SYSTYP
## 1 4 13 18 16 1 3 2
## 2 5 15 15 15 2 4 1
## 3 5 6 21 51 2 1 2
## 4 4 12 15 16 2 3 1
## 5 3 13 18 21 2 3 2
## 6 4 16 16 15 2 5 1
## F1SYSNAM F1SYSCOD CBSA CBSATYPE CSA NECTA COUNTYCD
## 1 -2 26620 1 290 -2 1089
## 2 The University of Alabama System 101050 13820 1 142 -2 1073
## 3 -2 33860 1 -2 -2 1101
## 4 The University of Alabama System 101050 26620 1 290 -2 1089
## 5 -2 33860 1 -2 -2 1101
## 6 The University of Alabama System 101050 46220 1 -2 -2 1125
## COUNTYNM CNGDSTCD LONGITUD LATITUDE DFRCGID DFRCUSCG TUITION2
## 1 Madison County 105 -86.56850 34.78337 128 1 8130
## 2 Jefferson County 107 -86.79935 33.50570 115 1 8040
## 3 Montgomery County 102 -86.17401 32.36261 236 2 9000
## 4 Madison County 105 -86.64045 34.72456 118 2 8996
## 5 Montgomery County 107 -86.29568 32.36432 136 1 6936
## 6 Tuscaloosa County 107 -87.54577 33.21440 117 1 10470
#str(a$TUITION2)
#head(a$TUITION2)
a$TUITION2<-as.numeric(as.character(a$TUITION2))
## Warning: NAs introduced by coercion
head(a$TUITION2)
## [1] 8130 8040 9000 8996 6936 10470
a<-a[!is.na(a$TUITION2),]
dim(a)
## [1] 1052 73
a<-a[a$LONGITUD > -124.848 &
a$LONGITUD < -66.886 &
a$LATITUDE > 24.3964 &
a$LATITUDE < 49.3844, ]
#dim(a)
#combine the first two columns to be coordinates:
coords<-cbind(a$LONGITUD,a$LATITUDE)
coordsPub<-cbind(a[a$SECTOR==1,]$LONGITUD,a[a$SECTOR==1,]$LATITUDE)
coordsPri<-cbind(a[a$SECTOR==2,]$LONGITUD,a[a$SECTOR==2,]$LATITUDE)
test.nb<-knn2nb(knearneigh(coords,k=1))
## Warning in knearneigh(coords, k = 1): knearneigh: identical points found
## Warning in knearneigh(coords, k = 1): knearneigh: kd_tree not available for
## identical points
test.nbdist<-dnearneigh(coords, 0, 120.701, row.names = a$name, longlat = TRUE) #75 miles
Looking at the two different Moran I test. The 1k Moran I has a statistic of .205. The 75 radius Moran I statistic is .132. Both approaches prove signicant at the .05 level. p-value = 1.142e-07 & p-value < 2.2e-16
The radius based approach we are allowing disconnected units to be not be accounted for. There are some institutions that are that are being excluded from the model because they have no neighbor within 75 mile radius. The nearest neighbor approach will account for any neighbor for institution regardless of distance. We have a lower number of institutions in the model which is reducing the effect of clusters/dependence.
#Now create a list, similar to an edgelist in spatial form
test.listw<-nb2listw(test.nb, zero.policy=TRUE)
test.listwdist<-nb2listw(test.nbdist, zero.policy=TRUE)
#create the listw object to test for spatial dependence
moran.test(a$TUITION2,test.listw, na.action=na.omit, zero.policy =TRUE)
##
## Moran I test under randomisation
##
## data: a$TUITION2
## weights: test.listw
##
## Moran I statistic standard deviate = 5.1747, p-value = 1.142e-07
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2045596381 -0.0009852217 0.0015777790
moran.test(a$TUITION2,test.listwdist, na.action=na.omit, zero.policy =TRUE)
##
## Moran I test under randomisation
##
## data: a$TUITION2
## weights: test.listwdist n reduced by no-neighbour observations
##
##
## Moran I statistic standard deviate = 8.1871, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.1317406543 -0.0010040161 0.0002628899
summary(test.listwdist,zero.policy = TRUE)
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 1016
## Number of nonzero links: 24048
## Percentage nonzero weights: 2.329655
## Average number of links: 23.66929
## 19 regions with no links:
## 118 169 215 326 467 468 497 613 734 757 763 766 768 774 779 798 866 936
## 1010
## Link number distribution:
##
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## 19 35 34 41 40 34 31 61 27 19 52 42 33 45 50 23 28 36 15 20
## 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
## 3 7 17 10 11 6 11 1 4 20 15 2 3 2 3 3 12 1 2 7
## 40 41 42 43 44 47 48 49 50 51 54 56 59 61 87 93 94 95 96 97
## 29 3 4 3 3 12 13 1 2 9 1 6 6 1 2 2 21 11 3 22
## 98 99 101 105 106 109 110 111 112
## 21 4 3 2 2 1 2 1 1
## 35 least connected regions:
## 22 37 40 214 216 424 428 435 437 466 469 483 484 604 614 615 649 650 682 690 730 778 783 784 802 813 820 821 850 861 865 868 978 986 1009 with 1 link
## 1 most connected region:
## 514 with 112 links
##
## Weights style: W
## Weights constants summary:
## n nn S0 S1 S2
## W 997 994009 997 263.1537 4037.172
plot(mtl, border="gray20", bg="slategray", col="gray90")
plot(test.nb, coords, col = rgb(205, 204,0, 255,max=255), lwd = 2, add=T, pch = 22)
points(coordsPub, col="#ff00669b", pch = 22, bg="#ff00669b")
points(coordsPri, col="#66ff009b", pch = 22, bg="#66ff009b")
title(cex.main=1.5, col.main="grey11", font.main=2, main="Closest neighbor specification",cex.sub=1.15, col.sub="grey11", font.sub=2,)
legend(title="Sector", "bottomright", legend=c("Public, n=337", "Private, n=679"), fill=c("#ff00669b", "#66ff009b"), bty="n", cex=1.5, y.intersp=0.8)
plot(mtl, border="gray20", bg="slategray", col="gray90")
plot(test.nbdist, coords, col = rgb(205, 204,0, 255,max=255), lwd = 2, add=T, pch = 22)
points(coordsPub, col="#ff00669b", pch = 22, bg="#ff00669b")
points(coordsPri, col="#66ff009b", pch = 22, bg="#66ff009b")
title(cex.main=1.5, col.main="grey11", font.main=2, main="Radius neighbor specification, 75 miles",cex.sub=1.15, col.sub="grey11", font.sub=2,)
legend(title="Sector", "bottomright", legend=c("Public, n=734", "Private, n=1605"), fill=c("#ff00669b", "#66ff009b"), bty="n", cex=1.5, y.intersp=0.8)