User:Aimyn

From InterSciWiki
Jump to: navigation, search

DRW comment: interesting that there is a signif DISTANCE effect up to model 12, then none from 13 forward. What changes is the transition from v739 (for males) to v740 (for females). In other words, a DISTANCE effect for arranged marriages of MALES, but not FEMALES.

Overall strategy

  • Across 4B-5B-6B-7B-8B DW: You're getting different vars as signif. If you do a 9A it could have all the signif vars from these: see how they work together... which ones to keep if tested together?
exogamy
localjh
agrlateboy
Whyte635
migr
Sanday668
Rohner800
femsubs
Rohner804
Rohner801
intwarB
  • 1A: is the new child model
  • 1B: the results of running the model
  • 2A: new child model with my dependent variable
  • 2B: results from running this program
  • 3A: The UR/2
  • 3B: results of the UR/2
  • Is this the correct outline of what one's wiki page is supposed to look like?
  • DRW: Yes, let me have a look, and there is a next step after 3B: in 4A you copy 3A and then weed out restrict_vars that are not significant, rerun and post results at 4B. Hold off editing while I clean up you page a bit

Dep Var and codebook definition

v739, Marriage Arrangement
    38    . = Missing data
    46    1 = Individual selects and/or courts partner autonomously:
              approval by parents or others unnecessary
    26    2 = Individual selects and/or courts partner autonomously:
              parental, kin, and/or community approval necessary or
              highly desireable
     5    3 = Individual suggests partner to parents or others:
              arrangements for courtship or marriage then proceed
              if choice is approved
            OR parents ask approval of individuals to initiate
              a match
            OR individual is approached by parent or others on
              behalf of suitor and can accept or reject the match
    27    4 = Individual choice and arranged marriages are
              alternatives
    25    5 = Parents choose partner: individual can object
    19    6 = Parents choose partner: individual cannot easily
              object or rarely objects in fact

1A Program CreateModelDRWpolygyny2.R

library(sccs) data(sccs) #Run CreateModelDRWpolygyny2.R

depvar=sccs$v1797

my_sccs<-data.frame(
dep_var=sccs$v1797,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)
#"fratgrpstr","plow","fem_agri","pre_mar_sex","marrcaptives","plunder","femproduceND")
#restrictvars must drop one or more indepvars - in this case, dropping "premarsexatt"
restrict_vars=c("language","distance","cultints","bovines","ncmallow","gath","malesexag")
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<-"general polygyny"
alias<-"DRWpolygyny2"
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
table(depvar)

1B Output CreateModelDRWpolygyny.R

              coef Fstat         ddf pvalue   VIF
(Intercept)  0.233 0.207   72908.267  0.649    NA
language    -0.036 0.003    1914.891  0.959 2.086
distance     0.883 7.053    3291.331  0.008 2.056
cultints    -0.047 0.714 1319578.138  0.398 1.578
bovines      0.371 3.111  137030.139  0.078 1.584
ncmallow    -0.019 0.328    4609.380  0.567 1.062
gath        -0.031 0.230  133129.297  0.632 1.513
malesexag    0.019 0.145     158.849  0.704 1.182
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
     0.08938656      0.99468531      0.99329835 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.344   6533.273  0.558
Wald.on.restrs  1.216     15.492  0.287
NCV             0.741  28471.516  0.389
SW.normal      27.956 997110.408  0.000
lag..language   0.020 269158.594  0.888
lag..distance   0.113 293071.118  0.737

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

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)
#"fratgrpstr","plow","fem_agri","pre_mar_sex","marrcaptives","plunder","femproduceND")
#restrictvars must drop one or more indepvars - in this case, dropping "premarsexatt"
restrict_vars=c("language","distance","cultints","bovines","ncmallow","gath","malesexag")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

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

 coef Fstat        ddf pvalue   VIF
(Intercept) -0.073 0.003 511688.035  0.956    NA
language    -0.650 1.405   2199.556  0.236 2.367
distance     1.081 9.563   2448.156  0.002 1.893
cultints     0.296 7.931  19997.652  0.005 1.575
bovines      0.556 2.066  43320.442  0.151 1.574
ncmallow     0.019 0.105 102334.631  0.746 1.081
gath         0.242 4.367  19053.127  0.037 1.404
malesexag    0.089 1.015    245.054  0.315 1.098
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1545558       0.9948433       0.9885685 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.226   1158.770  0.635
Wald.on.restrs  0.324    141.526  0.570
NCV             0.104  27279.216  0.747
SW.normal      13.920   4218.321  0.000
lag..language   0.100 211170.929  0.752
lag..distance   0.163 184300.061  0.686

3A Work on your indep_vars and restrict_vars

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

3B Used half your variables to illustrate an UNRESTRICTED MODEL

                 coef Fstat        ddf pvalue   VIF
(Intercept) -0.980 0.119   2225.354  0.730    NA
language    -1.038 2.006   1138.841  0.157 4.054 <--
distance     1.078 5.670   1948.326  0.017 3.081
famsize     -0.040 0.426  14911.537  0.514 2.368
exogamy      0.249 2.892   4887.947  0.089 1.439 <--
money        0.101 0.482   8277.787  0.488 2.103
popdens     -0.032 0.032  71067.609  0.857 3.764
malesexag    0.003 0.001     24.286  0.982 1.531
ndrymonth    0.042 0.446    954.974  0.505 2.204
gath         0.201 1.277  23653.839  0.258 3.209
hunt        -0.191 0.959 538109.135  0.327 5.887
fish         0.088 0.336   2142.301  0.562 3.577
anim         0.041 0.054   2460.164  0.817 6.087
brideprice  -0.762 2.149   1366.392  0.143 2.772 <--
nuclearfam   0.309 0.432  36367.778  0.511 2.187
ncmallow    -0.005 0.004    952.983  0.948 1.467
cultints     0.215 1.174  35856.492  0.279 5.481
tree         0.714 0.527  16407.940  0.468 3.103
roots        0.385 0.226   2711.735  0.634 4.868
cereals     -0.100 0.017  36074.419  0.898 7.084
settype     -0.060 0.229  11195.652  0.632 4.197
localjh      0.611 3.227   7248.228  0.072 1.981 <--
superjh     -0.091 0.203   9259.149  0.652 2.500
moralgods    0.075 0.173   2818.384  0.677 2.027
segadlboys   0.026 0.036    240.897  0.849 1.528
plow         0.189 0.073  62945.912  0.788 3.012
pigs        -0.601 0.887   9066.864  0.346 2.819
bovines      0.626 0.953  18382.376  0.329 4.195
milk        -0.348 0.271  63245.428  0.603 4.121
agrlateboy   0.163 2.965    449.358  0.086 1.471 <--
valchild     0.012 0.159    232.398  0.691 1.272
fratgrpstr   0.125 0.345    995.748  0.557 3.779
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.2797307       0.9940058       0.9895344 
>  ols_stats$restrict_diagnostics
                Fstat        df pvalue
RESET           0.088 11095.044  0.767
Wald.on.restrs -0.013    73.347  1.000
NCV             0.018  9345.503  0.894
SW.normal       3.435  2270.926  0.064
lag..language   0.170 60630.820  0.681
lag..distance   0.244  7211.288  0.621
>  table(depvar)'

4A Narrowed down the restrict_vars to significant variables

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("exogamy","brideprice","localjh","agrlateboy")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

4b results

               coef Fstat        ddf pvalue   VIF
(Intercept) -2.205 2.396   3177.232  0.122    NA
language    -0.103 0.040 268512.985  0.841 2.098
distance     0.980 7.884  27418.317  0.005 1.881
exogamy      0.217 2.852   7842.396  0.091 1.122
brideprice  -0.387 1.146   6380.417  0.284 1.373
localjh      0.644 6.536 328332.999  0.011 1.108
agrlateboy   0.156 3.412     88.141  0.068 1.074
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1294121       0.9939307       0.9881296 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           1.575   1729.016  0.210
Wald.on.restrs -0.021     18.054  1.000
NCV             0.075  39650.221  0.784
SW.normal       9.762   4493.996  0.002
lag..language   0.103 546525.908  0.749
lag..distance   0.193  12729.843  0.661
>  table(depvar)
depvar
 1  2  3  4  5  6 
46 26  5 27 25 19 
>

5A Copied 4A and restricted more variables

setwd("C:/My Documents/sccs")

library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("exogamy","localjh","agrlateboy")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

5b results

              coef Fstat        ddf pvalue   VIF
(Intercept) -1.601 1.568  12674.752  0.211    NA
language    -0.185 0.140 114291.409  0.708 1.934
distance     0.906 6.827  20382.850  0.009 1.864
exogamy      0.187 2.204  21400.606  0.138 1.085 v72
localjh      0.594 5.827 267089.778  0.016 1.059 v236-1
agrlateboy   0.142 3.332    422.623  0.069 1.010 v300
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1251210       0.9949990       0.9908149 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           1.015    383.736  0.314
Wald.on.restrs  0.425      9.635  0.530
NCV             0.010    126.477  0.922
SW.normal      11.298   2258.502  0.001
lag..language   0.088 115778.150  0.767
lag..distance   0.107  10114.247  0.743
>  table(depvar)

6A Copied 4A and restricted more variables

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("exogamy","localjh","agrlateboy","Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

6b results

               coef Fstat     ddf pvalue   VIF
(Intercept)   6.884 0.212 489.857  0.645    NA
language     -1.015 1.283  32.084  0.266 5.096
distance      1.045 3.786  28.569  0.062 3.520
exogamy       0.060 0.154  73.560  0.696 1.435
localjh       0.292 0.780  58.021  0.381 1.700
agrlateboy    0.092 0.622  19.527  0.440 1.761
Whyte577     -0.056 0.114 105.517  0.736 1.688
Whyte580     -0.184 0.400  21.393  0.534 2.067
Whyte584     -0.028 0.008  17.084  0.928 2.024
Whyte585     -0.528 1.237  41.723  0.272 1.586
Whyte595      0.060 0.025 860.277  0.875 1.795
Whyte602      0.016 0.001  18.280  0.975 1.730
Whyte615     -0.010 0.003  10.914  0.960 2.064
Whyte620     -0.065 0.031  10.894  0.863 1.949
Whyte626     -0.269 0.254  24.265  0.619 2.165
Whyte629     -0.231 0.330  10.168  0.578 1.797
Whyte630     -0.013 0.002  85.266  0.968 1.932
Whyte631      0.019 0.007  54.806  0.932 1.686
Whyte632     -0.321 1.901  29.160  0.178 1.811
Whyte633     -0.094 0.071  14.060  0.794 2.311
Whyte635      0.549 2.745  46.846  0.104 1.780 <--
Paige657     -0.040 0.006  84.269  0.940 1.788
femproduceND  0.549 0.377  16.378  0.547 3.430
Paige659      0.435 0.639 101.545  0.426 2.640
Paige660     -0.235 0.235 351.849  0.628 2.407
Paige661      0.391 0.624  87.783  0.432 2.666
Paige662     -0.553 1.192  75.643  0.278 2.228
fempower     -0.171 0.765  21.430  0.391 4.179
interperviol  0.576 0.305  10.155  0.593 6.009
migr         -0.801 2.568  21.528  0.124 2.065<--
Sanday664    -0.010 0.000   8.705  0.989 2.005<--
Sanday665     0.580 1.284  24.266  0.268 1.752<--
Sanday666    -0.309 0.073   8.257  0.793 6.052
Sanday667    -0.045 0.005   8.209  0.945 2.000
Sanday668     0.768 2.977  98.642  0.088 2.050<--
Sanday669    -0.080 0.145  11.227  0.711 3.779
Whyte718     -0.168 0.788 126.784  0.376 1.829
Whyte719     -0.096 0.214  62.810  0.645 1.753
Whyte720      0.183 0.291  56.514  0.592 1.759
Whyte721      0.245 0.926 355.171  0.336 2.229
Whyte722      0.053 0.007   8.209  0.933 2.571
Whyte723     -0.254 0.215   8.882  0.654 2.572
Whyte724     -0.351 0.709  24.881  0.408 1.830
Whyte725     -0.058 0.030  17.298  0.865 1.946
Rohner798    -0.002 0.093 891.830  0.760 1.624
Rohner799    -0.001 1.389  71.834  0.242 1.414
Rohner800     0.008 1.651 164.994  0.201 1.381
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.4310968       0.9946834       0.9880839 
>  ols_stats$restrict_diagnostics
                Fstat        df pvalue
RESET           2.748   311.498  0.098
Wald.on.restrs -0.001   301.773  1.000
NCV             0.487    29.403  0.491
SW.normal       1.739    26.771  0.198
lag..language   0.223 50447.691  0.637
lag..distance   0.494 15558.231  0.482
>  table(depvar)
depvar
 1  2  3  4  5  6 
46 26  5 27 25 19 
>

7A

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("exogamy","localjh","agrlateboy","Whyte635","migr","Sanday664","Sanday665",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

7B results

              coef Fstat       ddf pvalue   VIF
(Intercept) -6.047 0.208   304.982  0.648    NA
language    -0.368 0.345  4011.945  0.557 3.099
distance     0.942 6.005   521.510  0.015 2.198
exogamy      0.137 1.047 18386.906  0.306 1.241
localjh      0.431 2.407   166.946  0.123 1.224 <--
agrlateboy   0.114 1.595    76.857  0.210 1.261
Whyte635     0.247 0.741    53.219  0.393 1.259
migr        -0.570 2.277   193.518  0.133 1.499 <--
Sanday664    0.018 0.002   110.715  0.969 1.525
Sanday665    0.621 1.960    36.397  0.170 1.393
Sanday668    0.523 1.190    18.549  0.289 1.640
Sanday669   -0.006 0.002    32.197  0.963 2.112
Whyte718    -0.114 0.464    72.124  0.498 1.340
Whyte719    -0.029 0.023    88.949  0.880 1.355
Whyte720     0.018 0.004    66.947  0.952 1.251
Whyte721     0.059 0.066   110.562  0.798 1.629
Whyte722     0.171 0.093     8.708  0.768 2.052
Whyte723    -0.279 0.433    18.542  0.518 2.161
Whyte724    -0.131 0.137    40.065  0.713 1.324
Whyte725    -0.007 0.001    77.400  0.979 1.339
Rohner798    0.002 0.102   306.454  0.750 1.310
Rohner799   -0.001 1.072  1065.643  0.301 1.175
Rohner800    0.008 2.086   797.240  0.149 1.177<--
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.2416151       0.9940830       0.9872353 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.377   3709.011  0.539
Wald.on.restrs -0.045     39.797  1.000
NCV            -0.098     23.892  1.000
SW.normal       2.650     44.347  0.111
lag..language   0.158  23743.449  0.691
lag..distance   0.231 222225.077  0.631
>  table(depvar)
depvar
 1  2  3  4  5  6 
46 26  5 27 25 19 
>

8a

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("localjh","migr","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

8b results

                coef Fstat       ddf pvalue   VIF
(Intercept) -5.727 0.114    61.427  0.737    NA
language    -0.611 0.617   177.740  0.433 4.041
distance     0.839 2.443   127.376  0.121 3.710 
Rohner801    3.472 4.843 22619.218  0.028 1.685<--
Rohner802    0.006 0.469    76.501  0.495 1.506
Rohner803    0.006 0.924   119.766  0.338 1.355
Rohner804   -0.833 2.984   146.209  0.086 1.540<--
Rohner805   -0.084 0.174  5053.243  0.677 1.675
Rohner806   -0.005 0.001    37.899  0.975 1.754
Rohner807   -0.116 0.084  5557.783  0.771 1.682
Rohner808    0.032 0.006   368.186  0.937 1.671
Rohner809   -0.562 0.679   766.405  0.410 2.220
Rohner810   -0.780 0.639   248.282  0.425 1.512
Rohner811    0.061 0.139    79.179  0.710 1.746
Rohner812   -0.091 0.129    47.258  0.721 1.477
Rohner813    0.004 0.000    15.185  0.989 1.584
foodtrade    0.017 0.769  2611.367  0.380 1.726
fem_agri    -0.004 0.147    47.945  0.703 2.062
dateobs     -0.001 0.348   348.729  0.556 1.770
rain         0.045 0.125 11112.624  0.724 2.663
temp         0.027 0.047   389.126  0.828 2.592
ecorich     -0.224 0.378   140.310  0.540 2.621
pctFemPolyg -0.001 0.007    20.304  0.933 1.826
femsubs      0.212 2.073  2747.150  0.150 1.912<--
intwar       0.052 0.034   383.816  0.855 1.516
extwar       0.041 0.020    90.746  0.887 1.766
himilexp     0.331 0.807  1248.284  0.369 1.397
AP1          0.025 0.123  2570.519  0.725 2.828
AP2         -0.063 0.200  3451.122  0.655 2.321
pathstress   0.041 0.328  2887.672  0.567 3.309
war         -0.051 1.324   192.696  0.251 3.991
intwarB      0.082 4.622  1735.981  0.032 2.684<--
extwarB     -0.014 0.123   360.168  0.725 2.945
foodscarc    0.171 1.426   132.327  0.235 1.354
sexratio    -0.167 0.291    24.129  0.594 1.450
wagelabor    0.134 0.272    23.436  0.607 1.625
CVrain       0.000 0.051  1396.502  0.821 1.378
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.2751209       0.9934761       0.9885469 
>  ols_stats$restrict_diagnostics
               Fstat        df pvalue
RESET          2.064   149.968  0.153
Wald.on.restrs 0.774    76.758  0.382
NCV            0.349    79.021  0.557
SW.normal      6.032   397.510  0.014
lag..language  0.190 98973.662  0.663
lag..distance  0.337 57728.952  0.562
>  table(depvar)
depvar
 1  2  3  4  5  6 
46 26  5 27 25 19 
>


9a

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("exogamy","localjh","agrlateboy","migr","Rohner800","Rohner801","Rohner804","Whyte635","Sanday668","femsubs","intwarB")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

9b

               coef Fstat         ddf pvalue   VIF
(Intercept) -1.737 0.947     383.075  0.331    NA
language    -0.185 0.111    1986.373  0.739 2.449 
distance     0.838 4.902     453.123  0.027 2.180
exogamy      0.156 1.532 2945485.141  0.216 1.127
localjh      0.499 3.989    4952.123  0.046 1.115 <--
agrlateboy   0.135 2.261      78.159  0.137 1.186 <--
migr        -0.400 1.397     147.460  0.239 1.214
Rohner800    0.005 0.558    7336.013  0.455 1.925
Rohner801    1.281 0.646   21386.461  0.422 1.896
Rohner804   -0.560 1.461      14.812  0.246 1.096
Whyte635     0.123 0.231     240.431  0.631 1.131
Sanday668    0.604 3.267     764.703  0.071 1.231 <--
femsubs      0.045 0.172    7552.915  0.678 1.133
intwarB      0.013 0.225      96.583  0.636 1.287
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.2061265       0.9938036       0.9878538 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.109   2656.801  0.742
Wald.on.restrs -0.001  92820.574  1.000
NCV             0.144    155.188  0.705
SW.normal       4.721   1122.952  0.030
lag..language   0.171 353936.265  0.679
lag..distance   0.275 347999.932  0.600
>  table(depvar)
depvar
 1  2  3  4  5  6 
46 26  5 27 25 19 
>

10a

setwd("C:/My Documents/sccs")

library(sccs)
data(sccs)                                 
depvar=sccs$v739
my_sccs<-data.frame(
dep_var=sccs$v739,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  


indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("localjh","agrlateboy","Sanday668",  "exogamy","cultints",  "gath"  ) # "intwarB",  
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

10b

DRW ASSIST: Seems like this might be better to procede with, I just restored to 10A three earlier variables
(Intercept) -2.4842 3.2739  1500.5326 0.0706     NA
language    -0.4530 0.7900   859.1129 0.3744 2.1158
distance     1.0062 8.7539   658.6865 0.0032 1.8462
localjh      0.3720 2.2298 16495.8082 0.1354 1.1505
agrlateboy   0.1200 2.2532   120.1238 0.1360 1.0619
Sanday668    0.5057 2.6399   536.5335 0.1048 1.0844
exogamy      0.1918 2.4395  7123.6122 0.1184 1.0986 <-added back
cultints     0.3106 9.5769 22260.8984 0.0020 1.5012 <-added back
gath         0.1678 2.2976 14621.5237 0.1296 1.3397 <-added back
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1967009       0.9939900       0.9886125 
>  ols_stats$restrict_diagnostics
               Fstat        df pvalue
RESET          0.334   405.013  0.563
Wald.on.restrs 0.011 44216.145  0.917
NCV            0.158 60614.671  0.691
SW.normal      4.468  1029.755  0.035
lag..language  0.105 11545.860  0.746
lag..distance  0.208  9352.051  0.649
Given v739, Marriage Arrangement
   38    . = Missing data
   46    1 = Individual selects and/or courts partner autonomously:
             approval by parents or others unnecessary
   26    2 = Individual selects and/or courts partner autonomously:
             parental, kin, and/or community approval necessary or
             highly desireable
    5    3 = Individual suggests partner to parents or others:
             arrangements for courtship or marriage then proceed
             if choice is approved
           OR parents ask approval of individuals to initiate
             a match
           OR individual is approached by parent or others on
             behalf of suitor and can accept or reject the match
   27    4 = Individual choice and arranged marriages are
             alternatives
   25    5 = Parents choose partner: individual can object
   19    6 = Parents choose partner: individual cannot easily
             object or rarely objects in fact
It might be well to define in a 11A
depvar<--(sccs$v739>2)*1
and in a different run in a 12A
depvar<--(sccs$v739>4)*1
OLD RESULTS
              coef Fstat        ddf pvalue   VIF
(Intercept) -2.095 2.362    863.450  0.125    NA
language     0.013 0.001   5698.975  0.979 1.880
distance     0.931 7.273  16265.817  0.007 1.851
localjh      0.524 4.739 795122.873  0.029 1.017 <--
agrlateboy   0.099 1.498     73.370  0.225 1.038
Sanday668    0.562 2.727     61.025  0.104 1.056 <--
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1291060       0.9950063       0.9891676 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.024 104182.252  0.878
Wald.on.restrs  0.873     22.519  0.360
NCV             0.440  18495.874  0.507
SW.normal      10.065   1887.910  0.002
lag..language   0.124 105919.161  0.725
lag..distance   0.194  21332.502  0.660
>  table(depvar)
depvar
 1  2  3  4  5  6 
46 26  5 27 25 19 

>

11a (dichotomy)

setwd("C:/My Documents/sccs")

library(sccs)
data(sccs)                                 
depvar<--(sccs$v739>2)*1
my_sccs<-data.frame(
dep_var=(sccs$v739>2)*1,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  


indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("localjh","agrlateboy","Sanday668",  "exogamy","cultints",  "gath"  ) # "intwarB",  
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

11b

              coef Fstat        ddf pvalue   VIF
(Intercept) -0.759 5.817   2761.116  0.016    NA
language    -0.579 1.041   4213.059  0.308 1.704
distance     0.937 8.045   3130.701  0.005 1.473
localjh      0.150 4.945 213077.617  0.026 1.142 <--
agrlateboy   0.033 2.345     81.989  0.129 1.063 <--
Sanday668    0.178 4.383    549.509  0.037 1.088 <--
exogamy      0.047 1.971   8163.451  0.160 1.084 <--
cultints     0.067 6.129  54598.745  0.013 1.497 <--
gath         0.020 0.440 627925.980  0.507 1.337
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1875089       0.9912082       0.9886374 
>  ols_stats$restrict_diagnostics
                Fstat        df pvalue
RESET           0.790  1276.415  0.374
Wald.on.restrs  0.071    10.387  0.796
NCV             0.077   506.450  0.782
SW.normal      18.221  1391.060  0.000
lag..language   0.083 98037.138  0.774
lag..distance   0.122  8263.197  0.726
>  table(depvar)
depvar
-1  0 
76 72 
>

12a

setwd("C:/My Documents/sccs")

library(sccs)
data(sccs)                                 
depvar=(sccs$v739>4)*1
my_sccs<-data.frame(
dep_var=(sccs$v739>4)*1,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  


indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("localjh","agrlateboy","Sanday668",  "exogamy","cultints",  "gath"  ) # "intwarB",  
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

12b

              coef  Fstat          ddf pvalue   VIF
(Intercept) -0.591  4.679      558.953  0.031    NA
language    -0.957  1.399     2507.494  0.237 2.081
distance     0.928  4.840     1215.774  0.028 2.006
localjh      0.002  0.001    26182.922  0.979 1.143
agrlateboy   0.020  1.044      455.755  0.307 1.096
Sanday668    0.173  3.697       42.164  0.061 1.153
exogamy      0.060  3.848    32919.357  0.050 1.060
cultints     0.087 11.647     5162.978  0.001 1.484
gath         0.043  2.439 49418098.676  0.118 1.328
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1540339       0.9841968       0.9839488 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.464   8306.495  0.496
Wald.on.restrs -0.134     12.729  1.000
NCV             4.632    786.051  0.032
SW.normal      33.186   1183.099  0.000
lag..language   0.125 193778.391  0.723
lag..distance   0.179  39444.138  0.672
>  table(depvar)
depvar
 -1   0 
 44 104 
>

12b (made some changes)

740. Marriage Arrangements (Female)

    35    . = Missing data
    12    1 = Individual selects and/or courts partner autonomously:
              approval by parents or others unnecessary
    40    2 = Individual selects and/or courts partner authonomously:
              parental, kin, and/or community approval necessary
              or highly desireable
     4    3 = Individual suggests partner to parents or others;
              arrangements for courtship or marriage then proceed
              if choice is approved
            OR parents ask approval of individuals to initiate
              a match
            OR individual is approached by parent or others on
              behalf of suitor and can accept or reject the match
    27    4 = Individual choice and arranged marriages are
              alternatives
    35    5 = Parents choose partner: individual can object
    33    6 = Parents choose partner: individual cannot easily
              object or rarely objects in fact
  • v739. Marriage Arrangement (male)
   38    . = Missing data
   46    1 = Individual selects and/or courts partner autonomously:
             approval by parents or others unnecessary
   26    2 = Individual selects and/or courts partner autonomously:
             parental, kin, and/or community approval necessary or
             highly desireable
    5    3 = Individual suggests partner to parents or others:
             arrangements for courtship or marriage then proceed
             if choice is approved
           OR parents ask approval of individuals to initiate
             a match
           OR individual is approached by parent or others on
             behalf of suitor and can accept or reject the match
   27    4 = Individual choice and arranged marriages are
             alternatives
   25    5 = Parents choose partner: individual can object
   19    6 = Parents choose partner: individual cannot easily
             object or rarely objects in fact
depvar=(sccs$v739>4)*1
              coef  Fstat        ddf pvalue   VIF
(Intercept) -0.575  3.805     88.756  0.054    NA
language    -1.044  1.582    639.146  0.209 2.113
distance     0.988  5.449   4216.278  0.020 2.039
localjh      0.008  0.017  35886.317  0.896 1.144 <-- drop
agrlateboy   0.021  1.068    117.837  0.304 1.071 <-- drop
Sanday668    0.156  2.823     30.948  0.103 1.136
exogamy      0.061  3.839  12054.560  0.050 1.068
cultints     0.086 11.466 104898.746  0.001 1.481
gath         0.045  2.548  22623.231  0.110 1.320
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1476401       0.9847102       0.9828810 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           0.568   1978.940  0.451
Wald.on.restrs -0.069     23.399  1.000
NCV             3.965    298.450  0.047
SW.normal      33.688   1102.107  0.000
lag..language   0.121 144745.268  0.728
lag..distance   0.237 166329.211  0.626

> table(depvar)

13a (Female version)

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)
#"fratgrpstr","plow","fem_agri","pre_mar_sex","marrcaptives","plunder","femproduceND")
#restrictvars must drop one or more indepvars - in this case, dropping "premarsexatt"
restrict_vars=c("language","distance","cultints","bovines","ncmallow","gath","malesexag")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

13b Results

              coef Fstat        ddf pvalue   VIF
(Intercept)  3.361 1.188   6687.607  0.276    NA
language    -0.077 0.007   3588.674  0.933 1.537
distance    -0.023 0.002   3681.781  0.961 1.456
cultints     0.103 1.043 304236.404  0.307 1.588
bovines      0.684 3.236  35139.913  0.072 1.668<--
ncmallow    -0.047 0.672 131133.194  0.412 1.100
gath         0.170 2.391  39075.777  0.122 1.450<--
malesexag    0.100 1.347     62.891  0.250 1.074
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.0679338       0.9808604       0.9822786 
>  ols_stats$restrict_diagnostics
                Fstat         df pvalue
RESET           2.091     74.456  0.152
Wald.on.restrs  1.237      5.606  0.311
NCV             1.925   1028.628  0.166
SW.normal      16.998   3211.219  0.000
lag..language   0.082  76422.404  0.774
lag..distance   0.074 805397.688  0.785
>  table(depvar)
depvar
 1  2  3  4  5  6 
12 40  4 27 35 33 

>

14A UR/2

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c("famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

14b results

               coef Fstat       ddf pvalue    VIF
(Intercept)  12.321 3.766    84.866  0.056     NA
language     -1.340 1.028    52.639  0.315  3.021
distance     -0.660 1.008   288.585  0.316  2.892
famsize       0.013 0.037   163.611  0.848  3.101
exogamy       0.142 0.971   242.175  0.325  1.703
money         0.099 0.461  6551.158  0.497  2.706
popdens      -0.199 1.213   560.800  0.271  4.670
malesexag     0.004 0.001    15.415  0.976  1.937
ndrymonth     0.013 0.034    97.099  0.855  2.952
gath          0.135 0.541   821.950  0.462  4.389
hunt         -0.125 0.408   296.862  0.523  6.895
fish         -0.002 0.000   422.671  0.987  4.450
anim          0.131 0.521   202.983  0.471  6.898
brideprice    0.378 0.596 13300.845  0.440  3.256
nuclearfam   -0.004 0.000   112.260  0.994  3.055
ncmallow     -0.057 0.627   981.914  0.429  1.846
cultints      0.150 0.550  1561.885  0.458  6.986
tree         -0.403 0.134   142.694  0.714  4.679
roots        -0.815 0.905   514.243  0.342  6.762
cereals      -1.255 2.108   350.068  0.147 10.392 <--
settype       0.091 0.478    79.629  0.492  4.947
localjh       0.341 1.034   379.882  0.310  2.198
superjh       0.119 0.342   253.520  0.559  3.168
moralgods     0.152 0.753   523.133  0.386  2.420
segadlboys   -0.029 0.051   302.014  0.822  1.638
plow          0.386 0.239    67.818  0.626  4.125
pigs         -0.896 1.962   241.627  0.163  3.300
bovines       0.253 0.137  1209.822  0.712  5.941
milk         -0.476 0.444   214.674  0.506  5.496
agrlateboy    0.175 2.586    36.485  0.116  1.976 <--
valchild      0.009 0.085  3187.698  0.771  1.714
fratgrpstr   -0.068 0.075    34.544  0.786  4.924
Whyte577     -0.036 0.022     8.582  0.887  1.870
Whyte580     -0.221 0.608    29.801  0.442  2.475
Whyte584      0.078 0.081    90.580  0.777  2.378
Whyte585     -0.202 0.186    84.762  0.668  1.968
Whyte595     -0.235 0.292    30.304  0.593  2.045
Whyte602      0.205 0.179    34.362  0.675  1.993
Whyte615     -0.001 0.000   489.642  0.994  2.116
Whyte620     -0.143 0.201    58.050  0.656  2.525
Whyte626      0.093 0.036    37.515  0.851  2.443
Whyte629     -0.180 0.298    22.460  0.590  1.953
Whyte630     -0.325 1.017    34.929  0.320  2.134
Whyte631     -0.116 0.272    43.677  0.605  2.046
Whyte632     -0.142 0.392    30.763  0.536  1.993
Whyte633      0.020 0.004    17.691  0.950  2.545
Whyte635      0.168 0.235    34.861  0.631  2.111
Paige657     -0.933 2.949    48.353  0.092  2.044 <--
femproduceND  0.666 0.722    74.450  0.398  4.306
Paige659     -0.027 0.003    85.080  0.958  2.740
Paige660     -0.077 0.022   164.451  0.882  2.941
Paige661      0.322 0.347    66.139  0.558  3.604
Paige662     -0.525 1.329   214.008  0.250  2.317
fempower     -0.102 0.363    67.467  0.549  4.779
interperviol  0.392 0.898    62.082  0.347  1.950
migr         -0.206 0.191    20.196  0.666  2.109
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.4541159       0.9747282       0.9752836 
>  ols_stats$restrict_diagnostics
                Fstat          df pvalue
RESET           2.435      20.595  0.134
Wald.on.restrs  0.192     100.435  0.662
NCV            -0.078      20.111  1.000
SW.normal       0.930      55.606  0.339
lag..language   0.362 1597365.521  0.547
lag..distance   0.351    8309.954  0.554
>  table(depvar)
depvar
 1  2  3  4  5  6 
12 40  4 27 35 33 
>

15A more UR/2

 setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

15b results

              coef Fstat      ddf pvalue   VIF
(Intercept) -9.110 0.169   55.321  0.682    NA
language     0.256 0.040  166.936  0.842 2.935
distance    -0.293 0.188  117.867  0.665 2.667
Sanday664   -0.281 0.280   46.997  0.599 2.137
Sanday665    0.916 3.769  147.071  0.054 1.994 <--
Sanday666    0.332 0.371   18.106  0.550 2.365
Sanday667   -0.440 0.868   16.958  0.364 1.887
Sanday668    0.511 0.790   15.044  0.388 2.521
Sanday669   -0.117 0.410   15.880  0.531 3.710
Whyte718    -0.274 1.540   17.927  0.231 1.894
Whyte719    -0.060 0.049   11.932  0.829 1.930
Whyte720    -0.036 0.014   95.767  0.906 1.596
Whyte721     0.258 0.942   58.035  0.336 2.164
Whyte722     0.187 0.193   56.156  0.662 2.958
Whyte723    -0.412 1.141   39.909  0.292 2.792
Whyte724     0.609 3.237  237.461  0.073 1.657 <--
Whyte725    -0.136 0.196   21.124  0.663 1.875
Rohner798    0.002 0.040   53.740  0.842 2.023
Rohner799   -0.001 0.818  143.699  0.367 1.574
Rohner800    0.006 0.320  983.250  0.572 4.941
Rohner801   -0.517 0.060  196.180  0.807 3.343
Rohner802    0.005 0.282   17.166  0.603 1.848
Rohner803    0.007 0.854   34.315  0.362 1.708
Rohner804   -0.290 0.264   24.241  0.612 1.995
Rohner805    0.180 0.809  397.550  0.369 1.938
Rohner806   -0.085 0.223   17.453  0.643 2.178
Rohner807    0.189 0.193   89.396  0.661 2.043
Rohner808    0.254 0.315   48.354  0.577 2.165
Rohner809    0.240 0.110   54.174  0.742 2.560
Rohner810   -0.706 0.557  155.983  0.456 1.937
Rohner811   -0.020 0.011   13.246  0.920 1.952
Rohner812   -0.178 0.420   22.386  0.524 1.829
Rohner813   -0.120 0.176   26.057  0.678 1.922
foodtrade    0.028 1.609   68.729  0.209 2.435
fem_agri     0.003 0.094 4322.788  0.759 2.757
dateobs     -0.001 0.718  296.976  0.397 2.032
rain         0.034 0.062  534.421  0.804 3.485
temp         0.031 0.040   35.427  0.843 3.731
ecorich     -0.211 0.359 1328.491  0.549 3.350
pctFemPolyg  0.013 2.250   17.160  0.152 1.969 <--
femsubs     -0.104 0.458 1404.288  0.499 2.651
intwar      -0.116 0.169  116.873  0.682 1.840
extwar      -0.017 0.004   59.449  0.952 2.094
himilexp    -0.138 0.132   65.234  0.718 1.574
AP1          0.057 0.615  541.182  0.433 3.300
AP2         -0.139 0.831  131.496  0.364 3.046
pathstress  -0.026 0.136  319.435  0.713 3.601
war         -0.005 0.008   15.141  0.931 5.226
intwarB      0.046 0.653   12.870  0.434 3.930
extwarB      0.015 0.136   68.264  0.713 3.653
foodscarc    0.182 1.882  418.038  0.171 1.556
sexratio    -0.075 0.071   25.829  0.791 1.763
wagelabor    0.238 0.785   17.994  0.387 1.939
CVrain       0.001 0.122  413.234  0.727 1.734
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.3927231       0.9790866       0.9811172 
>  ols_stats$restrict_diagnostics
               Fstat        df pvalue
RESET          0.576    46.558  0.452
Wald.on.restrs 2.541    42.645  0.118
NCV            0.596    62.487  0.443
SW.normal      2.006    13.679  0.179
lag..language  0.222 16232.985  0.638
lag..distance  0.232 60246.056  0.630
>  table(depvar)

16A restricted to significant variables

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "bovines","gath","cereals","agrlateboy","Paige657","Sanday665","Whyte724","pctFemPolyg")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)


16B Results

              coef Fstat       ddf pvalue   VIF
(Intercept)  2.798 0.791  8573.723  0.374    NA
language    -0.136 0.025  5255.772  0.874 1.561
distance     0.128 0.080  8075.731  0.777 1.467
bovines      0.933 6.220  1585.199  0.013 1.775 <--
gath         0.061 0.380 19261.069  0.538 1.318
cereals     -0.415 1.711 18623.650  0.191 1.492 <--
agrlateboy   0.122 2.197    37.693  0.147 1.130 <--
Paige657    -0.741 3.603    79.160  0.061 1.121 <--
Sanday665    0.537 2.141    31.469  0.153 1.083 <--
Whyte724     0.229 0.652    46.612  0.424 1.097 
pctFemPolyg  0.012 6.300  1553.879  0.012 1.100 <--
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1914182       0.9796301       0.9783618 
>  ols_stats$restrict_diagnostics
               Fstat          df pvalue
RESET          1.313    1215.791  0.252
Wald.on.restrs 0.575      22.647  0.456
NCV            0.045    1559.740  0.833
SW.normal      8.099   15586.943  0.004
lag..language  0.140 1370331.230  0.708
lag..distance  0.119  609773.650  0.730
>  table(depvar)

17A

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "bovines","cereals","agrlateboy","Paige657","Sanday665","pctFemPolyg")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

17b

              coef Fstat        ddf pvalue   VIF
(Intercept)  2.692 0.656    229.248  0.419    NA
language    -0.053 0.004    286.383  0.952 1.548
distance     0.173 0.153  28243.356  0.696 1.422
bovines      0.850 5.692   2011.910  0.017 1.615 
cereals     -0.428 1.903 404465.324  0.168 1.438
agrlateboy   0.141 3.544    156.345  0.062 1.125
Paige657    -0.665 3.347    404.291  0.068 1.123
Sanday665    0.423 1.449     56.201  0.234 1.071
pctFemPolyg  0.013 6.292    430.660  0.012 1.095
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1801392       0.9763253       0.9781862 
>  ols_stats$restrict_diagnostics
                Fstat          df pvalue
RESET           0.524     155.678  0.470
Wald.on.restrs  0.365      65.096  0.548
NCV            -0.012    1228.140  1.000
SW.normal       7.749     186.666  0.006
lag..language   0.153    5567.485  0.696
lag..distance   0.146 1001431.421  0.702
>table(depvar)

18A

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "bovines","cereals","agrlateboy","Paige657","pctFemPolyg")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

18b

740.  Marriage Arrangements (Female)
    35    . = Missing data
    12    1 = Individual selects and/or courts partner autonomously:
              approval by parents or others unnecessary
    40    2 = Individual selects and/or courts partner authonomously:
              parental, kin, and/or community approval necessary
              or highly desireable
     4    3 = Individual suggests partner to parents or others;
              arrangements for courtship or marriage then proceed
              if choice is approved
            OR parents ask approval of individuals to initiate
              a match
            OR individual is approached by parent or others on
              behalf of suitor and can accept or reject the match
    27    4 = Individual choice and arranged marriages are
              alternatives
    35    5 = Parents choose partner: individual can object
    33    6 = Parents choose partner: individual cannot easily
              object or rarely objects in fact
              coef Fstat       ddf pvalue   VIF
(Intercept)  4.112 1.752  2271.915  0.186    NA
language    -0.043 0.003  2102.582  0.959 1.510
distance     0.103 0.052  3134.329  0.820 1.434
bovines      0.915 6.948 60630.238  0.008 1.560 v244
cereals     -0.439 1.989 73277.533  0.158 1.427 v233
agrlateboy   0.108 2.087   125.371  0.151 1.105 v300
Paige657    -0.820 5.125   807.757  0.024 1.096 v657
pctFemPolyg  0.014 7.479  1159.950  0.006 1.089 v872
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1673019       0.9781903       0.9797853 
>  ols_stats$restrict_diagnostics
                Fstat          df pvalue
RESET           1.509     180.276  0.221
Wald.on.restrs  1.097      22.432  0.306
NCV            -0.050      83.456  1.000
SW.normal      11.233     716.178  0.001
lag..language   0.138 4788867.126  0.710
lag..distance   0.134  163702.740  0.714
>  table(depvar)

19a

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
extramaritalsex=sccs$v170,
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"extramaritalsex","famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "extramaritalsex","bovines","cereals","agrlateboy","Paige657","pctFemPolyg")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

19b v170 not significant

                   coef Fstat       ddf pvalue   VIF
 (Intercept)      4.030 1.615   751.354  0.204    NA
 language        -0.099 0.013  3202.687  0.908 1.532
 distance         0.095 0.041   693.801  0.840 1.501
 extramaritalsex -0.049 0.090    20.230  0.768 1.150
 bovines          0.932 7.134 22919.340  0.008 1.558
 cereals         -0.463 2.158  6693.335  0.142 1.433
 agrlateboy       0.152 4.722  2950.531  0.030 1.081
 Paige657        -0.682 3.120    80.076  0.081 1.105
 pctFemPolyg      0.012 5.487  1573.854  0.019 1.114
 >  ols_stats$r2
  R2:final model R2:IV_ language R2:IV_ distance 
       0.1656127       0.9808223       0.9828484 
 >  ols_stats$restrict_diagnostics
                 Fstat        df pvalue
 RESET           1.170   124.368  0.281
 Wald.on.restrs  0.692     9.546  0.426
 NCV             0.125   844.722  0.724
 SW.normal      11.830  1294.845  0.001
 lag..language   0.107 56856.417  0.743
 lag..distance   0.057 80823.606  0.812
>  table(depvar)

20A

setwd("C:/My Documents/sccs")

library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
premarsexfrqf=sccs$v167,
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"premarsexfrqf","famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "premarsexfrqf","bovines","cereals","agrlateboy","Paige657","pctFemPolyg")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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
table(depvar)

20B Premarsexfreq in female significant

                 coef  Fstat       ddf pvalue   VIF
 (Intercept)    3.042  1.035  2742.393  0.309    NA
 language      -0.013  0.000   348.768  0.988 1.540
 distance      -0.011  0.001   373.225  0.981 1.457
 premarsexfrqf  0.404 13.007   107.777  0.000 1.085
 bovines        0.908  7.598 89769.573  0.006 1.549
 cereals       -0.612  3.852   356.061  0.050 1.469
 agrlateboy     0.120  3.269   787.424  0.071 1.080
 Paige657      -0.545  2.553  3775.200  0.110 1.114
 pctFemPolyg    0.014  8.992   356.277  0.003 1.064
 >  ols_stats$r2
  R2:final model R2:IV_ language R2:IV_ distance 
       0.2489899       0.9806353       0.9831675 
 >  ols_stats$restrict_diagnostics
                 Fstat         df pvalue
 RESET           0.482     42.842  0.491
 Wald.on.restrs -0.002      4.855  1.000
 NCV             0.152   5212.227  0.696
 SW.normal       5.489    115.887  0.021
 lag..language   0.091 271052.851  0.762
 lag..distance   0.124  10238.026  0.725
 >  table(depvar)
 depvar
  1  2  3  4  5  6 
 12 40  4 27 35 33 
>

21A

setwd("/Users/drwhite/Documents/sccs")

setwd("C:/My Documents/sccs")
library(sccs)
data(sccs)                                 
depvar=sccs$v740
my_sccs<-data.frame(
dep_var=sccs$v740,
socname=sccs$socname,socID=sccs$"sccs#",
fembodytype=sccs$v1248,
famsize=sccs$v68,    # similar to v80
exogamy=sccs$v72,
#famsizeB=sccs$v80,   # similar to v68
money=sccs$v155,
popdens=sccs$v156,
premarsexatt=sccs$v165,
premarsexfrq=sccs$v166,
malesexag=sccs$v175,
ndrymonth=sccs$v196,
gath=sccs$v203,
hunt=sccs$v204,
fish=sccs$v205,
anim=sccs$v206,
brideprice=(sccs$v208==1)*1,
nuclearfam=(sccs$v210<=3)*1,
ncmallow=sccs$v227,
cultints=sccs$v232,
tree=(sccs$v233==4)*1,
roots=(sccs$v233==5)*1,
cereals=(sccs$v233==6)*1,
settype=sccs$v234,
localjh=sccs$v236-1,
superjh=sccs$v237,
moralgods=sccs$v238,
segadlboys=sccs$v242,
plow=(sccs$v243>1)*1,
pigs=(sccs$v244==2)*1,
bovines=(sccs$v244==7)*1,
milk=(sccs$v245>1)*1,
agrlateboy=sccs$v300,
valchild=(sccs$v473+sccs$v474+sccs$v475+sccs$v476),
fratgrpstr=sccs$v570,
Whyte577=sccs$v577,    #take care using Whyte variables - only coded 1/2 the sample
Whyte580=sccs$v580,
Whyte584=sccs$v583,
Whyte585=sccs$v584,
Whyte595=sccs$v595,
Whyte602=sccs$v602,
Whyte615=sccs$v615,
Whyte620=sccs$v620,
Whyte626=sccs$v626,
Whyte629=sccs$v629,
Whyte630=sccs$v630,
Whyte631=sccs$v631,
Whyte632=sccs$v632,
Whyte633=sccs$v633,
Whyte635=sccs$v635,
#                    #take care using Paige variables - coded less than 1/2 the sample
Paige657=sccs$v657,  # summed in v663#  Paige657 Paige658 Paige659 Paige660 Paige661 Paige662
femproduceND=sccs$v658, #Paige658=sccs$v658,  # summed in v663 
Paige659=sccs$v659,  # summed in v663
Paige660=sccs$v660,  # summed in v663
Paige661=sccs$v661,  # summed in v663
Paige662=sccs$v662,  # summed in v663
fempower=sccs$v663, # sum of v657-662
interperviol=sccs$v666,   ###synonyms: violence / interviol / freintovio
migr=(sccs$v677==2)*1,
#                    #take care using Sanday variables - only coded 1/2 the sample
Sanday664=sccs$v664,  # summed in v669
Sanday665=sccs$v665,  # summed in v669
Sanday666=sccs$v666,  # summed in v669
Sanday667=sccs$v667,  # summed in v669
Sanday668=sccs$v668,  # summed in v669
Sanday669=sccs$v669, # sum of v664-668 
 #WHYTE Data Quality Whyte718 Whyte719 Whyte720 Whyte721 Whyte722 Whyte723 Whyte724 Whyte725
Whyte718=sccs$v718,    #take care using Whyte variables - only coded 1/2 the sample
Whyte719=sccs$v719,
Whyte720=sccs$v720,
Whyte721=sccs$v721,
Whyte722=sccs$v722,
Whyte723=sccs$v723,
Whyte724=sccs$v724,
Whyte725=sccs$v725,
 #Rohner Data Quality Codes 
Rohner798=sccs$v798,
Rohner799=sccs$v799,
Rohner800=sccs$v800,
Rohner801=sccs$v801,
Rohner802=sccs$v802,
Rohner803=sccs$v803,
Rohner804=sccs$v804,
Rohner805=sccs$v805,
Rohner806=sccs$v806,
Rohner807=sccs$v807,
Rohner808=sccs$v808,
Rohner809=sccs$v809,
Rohner810=sccs$v810,
Rohner811=sccs$v811,
Rohner812=sccs$v812,
Rohner813=sccs$v813,
foodtrade=sccs$v819,
fem_agri=sccs$v821, 
dateobs=sccs$v838,
rain=sccs$v854,
temp=sccs$v855,
#ecorich=sccs$v857,
ecorich=(sccs$v857==3|sccs$v857==4)*1+(sccs$v857==5)*2,
pctFemPolyg=sccs$v872,
marrcaptives=sccs$v870,
femsubs=sccs$v890,
intwar=sccs$v891,    # similar to 1649
extwar=sccs$v892,    # similar to 1650
himilexp=(sccs$v899==1)*1,
plunder=sccs$v912,
AP1=sccs$v921,           ###agricultural potential 1
AP2=sccs$v928,           ###agricultural potential 2
pathstress=sccs$v1260,
war=sccs$v1648,     # overall -- sum of internal and external
intwarB=sccs$v1649,  # similar to v891
extwarB=sccs$v1650,  # similar to v892
foodscarc=sccs$v1685,
sexratio=1+(sccs$v1689>85)+(sccs$v1689>115),
wagelabor=sccs$v1732,
CVrain=sccs$v1914/sccs$v1913   #no comma
)  
indep_vars<-c(
"fembodytype","famsize","exogamy",    "money","popdens","malesexag","ndrymonth","gath","hunt","fish",
"anim","brideprice","nuclearfam","ncmallow","cultints","tree","roots","cereals","settype","localjh",
"superjh","moralgods","segadlboys","plow","pigs","bovines","milk","agrlateboy","valchild","fratgrpstr",
"Whyte577","Whyte580","Whyte584","Whyte585","Whyte595","Whyte602","Whyte615","Whyte620","Whyte626","Whyte629",
"Whyte630","Whyte631","Whyte632","Whyte633","Whyte635","Paige657","femproduceND","Paige659","Paige660",
"Paige661","Paige662","fempower","interperviol","migr","Sanday664","Sanday665","Sanday666","Sanday667",
"Sanday668","Sanday669","Whyte718","Whyte719","Whyte720","Whyte721","Whyte722","Whyte723","Whyte724",
"Whyte725","Rohner798","Rohner799","Rohner800","Rohner801","Rohner802","Rohner803","Rohner804","Rohner805",
"Rohner806","Rohner807","Rohner808","Rohner809","Rohner810","Rohner811","Rohner812","Rohner813","foodtrade","fem_agri",
"dateobs","rain","temp","ecorich","pctFemPolyg","femsubs","intwar","extwar","himilexp","AP1","AP2",
"pathstress","war","intwarB","extwarB","foodscarc","sexratio","wagelabor","CVrain"
)


restrict_vars=c( "fembodytype","bovines","cereals","agrlateboy","Paige657","pctFemPolyg")
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<-"marriage arrangement"
alias<-"AHNMarriageArrn"
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( 
ztxt<-gsub("NaN",".",ztxt)
text(lon,lat,ztxt)
ols_stats$restrict_stats
ols_stats$r2
ols_stats$restrict_diagnostics
table(depvar)

21B depvar=sccs$v740>4 (arranged4fem) with v1248 Female body type significant

Marriage arrangement table today.png
740.  Marriage Arrangements (Female)
    35    . = Missing data
    12    1 = Individual selects and/or courts partner autonomously:
              approval by parents or others unnecessary
    40    2 = Individual selects and/or courts partner authonomously:
              parental, kin, and/or community approval necessary
              or highly desireable
     4    3 = Individual suggests partner to parents or others;
              arrangements for courtship or marriage then proceed
              if choice is approved
            OR parents ask approval of individuals to initiate
              a match
            OR individual is approached by parent or others on
              behalf of suitor and can accept or reject the match
    27    4 = Individual choice and arranged marriages are
              alternatives
    35    5 = Parents choose partner: individual can object
    33    6 = Parents choose partner: individual cannot easily
              object or rarely objects in fact



FINAL MODEL! YAY =]

              coef Fstat      ddf pvalue   VIF
(Intercept)  3.331 1.139 1094.359  0.286    NA
language    -0.031 0.001 2261.350  0.971 1.528
distance     0.047 0.010  161.026  0.921 1.465
fembodytype  0.223 2.407   14.785  0.142 1.101 v1248 (slim)
bovines      0.832 4.807   83.529  0.031 1.608 v244 
cereals     -0.490 2.480 8340.874  0.115 1.439 v233
agrlateboy   0.141 2.651   16.004  0.123 1.083 v300
Paige657    -0.632 2.922  160.980  0.089 1.106 v657 Divorce easy (neg:Hard)
pctFemPolyg  0.012 4.596   37.315  0.039 1.079 v872
>  ols_stats$r2
 R2:final model R2:IV_ language R2:IV_ distance 
      0.1863415       0.9796791       0.9810386 
>  ols_stats$restrict_diagnostics
               Fstat         df pvalue
RESET          0.165     51.784  0.687
Wald.on.restrs 1.172     11.133  0.302
NCV            0.165    743.011  0.685
SW.normal      9.562   6418.321  0.002
lag..language  0.135 435608.833  0.713
lag..distance  0.120  24671.162  0.729
>  table(depvar)
depvar
 1  2  3  4  5  6 
12 40  4 27 35 33 
>