Skip to content

Latest commit

 

History

History
248 lines (231 loc) · 10.8 KB

associations.org

File metadata and controls

248 lines (231 loc) · 10.8 KB

Correlation and Regressions

library(data.table)
readRDS("plfsdata/plfsacjdata.rds")->worker
worker$standardwage->worker$wage
factor(worker$social_group)->worker$social_group
factor(worker$religion)->worker$religion
factor(as.numeric(worker$state))->worker$state
factor(worker$sector)->worker$sector

cor.test(worker$wage,worker$years_edu)
cor.test(worker$wage,worker$age)
lm(wage~sex+age+years_edu,
   data=worker)->t
summary(t)

lm(wage~sex+age+years_edu+sector+social_group+religion+quarter,
   data=worker)->t
summary(t)

lm(wage~sex+age+years_edu+
     sector+social_group+religion+quarter+state,
   data=worker)->t
summary(t)
library(data.table)
readRDS("plfsdata/plfsacjdata.rds")->worker
worker$standardwage->worker$wage
factor(worker$social_group)->worker$social_group
factor(worker$religion)->worker$religion
factor(worker$state)->worker$state
factor(worker$sector)->worker$sector
worker->t9
lm(wage~sex+age+years_edu+sector+social_group+religion+quarter+state,data=t9)->t
lm(log(wage)~sex+age+years_edu+sector+social_group+religion+quarter+state,data=t9)->t2
data.frame(yvar=t9$wage,residuals=residuals(t),variable="model1")->a
rbind(a,data.frame(yvar=log(t9$wage),residuals=residuals(t2),variable="model2"))->a
ggplot(a,aes(x=residuals,y=yvar,group=variable))->p
p+geom_point()+facet_wrap(.~variable,scales="free")
worker->t
t[,years_edu:=as.numeric(years_edu)]
t[years_edu==0,category:=3]
t[years_edu>0&years_edu<12,category:=2]
t[is.na(category),category:=1]


ifelse(t$years_edu==0,1,
  ifelse(t$years_edu<12,2,3))->t$category

t[sex!=3,.(length(person_no)),.(category,sex)]->t
  t[,prop:=V1/sum(V1),sex]
t
categorysexV1prop
1236970.529959862385321
1170660.230515773333768
2230470.436783256880734
21203630.664306919387988
3132240.105177307278244
322320.033256880733945