Você está na página 1de 12

Graph 1: Data: observations reasonably spread across years.

Distribution across 15 occupations

table(year)

0
5

40000

100000

7 year

table(occpall)

0
0

100000

7 occpall

10

11

12

13

14

Graph2: Latinos within each year/occupation (red)

Year Distribution by Latino

0e+00

6e+04

7 Year

Occupation Distribution by Latino


200000

1 0

100000

10

11

12

13

14

OCCPALL

Corresponding tables for previous graphs:

Graph: Observing the latino /non distribution across occupations for all years:
Latino Segreation, 2005
0

7 Occupation

10

11

12

13

14

Latino Segreation, 2006


0

7 Occupation

10

11

12

13

14

Latino Segreation, 2007


0

7 Occupation

10

11

12

13

14

Latino Segreation, 2008


0

7 Occupation

10

11

12

13

14

Latino Segreation, 2009


0

7 Occupation

10

11

12

13

14

Table: proportion latino in years 2005 and 2009 in 15 occupations

Graph: Histogram of potential values of Duncan index (0-100) if random uniform proportions (simulation)
Histogram of p
250 Frequency 0
0.0

50

100

150

200

0.2

0.4 p

0.6

0.8

#data input and reduction of massive stata dataset library ("arm") exmassive <- read.dta ("H:/exmassive.dta") exmassive1 = exmassive[c("latino", "occpall", "year","occp1","occp10","occp11","occp12","occp13","occp14","occp2","occp3","occp4","occp5","occp 6","occp7","occp8","occp9","occpall")] attach(exmassive1); sort(colnames(exmassive))

##visualizing necessary data #graph par(mfrow=c(2,1)) plot(table(year)); plot(table(occpall)) #years reasonably spread out /// occupations skewed to 0

#graph: sense of population through time and latinos across industries (all time) par(mfrow=c(2,1)) counts <- table(latino,year); barplot(counts, main="Year Distribution by Latino", xlab="Year", col=c("darkblue","red")) counts <- table(latino, occpall); barplot(counts, main="Occupation Distribution by Latino", xlab="OCCPALL", col=c("darkblue","red"),legend = rownames(counts))

#corresponding tables for graph yrlat = table(year,latino) ; prop.table(yrlat,1) occplat = table(occpall,latino) ; prop.table(occplat,1)

#graph: latinos across industries through time: "segregation across time" par(mfrow=c(5,1)) counts5 <- table(latino[year==5],occpall[year==5]); barplot(counts5, main="Latino Segreation, 2005", xlab="Occupation", col=c("yellow","red")) counts6 <- table(latino[year==6],occpall[year==6]); barplot(counts6, main="Latino Segreation, 2006", xlab="Occupation", col=c("yellow","red")) counts7 <- table(latino[year==7],occpall[year==7]); barplot(counts7, main="Latino Segreation, 2007", xlab="Occupation", col=c("yellow","red")) counts8 <- table(latino[year==8],occpall[year==8]); barplot(counts8, main="Latino Segreation, 2008", xlab="Occupation", col=c("yellow","red")) counts9 <- table(latino[year==9],occpall[year==9]); barplot(counts9, main="Latino Segreation, 2009", xlab="Occupation", col=c("yellow","red"))

prop.table(counts5,2); prop.table(counts9,2)

#1 industry vs all 14 #lowercase / uppercase notation designates respective years

bisectoccp = function(occp) {

mini = occp1[year==9 & latino==1] maji = occp[year==9 & latino==0] MINI = occp[year==5 & latino==1] MAJI = occp[year==5 & latino==0]

smin = sum(mini); smaj=sum(maji); SMIN=sum(MINI); SMAJ=sum(MAJI) ti = smin + smaj; Ti = SMIN + SMAJ; pi = smaj / ti; Pi = SMAJ / Ti qi = smin / ti; Qi = SMIN / Ti return(c(ti=ti,Ti=Ti,pi=pi, Pi=Pi,qi=qi,Qi=Qi,smin=smin,SMIN=SMIN,smaj=smaj,SMAJ=SMAJ)) }

#T for all industries; maj for all industries etcetc

a = bisectoccp(occp1); b = bisectoccp(occp2);c = bisectoccp(occp3);d = bisectoccp(occp4);e = bisectoccp(occp5);f = bisectoccp(occp6);g = bisectoccp(occp7);h = bisectoccp(occp8);i = bisectoccp(occp9);j = bisectoccp(occp10);k = bisectoccp(occp11);l = bisectoccp(occp12);m = bisectoccp(occp13);n = bisectoccp(occp14); rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n) t = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["ti"];t T = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["Ti"];T min = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["smin"];min MIN = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["SMIN"];MIN maj = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["smaj"];maj MAJ = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["SMAJ"];MAJ P = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["Pi"];P p = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["pi"];p Q = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["Qi"];Q q = colSums(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))["qi"];q

df = data.frame(rbind(a,b,c,d,e,f,g,h,i,j,k,l,m,n))

#50* sum( (abs(df["Pi"]/P - df["Qi"]/Q) + abs(df["pi"]/p-df["qi"]/q)) / (2* (df["ti"]/t - df["Ti"]/T) )

))

num1 = abs(df["Pi"]/ P - df["Qi"] / Q) + abs(df["pi"]/p - df["qi"]/q ) den1 = 2*(df["ti"]/t - df["Ti"]/T) struct = num1 / den1; sum(struct) racial = ((df["Ti"]/ T + df["ti"] / t)/2 ) sum(racial) 50*sum(struct) + 50*sum(racial) #das gupta decomp * abs(df["pi"]/p - df["qi"]/q) - abs( df["Pi"]/P - df["Qi"]/Q)

counts <- table(latino[-occpall==0],occpall[-occpall==0]); foo = prop.table(counts) ; .5*(sum(abs(foo[2,]-foo[1,]))) plot(table(occpall[c(occpall==1,occpall==2,occpall==3 )])) sum(occpall==0)

################################################duncan index

maji = seq(from = .001, to=.999, by = .001); mini = 1 - maji

maji mini D = .5* abs(maji - mini)

set.seed(1); maji = runif(10); mini = 1 - maji D = .5*sum(abs(maji - mini)); D

majoccp1=.7 ; majoccp2=.1; majoccp3=.1; maji = c(majoccp1,majoccp2,majoccp3) minoccp1=.7 ; minoccp2=.1; minoccp3=.1; mini = c(minoccp1,minoccp2,minoccp3) D = .5*sum(abs(maji - mini)); D majoccp1=.8 ; majoccp2=.1; majoccp3=.1; maji = c(majoccp1,majoccp2,majoccp3) minoccp1=.25 ; minoccp2=.25; minoccp3=.5; mini = c(minoccp1,minoccp2,minoccp3) D = .5*sum(abs(maji - mini)); D

################majority distribution across occupations set.seed(1); m=1000 ; n=3; maji = matrix(0,nrow=m,ncol=n) for(i in 1:m) { a = runif(n) maji[i,] = a / sum(a) } ################minority distribution across occupations mini = matrix(0,nrow=m,ncol=n) for(i in 1:m) { a = runif(n) mini[i,] = a / sum(a) }

pp = .5* rowSums(abs(maji - mini)) hist(pp) #distribution of duncan index values mean(pp) # ####################### #Duncan for the data### ####################### #expected value of disribution

#overall duncan: years 5-9 majidunc = table(occpall[latino==0]) ; majidunc = prop.table(majidunc) minidunc = table(occpall[latino==1]) ; minidunc = prop.table(minidunc)

pall = .5* sum(abs(majidunc - minidunc))

#Duncan: year = 5 majidunc = table(occpall[latino==0 & year==5]) ; majidunc = prop.table(majidunc) minidunc = table(occpall[latino==1 & year==5]) ; minidunc = prop.table(minidunc)

p1 = .5* sum(abs(majidunc - minidunc))

#Duncan: year = 9 majidunc = table(occpall[latino==0 & year==9]) ; majidunc = prop.table(majidunc) minidunc = table(occpall[latino==1 & year==9]) ; minidunc = prop.table(minidunc)

p2 = .5* sum(abs(majidunc - minidunc))

p2 - p1

Você também pode gostar