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
category sex V1 prop
1 2 3697 0.529959862385321
1 1 7066 0.230515773333768
2 2 3047 0.436783256880734
2 1 20363 0.664306919387988
3 1 3224 0.105177307278244
3 2 232 0.033256880733945