User:Ahwalker

From InterSciWiki
Revision as of 13:10, 30 November 2010 by Ahwalker (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Only 52 societies. v1010 would be better. Look at the context of this code to see what its about.

1010. Labor Recoding

          . = Missing data
    13    0 = No wage labor, no coerced labor, or
     8    1 = labor hired - in kind or local service occupations only
     5    2 = Internal coerced labor only
              - ([modify to: large scale] slavery, vassals, corvee)
     4    3 = External coerced labor -
     9    4 = Sporadic wage labor (5,6,7 above)
     2    5 = Divided or exempted wage labor (5,6,7 above) - see notes
    12    6 = Important wage labor (5,6,7 above) - includes sale, craft


YOU HAD JUNK HERE BECAUSE YOU NEED TO OPEN TEXTPAD, type a space, copy into textpad, paste back Working *Rccs* models#Value_of_children

1A Program CreateModelValueSDWchildren.R

#--extract variables to be used from sccs, put in dataframe my_sccs--
setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                  
depvar=apply(sccs[,c("v473","v474","v475","v476")],1,sum)
my_sccs<-data.frame(
#--For this dep_var, we sum variables measuring how much a society values children--
#--can replace "sum" with "max"
dep_var=apply(sccs[,c("v473","v474","v475","v476")],1,sum),
socname=sccs$socname,
socID=sccs$"sccs#",
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
cultints=sccs$v232,roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,anim=sccs$v206,
femsubs=sccs$v890,
pigs=(sccs$v244==2)*1,
milk=(sccs$v245>1)*1,
plow=(sccs$v243>1)*1,
bovines=(sccs$v244==7)*1,
tree=(sccs$v233==4)*1,
foodtrade=sccs$v819,
foodscarc=sccs$v1685,
ecorich=sccs$v857,
popdens=sccs$v156,
pathstress=sccs$v1260,
CVrain=sccs$v1914/sccs$v1913,
rain=sccs$v854,
temp=sccs$v855,
AP1=sccs$v921,
AP2=sccs$v928,
ndrymonth=sccs$v196,
exogamy=sccs$v72,
ncmallow=sccs$v227,
famsize=sccs$v80,
settype=sccs$v234,
localjh=(sccs$v236-1),
superjh=sccs$v237,
moralgods=sccs$v238,
fempower=sccs$v663,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
war=sccs$v1648,
himilexp=(sccs$v899==1)*1,
money=sccs$v155,
wagelabor=sccs$v1732,
migr=(sccs$v677==2)*1,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
pctFemPolyg=sccs$v872)
indep_vars<-c("AP1","AP2","CVrain","anim","bovines","brideprice","cereals","cultints","ecorich","exogamy","famsize","fempower","femsubs","fish","foodscarc","foodtrade","gath","himilexp","hunt","localjh","migr","milk","money","moralgods","ncmallow","ndrymonth","nuclearfam","pathstress","pctFemPolyg","pigs","plow","popdens","rain","roots","settype","sexratio","superjh","tree","wagelabor","war")
restrict_vars=c("cultints","roots","fish","exogamy","settype","femsubs")
library(foreign)
#--Read in two weight matrices--
Wll<-as.matrix(read.dta("./examples/data/langwm.dta")[,-1])
Wdd<-as.matrix(read.dta("./examples/data/dist25wm.dta")[,c(-1,-2,-189)])
load("./examples/data/vaux.Rdata",.GlobalEnv)
my_aux = vaux
row.names(my_aux)<-NULL
#--remove the society name field--
my_aux<-my_aux[,-28]
name<-"how society values children"
alias<-"DRWchildren"
model=list(name=name,
           alias=alias,
           data=my_sccs,
           aux_data=my_aux,
           prox_list=list(language=Wll,distance=Wdd),
           dep_var="dep_var",
           indep_vars=indep_vars,
           restrict_vars=restrict_vars)
save(model,file=paste(alias,".Rdata",sep=""))
source("examples/src/run_model.R") #does for this model multiple imputation, two stage ols, saves to file to working directory.
lat<-sccs$v833.1
lon<-sccs$v833.2
plot(lon,lat, cex=.1)
ztxt=as.character(depvar) #above "my_sccs( " -- a new line inserted: depvar= as defined in my_sccs(
text(lon,lat,ztxt)
ols_stats$restrict_stats
ols_stats$r2
ols_stats$restrict_diagnostics
ols_stats$restrict_stats
ols_stats$r2
ols_stats$restrict_diagnostics

1B Output CreateModelValueSDWchildren

               coef  Fstat          ddf pvalue    VIF
(Intercept) -9.2349 0.6837  5147859.410 0.4083     NA
language     1.6758 7.2348    57938.761 0.0072 2.1150
distance    -0.3175 0.5913     6214.685 0.4419 1.8948
cultints     0.7712 5.3353 33952759.458 0.0209 1.9155
roots       -2.5373 4.5326  1018231.693 0.0333 1.3155
fish         0.6089 5.7801  1465520.190 0.0162 1.2716
exogamy     -0.9878 6.7680 24002815.232 0.0093 1.1365
settype     -0.4398 3.8591 44104067.740 0.0495 1.6880
femsubs      0.6837 4.6169 12142256.390 0.0317 1.2881
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1188230       0.9648390       0.9228886 
>  ols_stats$restrict_diagnostics
               Fstat           df pvalue
RESET          1.091    35203.416  0.296
Wald.on.restrs 1.244     1334.924  0.265
NCV            0.829 93462710.258  0.363
SW.normal      1.023 15057403.014  0.312
lag..language  1.594  5492014.309  0.207
lag..distance  1.975    27100.094  0.160

2A Copy 1A here and change your dep_var; get it running, then copy to ==3A Work on your indep_vars and restrict_vars==

2B Your 2A Results: Give you dep_var name and vNumber in sccs

3A Work on your indep_vars and restrict_vars