Variables in SPSS FILES (STDS*.sav) and MAPTAB (ST*.dat) FILES

 Eff and Brown model. Converted from DEf01d to DEf01f. Used [[StartSimple]] to convert html to correct left margin spacing
 Using  the  Dow-Eff  functions  in  R:  working  with  the  SCCS
 
 The  latest  version  of  the  Dow-Eff  functions  (Manual:  pdf;  html)  can  perform  analyses  on  five  different  ethnological  datasets:
 
 abbreviation dataset codebook
 WNAI Western  North  American  Indians codebook
 SCCS Standard  Cross-Cultural  Sample codebook
 EA Ethnographic  Atlas codebook
 LRB Lewis  R.  Binford's  forager  data codebook
 XC Merged  371  society  data codebook
 The  code  below  outlines  the  workflow  for  working  with  the  SCCS.
 
 You  will  need  a  number  of  R  packages  to  run  the  Dow-Eff  functions.  These  are  loaded  using  the  “library”  command.  If  a  package  is  “not  found”,  it  should  be  first  installed.  The  following  command  will  initiate  the  installation  of  a  package  named  “mice”,  for  example:
 e.g., 
 install.packages("mice")
 COPY FROM HERE TO '''CSVwrite(h, "'Eff-Brown MoralGods1 at the end of the run
 #  --set  working  directory  and  load  needed  libraries--
 options(width  =  150)
 setwd("e:/Dropbox/functions/")
 ##  Error:  cannot  change  working  directory
 library(Hmisc)
 library(mice)
 library(foreign)
 library(stringr)
 library(AER)
 library(spdep)
 library(psych)
 library(geosphere)
 library(relaimpo)
 library(linprog)
 library(dismo)
 library(forward)
 library(pastecs)
 library(classInt)
 library(maps)
 library(dismo)
 library(plyr)
 library(aod)
 library(reshape)
 library(RColorBrewer)
 library(XML)
 library(tm)
 library(mlogit)
 library(stringr) #new with DEF01f for str_c  is in package stringr needed for addesc("inhreal","real property is inherited")     
 #The  Dow-Eff  functions,  as  well  as  the  five  ethnological  datasets,  are  contained  in  an  R-workspace,  located  in  the  cloud.
 
 #load(url("http://dl.dropbox.com/u/9256203/DEf01d.Rdata"),  .GlobalEnv)
 load(url("http://dl.dropbox.com/u/9256203/DEf01d.Rdata"),  .GlobalEnv)
 ls()    #-can  see  the  objects  contained  in  DEf01d.Rdata
 ##    [1]  "addesc"            "capwrd"            "chK"                  "CSVwrite"        "doLogit"          "doMI"                "doMNLogit"      "doOLS"              "EA"                    "EAcov"            
 ##  [11]  "EAfact"            "EAkey"              "fv4scale"        "gSimpStat"      "kln"                  "llm"                  "LRB"                  "LRBcov"            "LRBfact"          "LRBkey"          
 ##  [21]  "MEplots"          "mkcatmappng"  "mkdummy"          "mkmappng"        "mknwlag"          "mkscale"          "mkSq"                "mmgg"                "plotSq"            "quickdesc"    
 ##  [31]  "resc"                "rmcs"                "rnkd"                "SCCS"                "SCCScov"          "SCCSfact"        "SCCSkey"          "setDS"              "showlevs"        "spmang"          
 ##  [41]  "widen"              "WNAI"                "WNAIcov"          "WNAIfact"        "WNAIkey"          "XC"                    "XCcov"              "XCfact"            "XCkey"
 #The  setDS(  xx  )  command  sets  one  of  the  four  ethnological  datasets  as  the  source  for  the  subsequent  analysis.  The  five  valid  options  for  xx  are:  “XC”,  “LRB”,  “EA”,  “SCCS”,  and  “WNAI”.  The  setDS()  command  creates  objects:
 
 #object  name description
 #cov Names  of  covariates  to  use  during  imputation  step
 #dx The  selected  ethnological  dataset  is  now  called  dx
 #dxf The  factor  version  of  dx
 #key A  metadata  file  for  dx
 #wdd A  geographic  proximity  weight  matrix  for  the  societies  in  dx
 #wee An  ecological  similarity  weight  matrix  for  the  societies  in  dx
 #wll A  linguistic  proximity  weight  matrix  for  the  societies  in  dx
 setDS("SCCS")
 #The  next  step  in  the  workflow  is  to  create  any  new  variables  and  add  them  to  the  dataset  dx.  New  variables  can  be  created  directly,  as  in  the  following  example.  When  created  in  this  way,  one  should  also  record  a  description  of  the  new  variable,  using  the  command  addesc().  The  syntax  takes  first  the  name  of  the  new  variable,  and  then  the  description.
 
 #dx$inhreal  =  (SCCS$v278  >  1)  *  1
  dx$inhreal  =  (dx$v278  >  1)  *  1  #converted from DEf01d to DEf01f
 #addesc("inhreal",  "Dummy:  real  property  is  inherited")
  addesc("inhreal","real  property  is  inherited")  #not working
  addesc("inhreal","real property is inherited")     
 #inhmove  =  (SCCS$v279  >  1)  *  1
  dx$inhmove  =  (dx$v279  >  1)  *  1  #converted from DEf01d to DEf01f
 addesc("inhmove",  "Dummy:  movable  property  is  inherited")
 #dx$marrgood  =  (SCCS$v208  <  4)  *  1
  dx$marrgood  =  (dx$v208  <  4)  *  1  #converted from DEf01d to DEf1f
 addesc("marrgood",  "Dummy:  marriage  includes  transfer  of  goods")
 #Dummy  variables  (variables  taking  on  the  values  zero  or  one)  should  be  added  using  the  command  mkdummy().  This  command  will  automatically  record  a  variable  description.  Dummy  variables  are  appropriate  for  categorical  variables.  The  syntax  of  mkdummy()  takes  first  the  categorical  variable  name,  and  then  the  category  number  (these  can  be  found  in  the  codebook  for  each  ethnological  dataset).  Note  that  the  resulting  dummy  variable  will  be  called  variable  name+“.d”+category  number.
 
 mkdummy("v245",  2)
 ##  [1]  "This  dummy  variable  is  named  v245.d2"
 ##  [1]  "The  variable  description  is:  'Milking  of  Domestic  Animals  ==  Milked  more  often  than  sporadically'"
 #After  making  any  new  variables,  list  the  variables  you  intend  to  use  in  your  analysis  in  the  following  form.
 
 evm  <-  c("v238",  "v921",  "v928",  "v1685",  "v232",  "v206",  "v245.d2",  "v270",  "v272",  "v237",  "v155",  "v72",  "v1726",  "inhreal",  "inhmove",  "marrgood",  
         "v63",  "v64",  "v1665",  "v1666",  "v1667",  "v666",  "v767",  "v768",  "v770",  "v773",  "v891",  "v1649",  "v1650")
 #Missing  values  of  these  variables  are  then  imputed,  using  the  command  doMI().  Below,  the  number  of  imputed  datasets  is  5,  and  7  iterations  are  used  to  estimate  each  imputed  value  (5  imputations  is  borderline  OK,  10  or  15  would  be  better).  The  stacked  imputed  datasets  are  collected  into  a  single  dataframe  which  here  is  called  smi.
 
 #This  new  dataframe  smi  will  contain  not  only  the  variables  in  evm,  but  also  a  set  of  normalized  (mean=0,  sd=1)  variables  related  to  climate,  location,  and  ecology  (these  are  used  in  the  OLS  analysis  to  address  problems  of  endogeneity).  In  addition,  squared  values  are  calculated  automatically  for  variables  with  at  least  three  discrete  values  and  maximum  absolute  values  no  more  than  300.  These  squared  variables  are  given  names  in  the  format  variable  name+“Sq”.
 
 #Finally,  smi  contains  a  variable  called  “.imp”,  which  identifies  the  imputed  dataset,  and  a  variable  called  “.id”  which  gives  the  society  name.
 
 smi  <-  doMI(evm,  nimp  =  5,  maxit  =  7)
 ##  [1]  "--create  variables  to  use  as  covariates--"
 ##  [1]  "--finding  covariates  for    inhreal,  inhmove  --"
 ##  [1]  "v238"
 ##  [1]  "v1685"
 ##  [1]  "v272"
 ##  [1]  "v237"
 ##  [1]  "v72"
 ##  [1]  "v1726"
 ##  [1]  "inhreal"
 ##  [1]  "inhmove"
 ##  [1]  "v63"
 ##  [1]  "v64"
 ##  [1]  "v1665"
 ##  [1]  "v1666"
 ##  [1]  "v1667"
 ##  [1]  "v666"
 ##  [1]  "v767"
 ##  [1]  "v768"
 ##  [1]  "v770"
 ##  [1]  "v773"
 ##  [1]  "v891"
 ##  [1]  "v1649"
 ##  [1]  "v1650"
 ##  [1]  "WARNING:  variable  may  not  be  ordinal--v272"        "WARNING:  variable  may  not  be  ordinal--v270"        "WARNING:  variable  may  not  be  ordinal--society"
 ##  [4]  "WARNING:  variable  may  not  be  ordinal--dxid"      
 ##  Time  difference  of  44.35  secs
 dim(smi)    #  dimensions  of  new  dataframe  smi
 ##  [1]  930  121
 smi[1,  ]    #  first  row  of  new  dataframe  smi
 ##      .imp    .id  v238  v1685  v272  v237  v72  v1726  inhreal  inhmove  v63  v64  v1665  v1666  v1667  v666  v767  v768  v770  v773  v891  v1649  v1650              x            y
 ##  1        1  Nama        1          3        1        2      5          3              0              1      3      1          1          5          1        2        4        3        3        3        2        17        17  0.02853  -1.513
 ##                    x2      y2              xy  Austronesian  Nigercongo  mht.name.dTropicalandsubtropicalgrasslandssavannasandshrublands
 ##  1  0.0008138  2.29  -0.04317                        0                    0                                                                                                                              0
 ##      mht.name.dTropicalandsubtropicalmoistbroadleafforests  koeppengei.dAf  koeppengei.dAw  continent.dAfrica  continent.dAsia  continent.dNorthAmerica
 ##  1                                                                                                          0                            0                            0                                  1                              0                                              0
 ##      continent.dSouthAmerica  region.dNorthernAmerica  region.dSouthAmerica  v921  v928  v232  v206  v245.d2  v270  v155  marrgood    bio.1  bio.2      bio.3      bio.4
 ##  1                                              0                                              0                                        0      12        3        1        5              1        2        1                0  0.1332  1.955  0.07924  0.04614
 ##        bio.5      bio.6    bio.8    bio.9  bio.10    bio.11  bio.12  bio.13    bio.14  bio.15  bio.16    bio.17    bio.18    bio.19  meanalt  mnnpp      sdalt  society      lati    long
 ##  1  0.4791  -0.2195  0.4183  -0.245    0.178  0.05293  -1.122  -1.111  -0.7111      1.39  -1.078  -0.7497  -0.7118  -0.9043      1.024  -1.02  -0.4929        Nama  -23.32  17.08
 ##      dxid  v238Sq  v1685Sq  v272Sq  v237Sq  v72Sq  v1726Sq  v63Sq  v64Sq  v1665Sq  v1666Sq  v1667Sq  v767Sq  v768Sq  v770Sq  v773Sq  v891Sq  v1649Sq  v1650Sq  v921Sq
 ##  1        1            1              9            1            4        25              9          9          1              1            25              1          16            9            9            9            4          289          289        144
 ##      v928Sq  v232Sq  v206Sq  v270Sq  v155Sq  bio.1Sq  bio.2Sq    bio.3Sq    bio.4Sq  bio.5Sq  bio.6Sq  bio.8Sq  bio.9Sq  bio.10Sq  bio.11Sq  bio.12Sq  bio.13Sq  bio.14Sq
 ##  1            9            1          25            4            1  0.01775      3.821  0.006279  0.002129    0.2295  0.04818      0.175  0.06001    0.03168  0.002802        1.259        1.234      0.5057
 ##      bio.15Sq  bio.16Sq  bio.17Sq  bio.18Sq  bio.19Sq  meanaltSq  mnnppSq  sdaltSq  latiSq  longSq  dxidSq
 ##  1        1.933        1.162      0.5621      0.5066      0.8178          1.049        1.04    0.2429    543.7    291.8            1
 #The  variables  for  a  scale  can  be  combined  using  the  function  mkscale.  The  function  can  calculate  three  different  kinds  of  scales:  1)  based  on  linear  programming  as  described  in  Eff  (2010);  2)  the  mean  of  the  standardized  values;  3)  the  first  principal  component  of  the  standardized  values.  Below,  three  scales  are  created  using  the  first  principal  component.
 
 #One  should  look  at  the  output  of  mkscale  to  ensure  that  the  components  correlate  in  the  expected  way  with  the  final  scale.  The  column  “inv”  in  fec$corrs  shows  that  whether  the  variable  was  inverted.  Compare  that  with  the  description  of  the  variable,  and  its  factor  levels,  to  understand  whether  it  correlates  as  expected.
 
 
 #  ==agricultural  potential==
 agp  <-  c("v921",  "v928")
 fec  <-  mkscale(compvarbs  =  "agp",  udnavn  =  "PCAP",  impdata  =  smi,  set.direction  =  "v921",  type  =  "pc1",  add.descrip  =  "1st  PC:  Agricultural  potential  high")
 ##  [1]  "PCAP"
 ##  [1]  "Pct  Variance  Explained  by  component"
 ##  Comp.1  Comp.2  
 ##  0.8257  0.1743  
 ##  c("v921",  "v928")
 #  --check  reasonableness  of  scale--
 fec$stats
 ##      std.alpha
 ##  1        0.7889
 fec$corrs
 ##            min.load  max.load  cor.w.scale  inv  varb                                                                                                                      description
 ##  v921      0.7071      0.7071              0.909      1  v921        Agricultural  Potential  1:  Sum  of  Land  Slope,  Soils,  Climate  Scales
 ##  v928      0.7071      0.7071              0.909      1  v928  Agricultural  Potential  2:  Lowest  of  Land  Slope,  Soils,  Climate  Scales
 smi[,  names(fec$scales)]  <-  fec$scales
 
 #  ==commmunity  size==
 csz  <-  c("v63",  "v237")
 fec  <-  mkscale(compvarbs  =  "csz",  udnavn  =  "PCsize",  impdata  =  smi,  set.direction  =  "v63",  type  =  "pc1",  add.descrip  =  "1st  PC:  Community  size  large")
 ##  [1]  "PCsize"
 ##  [1]  "Pct  Variance  Explained  by  component"
 ##  Comp.1  Comp.2  
 ##  0.7325  0.2675  
 ##  c("v237",  "v63")
 #  --check  reasonableness  of  scale--
 fec$stats
 ##      std.alpha
 ##  1        0.6347
 fec$corrs
 ##            min.load  max.load  cor.w.scale  inv  varb                                                                          description
 ##  v63        0.7071      0.7071              0.856      1  v237  Jurisdictional  Hierarchy  beyond  Local  Community
 ##  v237      0.7071      0.7071              0.856      1    v63                                                                    Community  Size
 smi[,  names(fec$scales)]  <-  fec$scales
 
 #  ==violence==
 vio  <-  c("v1665",  "v1666",  "v1667")
 fec  <-  mkscale(compvarbs  =  "vio",  udnavn  =  "PCviol",  impdata  =  smi,  set.direction  =  "v1665",  type  =  "pc1",  add.descrip  =  "1st  PC:  High  levels  of  violence")
 ##  [1]  "PCviol"
 ##  [1]  "Pct  Variance  Explained  by  component"
 ##  Comp.1  Comp.2  Comp.3  
 ##  0.5829  0.2399  0.1772  
 ##  c("v1667",  "v1665",  "v1666")
 #  --check  reasonableness  of  scale--
 fec$stats
 ##      std.alpha
 ##  1        0.6398
 fec$corrs
 ##              min.load  max.load  cor.w.scale  inv    varb                                            description
 ##  v1667      0.5141      0.5424              0.701      1  v1667        Individual  Aggression  -  Theft
 ##  v1665      0.5727      0.6156              0.776      1  v1665  Individual  Aggression  -  Homicide
 ##  v1666      0.5946      0.6257              0.809      1  v1666    Individual  Aggression  -  Assault
 smi[,  names(fec$scales)]  <-  fec$scales
 #All  of  the  variables  selected  to  play  a  role  in  the  model  must  be  found  in  the  new  dataframe  smi.  Below,  the  variables  are  organized  according  to  the  role  they  will  play.
 
 #  --dependent  variable--
 dpV  <-  "v238"
 #  --independent  variables  in  UNrestricted  model--
 UiV  <-  c("PCAP",  "PCsize",  "PCsizeSq",  "PCviol",  "v1685",  "v232",  "v206",  "v245.d2",  "v270",  "v272",  "v155",  "v72",  "v1726",  "inhreal",  "inhmove",  "marrgood",  
         "v64",  "v666",  "v767",  "v768",  "v770",  "v773",  "v891",  "v1649",  "v1650")
 #  --independent  variables  in  restricted  model  (all  must  be  in  UiV  above)--
 RiV  <-  c("PCAP",  "PCsize",  "PCsizeSq",  "v1685",  "v206",  "v272",  "v1650")
 CSVwrite(h, "Eff-Brown MoralGods1.noEW", FALSE)
 
 
 
 
 #The  command  doOLS()  estimates  the  model  on  each  of  the  imputed  datasets,  collecting  output  from  each  estimation  and  processing  them  to  obtain  final  results.  To  control  for  Galton's  Problem,  a  network  lag  model  is  used,  with  the  user  able  to  choose  a  combination  of  geographic  proximity  (dw),  linguistic  proximity  (lw),  and  ecological  similarity  (ew)  weight  matrices.  In  most  cases,  the  user  should  choose  the  default  of  dw=TRUE,  lw=TRUE,  ew=FALSE.
 
 #There  are  several  options  that  increase  the  time  doOLS()  takes  to  run:  stepW  runs  a  background  stepwise  regression  to  find  which  variables  perform  best  over  the  set  of  estimations;  relimp  calculates  the  relative  importance  of  each  variable  in  the  restricted  model,  using  a  technique  to  partition  R2;  slmtests  calculates  LaGrange  multiplier  tests  for  spatial  dependence  using  the  three  weight  matrices.  All  of  these  should  be  set  to  FALSE  if  one  wishes  to  speed  up  estimation  times.
 
 h  <-  doOLS(smi,  depvar  =  dpV,  indpv  =  UiV,  rindpv  =  RiV,  othexog  =  NULL,  dw  =  TRUE,  lw  =  TRUE,  ew  =  FALSE,  stepW  =  FALSE,  boxcox  =  FALSE,  getismat  =  FALSE,  
         relimp  =  TRUE,  slmtests  =  FALSE,  haustest  =  NULL,  mean.data  =  TRUE,  doboot  =  300,  full.set  =  FALSE)
 ##  [1]  "--finding  optimal  weight  matrix------"
 ##  [1]  "Exogenous  variables  used  to  instrument  Wy:    xWPCAP,  xWPCsize,  xWv1685,  xWv245.d2,  xWv270,  xWv72,  xWv1726,  xWmarrgood,  xWv64,  xWv666,  xWv767,  xWv768,  xWv891,  xWv1649,  xWv1650,  xWPCviolSq,  xWv1685Sq,  xWv232Sq,  xWv270Sq,  xWv272Sq,  xWv72Sq,  xWv64Sq,  xWv768Sq,  xWv770Sq,  xWv773Sq,  xWv891Sq,  xWv1649Sq"
 ##  [1]  "--looping  through  the  imputed  datasets--"
 ##  [1]  1
 ##  [1]  2
 ##  [1]  3
 ##  [1]  4
 ##  [1]  5
 ##  Warning:  no  non-missing  arguments  to  max;  returning  -Inf
 ##  Warning:  no  non-missing  arguments  to  max;  returning  -Inf
 ##  Warning:  no  non-missing  arguments  to  max;  returning  -Inf
 ##  Time  difference  of  42.12  secs
 names(h)
 ##    [1]  "DependVarb"                                "URmodel"                                      "model.varbs"                              "Rmodel"                                        "EndogeneityTests"                  
 ##    [6]  "Diagnostics"                              "OtherStats"                                "DescripStats.ImputedData"    "DescripStats.OriginalData"  "totry"                                        
 ##  [11]  "didwell"                                      "usedthese"                                  "dfbetas"                                      "data"
 The  output  from  doOLS(),  here  called  h,  is  a  list  containing  14  items.
 
 name description
 DependVarb Description  of  dependent  variable
 URmodel Coefficient  estimates  from  the  unrestricted  model  (includes  standardized  coefficients  and  VIFs).  Two  pvalues  are  given  for  H0:  β  =0.  One  is  the  usual  pvalue,  the  other  (hcpval)  is  heteroskedasticity  consistent.  If  stepkept=TRUE,  the  table  will  also  include  the  proportion  of  times  a  variable  is  retained  in  the  model  using  stepwise  regression.
 model.varbs Short  descriptions  of  model  variables:  shows  the  meaning  of  the  lowest  and  highest  values  of  the  variable.  This  can  save  a  trip  to  the  codebook.
 Rmodel Coefficient  estimates  from  the  restricted  model.  If  relimp=TRUE,  the  R2  assigned  to  each  independent  variable  is  shown  here.
 EndogeneityTests Hausman  tests  (H0:  variable  is  exogneous),  with  F-statistic  for  weak  instruments  (a  rule  of  thumb  is  that  the  instrument  is  weak  if  the  F-stat  is  below  10),  and  Sargan  test  (H0:  instrument  is  uncorrelated  with  second-stage  2SLS  residuals).
 Diagnostics Regression  diagnostics  for  the  restricted  model:  RESET  test  (H0:  model  has  correct  functional  form);  Wald  test  (H0:  appropriate  variables  dropped);  Breusch-Pagan  test  (H0:  residuals  homoskedastic;  Shapiro-Wilkes  test  (H0:  residuals  normal);  Hausman  test  (H0:  Wy  is  exogenous);  Sargan  test  (H0:  residuals  uncorrelated  with  instruments  for  Wy).  If  slmtests=TRUE,  the  LaGrange  multiplier  tests  (H0:  spatial  error  model  not  appropriate)  are  reported  here.
 OtherStats Other  statistics:  Composite  weight  matrix  weights  (see  details);  R2  for  restricted  model  and  unrestricted  model;  number  of  imputations;  number  of  observations;  Fstat  for  weak  instruments  for  Wy.
 DescripStats.ImputedData Descriptive  statistics  for  model  variables  found  only  in  imputed  data.
 DescripStats.OriginalData Descriptive  statistics  for  model  variables  found  in  pre-imputation  dataset.
 totry Character  string  of  variables  that  were  most  significant  in  the  unrestricted  model  as  well  as  additional  variables  that  proved  significant  using  the  add1  function  on  the  restricted  model.
 didwell Character  string  of  variables  that  were  most  significant  in  the  unrestricted  model.
 usedthese Table  showing  how  observations  used  differ  from  observations  not  used,  regarding  ecology,  continent,  and  subsistence.
 dfbetas Influential  observations  for  dfbetas  (see  details)
 data Data  as  used  in  the  estimations.  Observations  with  missing  values  of  the  dependent  variable  have  been  dropped.  If  mean.data=TRUE,  will  output  format  that  can  be  used  to  make  maps.
 The  last  two  items  in  the  list  can  be  fairly  large,  but  the  first  twelve  provide  a  nice  overview.
 
 h[1:12]
 ##  $DependVarb
 ##  [1]  "Dependent  variable='v238':  High  Gods"
 ##  
 ##  $URmodel
 ##                                  coef    stdcoef      VIF        pval    hcpval  bootpval  star
 ##  inhmove          -0.53300  -0.16768  1.440  0.01552  0.02043    0.03060      **
 ##  inhreal            0.11723    0.04810  2.518  0.58957  0.49309    0.57638          
 ##  (Intercept)    1.09938            NaN      NaN  0.21745  0.15681    0.21360          
 ##  marrgood          0.21711    0.08945  1.229  0.14945  0.12571    0.17602          
 ##  PCAP                -0.12288  -0.13258  1.350  0.03917  0.03025    0.08086        *
 ##  PCsize              0.24022    0.25329  4.434  0.02925  0.00437    0.01540      **
 ##  PCsizeSq        -0.11186  -0.19461  1.768  0.00750  0.02318    0.04724      **
 ##  PCviol              0.04378    0.04955  1.357  0.43812  0.45855    0.51241          
 ##  v155                  0.05882    0.07416  2.084  0.34695  0.20932    0.30112          
 ##  v1649              -0.00858  -0.04750  1.854  0.54473  0.48965    0.54273          
 ##  v1650              -0.02568  -0.14277  1.554  0.04345  0.02769    0.03992      **
 ##  v1685                0.06910    0.07218  1.227  0.24226  0.19717    0.26245          
 ##  v1726                0.01952    0.01315  1.721  0.85818  0.83916    0.86219          
 ##  v206                  0.06544    0.11346  2.415  0.18414  0.12301    0.21642          
 ##  v232                -0.01867  -0.02746  2.824  0.76592  0.74360    0.78652          
 ##  v245.d2            0.48818    0.18990  3.033  0.05121  0.03408    0.06149        *
 ##  v270                  0.03382    0.04347  2.059  0.58942  0.54137    0.59847          
 ##  v272                  0.06959    0.04254  1.379  0.50763  0.36777    0.46324          
 ##  v64                  -0.03742  -0.06295  2.993  0.50482  0.40711    0.50239          
 ##  v666                -0.30037  -0.11780  1.434  0.08808  0.07700    0.12409          
 ##  v72                  -0.01386  -0.01393  1.260  0.82125  0.80808    0.82565          
 ##  v767                  0.02252    0.01471  1.474  0.82709  0.79091    0.82186          
 ##  v768                -0.17812  -0.16226  1.919  0.03327  0.01825    0.02919      **
 ##  v770                  0.04421    0.02840  1.596  0.70226  0.71510    0.73991          
 ##  v773                  0.15961    0.16629  2.021  0.03653  0.03125    0.04633      **
 ##  v891                -0.14332  -0.08307  1.272  0.19983  0.18811    0.24209          
 ##  Wy                      0.91016    0.39197  2.310  0.00000  0.00000    0.00001    ***
 ##                                                                                                                                                                                                                                                    desc
 ##  inhmove                                                                                                                                                                    Dummy:  movable  property  is  inherited
 ##  inhreal                                                                                                                                                                          Dummy:  real  property  is  inherited
 ##  (Intercept)                                                                                                                                                                                                                            
 ##  marrgood                                                                                                                                                      Dummy:  marriage  includes  transfer  of  goods
 ##  PCAP                                                                                                                                                                            1st  PC:  Agricultural  potential  high
 ##  PCsize                                                                                                                                                                                      1st  PC:  Community  size  large
 ##  PCsizeSq                                                                                                                                                                  1st  PC:  Community  size  large  Squared
 ##  PCviol                                                                                                                                                                                1st  PC:  High  levels  of  violence
 ##  v155                                                                                                                                                                                                                      Scale  7-  Money
 ##  v1649                                                                                                                                                  Frequency  of  Internal  Warfare  (Resolved  Rating)
 ##  v1650                                                                                                                                                  Frequency  of  External  Warfare  (Resolved  Rating)
 ##  v1685                                                                                                                                                        Chronic  Resource  Problems  (Resolved  Ratings)
 ##  v1726                                                                                                                                                                                                          Communality  of  Land
 ##  v206                                                                                                                                                                  Dependence  on  Animal  Husbandry  (Atlas  4)
 ##  v232                                                                                                                                                                                                  Intensity  of  Cultivation
 ##  v245.d2                                                                                                        Milking  of  Domestic  Animals  ==  Milked  more  often  than  sporadically
 ##  v270                                                                                                                                                                                                          Class  Stratification
 ##  v272                                                                                                                                                                                    Caste  Stratification  (Endogamy)
 ##  v64                                                                                                                                                  Population  Density  (from  Murdock  and  Wilson  Data)
 ##  v666                                                                                                                                                            Moderate  or  Frequent  Interpersonal  Violence
 ##  v72                                                                                                                                                                                                      Intercommunity  Marriage
 ##  v767                                                                                                                              (No)  Conflict  (Social  or  Political)  in  the  Local  Community
 ##  v768                                                                                                                                        (No)  Conflict  between  Communities  of  the  Same  Society
 ##  v770                (No)  Resort  to  Physical  Force  by  Disputants  in  Settling  Disputes,  Exclusive  of  Police  or  Institutionalized  Force,
 ##  v773                                                                                                                            (No)  Internal  Warfare  (between  Communities  of  Same  Society)
 ##  v891                                                                                Frequency  of  Internal  War  Otterbein  (1970:  3,  84,  143)  Definition  of  Internal  War
 ##  Wy                                                                                                                                                                                                                      Network  lag  term
 ##  
 ##  $model.varbs
 ##              [,1]                                                                                                                                                                                                                                                                                                            
 ##    [1,]  "======  [  v238  ]    High  Gods  ========"                                                                                                                                                                                                                                          
 ##    [2,]  "[1]:  Absent  or  not  reported  |+|  [4]:  Present,  active,  and  specifically  supportive  of  human  morality"                                                                                                          
 ##    [3,]  "======  [  v1685  ]    Chronic  Resource  Problems  (Resolved  Ratings)  ========"                                                                                                                                                                  
 ##    [4,]  "[1]:  Low  or  rare  (original  code  1)  |+|  [5]:  Most  members  of  the  population  usually  do  not  have  enough  to  eat  -  i.e.,  th"                                                                  
 ##    [5,]  "======  [  v232  ]    Intensity  of  Cultivation  ========"                                                                                                                                                                                                            
 ##    [6,]  "[1]:  No  agriculture  |+|  [6]:  Intensive  irrigated  agriculture"                                                                                                                                                                                        
 ##    [7,]  "======  [  v206  ]    Dependence  on  Animal  Husbandry  (Atlas  4)  ========"                                                                                                                                                                            
 ##    [8,]  "[0]:  0  -  5  pct  |+|  [9]:  86  -  100  pct"                                                                                                                                                                                                                                        
 ##    [9,]  "======  [  v245.d2  ]    Milking  of  Domestic  Animals  ==  Milked  more  often  than  sporadically  ========"                                                                                                                  
 ##  [10,]  "[0]:  otherwise  |+|  [1]:  Milked  more  often  than  sporadically"                                                                                                                                                                                          
 ##  [11,]  "======  [  v270  ]    Class  Stratification  ========"                                                                                                                                                                                                                    
 ##  [12,]  "[1]:  Absence  among  freemen  |+|  [5]:  Complex  (social  classes)"                                                                                                                                                                                        
 ##  [13,]  "======  [  v272  ]    Caste  Stratification  (Endogamy)  ========"                                                                                                                                                                                              
 ##  [14,]  "[1]:  Absent  or  insignificant  |+|  [4]:  Complex"                                                                                                                                                                                                                      
 ##  [15,]  "======  [  v155  ]    Scale  7-  Money  ========"                                                                                                                                                                                                                                
 ##  [16,]  "[1]:  None  |+|  [5]:  True  money"                                                                                                                                                                                                                                                      
 ##  [17,]  "======  [  v72  ]    Intercommunity  Marriage  ========"                                                                                                                                                                                                                
 ##  [18,]  "[1]:  Local  endogamy  90-100  pct  |+|  [5]:  Local  endogamy  0-10  pct  (exogamy)"                                                                                                                                                              
 ##  [19,]  "======  [  v1726  ]    Communality  of  Land  ========"                                                                                                                                                                                                                    
 ##  [20,]  "[1]:  land  predominantly  private  property  |+|  [3]:  communal  land  use  rights  only"                                                                                                                                                  
 ##  [21,]  "======  [  inhreal  ]    Dummy:  real  property  is  inherited  ========"                                                                                                                                                                                    
 ##  [22,]  "range:  0  to  1"                                                                                                                                                                                                                                                                                      
 ##  [23,]  "======  [  inhmove  ]    Dummy:  movable  property  is  inherited  ========"                                                                                                                                                                              
 ##  [24,]  "range:  0  to  1"                                                                                                                                                                                                                                                                                      
 ##  [25,]  "======  [  marrgood  ]    Dummy:  marriage  includes  transfer  of  goods  ========"                                                                                                                                                                
 ##  [26,]  "range:  0  to  1"                                                                                                                                                                                                                                                                                      
 ##  [27,]  "======  [  v64  ]    Population  Density  (from  Murdock  and  Wilson  Data)  ========"                                                                                                                                                            
 ##  [28,]  "[1]:  <  1  person  per  5  sq.  mile  |+|  [7]:  over  500  persons  per  sq.  mile"                                                                                                                                                                      
 ##  [29,]  "======  [  v666  ]    Moderate  or  Frequent  Interpersonal  Violence  ========"                                                                                                                                                                      
 ##  [30,]  "[1]:  Absent  |+|  [2]:  Present"                                                                                                                                                                                                                                                        
 ##  [31,]  "======  [  v767  ]    (No)  Conflict  (Social  or  Political)  in  the  Local  Community  ========"                                                                                                                                        
 ##  [32,]  "[1]:  Endemic:  a  reality  of  daily  existence  (e.g.,  physical  violence,  feuding,  bi  |+|  [4]:  Mild  or  rare"                                                                                                    
 ##  [33,]  "======  [  v768  ]    (No)  Conflict  between  Communities  of  the  Same  Society  ========"                                                                                                                                                  
 ##  [34,]  "[1]:  Endemic:  High  physical  violence,  feuding,  and/or  raiding  occur  regularly  |+|  [4]:  Mild  or  rare"                                                                                                          
 ##  [35,]  "======  [  v770  ]    (No)  Resort  to  Physical  Force  by  Disputants  in  Settling  Disputes,  Exclusive  of  Police  or  Institutionalized  Force,  ========"                          
 ##  [36,]  "[1]:  Often  used  |+|  [3]:  Rarely  or  never  used"                                                                                                                                                                                                                      
 ##  [37,]  "======  [  v773  ]    (No)  Internal  Warfare  (between  Communities  of  Same  Society)  ========"                                                                                                                                      
 ##  [38,]  "[1]:  Frequent,  occurring  at  least  yearly  |+|  [4]:  Rare  or  never"                                                                                                                                                                                  
 ##  [39,]  "======  [  v891  ]    Frequency  of  Internal  War  Otterbein  (1970:  3,  84,  143)  Definition  of  Internal  War  ========"                                                                                          
 ##  [40,]  "[1]:  Continual  |+|  [3]:  Infrequent"                                                                                                                                                                                                                                            
 ##  [41,]  "======  [  v1649  ]    Frequency  of  Internal  Warfare  (Resolved  Rating)  ========"                                                                                                                                                            
 ##  [42,]  "[1]:  Internal  warfare  seems  to  be  absent  or  rare  (original  code  1)  |+|  [17]:  Internal  warfare  seems  to  occur  almost  constantly  and  at  any  time  of  the  ye"
 ##  [43,]  "======  [  v1650  ]    Frequency  of  External  Warfare  (Resolved  Rating)  ========"                                                                                                                                                            
 ##  [44,]  "[1]:  External  warfare  seems  to  be  absent  or  rare  (original  code  1)  |+|  [17]:  External  warfare  seems  to  occur  almost  constantly  and  at  any  time  of  the  ye"
 ##  
 ##  $Rmodel
 ##                                  coef    stdcoef      VIF    relimp        pval    hcpval  bootpval  star                                                                                        desc
 ##  (Intercept)  -0.40644            NaN      NaN          NaN  0.24437  0.17758    0.26062                                                                                                  
 ##  PCAP                -0.12515  -0.13503  1.187  0.01204  0.02633  0.01380    0.02811      **                          1st  PC:  Agricultural  potential  high
 ##  PCsize              0.23579    0.24861  1.822  0.04133  0.00099  0.00042    0.00130    ***                                        1st  PC:  Community  size  large
 ##  PCsizeSq        -0.10886  -0.18940  1.429  0.01247  0.00451  0.01844    0.03235      **                        1st  PC:  Community  size  large  Squared
 ##  v1650              -0.03128  -0.17386  1.123  0.01594  0.00400  0.00176    0.00183    ***  Frequency  of  External  Warfare  (Resolved  Rating)
 ##  v1685                0.08341    0.08715  1.054  0.01193  0.13240  0.12566    0.14099                  Chronic  Resource  Problems  (Resolved  Ratings)
 ##  v206                  0.08305    0.14400  1.555  0.11800  0.03936  0.02882    0.04553      **                Dependence  on  Animal  Husbandry  (Atlas  4)
 ##  v272                  0.14236    0.08708  1.147  0.03503  0.14853  0.05939    0.09759        *                                  Caste  Stratification  (Endogamy)
 ##  Wy                      1.17105    0.50433  1.612  0.25047  0.00000  0.00000    0.00000    ***                                                                Network  lag  term
 ##  
 ##  $EndogeneityTests
 ##  [1]  "no  endogeneity  tests"
 ##  
 ##  $Diagnostics
 ##                                                                                                                    Fstat          df  pvalue  star
 ##  RESET  test.  H0:  model  has  correct  functional  form                4.654        999  0.0312      **
 ##  Wald  test.  H0:  appropriate  variables  dropped                          1.722      1978  0.1896          
 ##  Breusch-Pagan  test.  H0:  residuals  homoskedastic                    1.082  194160  0.2982          
 ##  Shapiro-Wilkes  test.  H0:  residuals  normal                                8.036    18771  0.0046    ***
 ##  Hausman  test.  H0:  Wy  is  exogenous                                                2.554        687  0.1104          
 ##  Sargan  test.  H0:  residuals  uncorrelated  with  instruments  2.176        262  0.1413          
 ##  
 ##  $OtherStats
 ##          d      l  e  Weak.Identification.Fstat  R2.final.model  R2.UR.model  nimp  nobs  BClambda
 ##  1  0.7  0.3  0                                          19.46                  0.5065            0.5824        5    168          none
 ##  
 ##  $DescripStats.ImputedData
 ##                                                                              desc  nobs  mean        sd        min      max
 ##  PCAP      1st  PC:  Agricultural  potential  high    930        0  1.285  -4.231  2.688
 ##  PCsize                1st  PC:  Community  size  large    930        0  1.210  -1.639  3.541
 ##  PCviol          1st  PC:  High  levels  of  violence    930        0  1.322  -2.037  2.806
 ##  
 ##  $DescripStats.OriginalData
 ##                                                                                                                                                                                                                                              desc  nobs    mean        sd  min  max
 ##  v238                                                                                                                                                                                                                          High  Gods    168  2.149  1.192      1      4
 ##  v1685                                                                                                                                                  Chronic  Resource  Problems  (Resolved  Ratings)    144  2.139  1.277      1      5
 ##  v232                                                                                                                                                                                            Intensity  of  Cultivation    186  3.403  1.732      1      6
 ##  v206                                                                                                                                                            Dependence  on  Animal  Husbandry  (Atlas  4)    186  1.575  2.123      0      9
 ##  v245.d2                                                                                                  Milking  of  Domestic  Animals  ==  Milked  more  often  than  sporadically    186  0.306  0.462      0      1
 ##  v270                                                                                                                                                                                                    Class  Stratification    186  2.409  1.508      1      5
 ##  v272                                                                                                                                                                              Caste  Stratification  (Endogamy)    181  1.249  0.674      1      4
 ##  v155                                                                                                                                                                                                                Scale  7-  Money    186  2.511  1.479      1      5
 ##  v72                                                                                                                                                                                                Intercommunity  Marriage    185  3.195  1.200      1      5
 ##  v1726                                                                                                                                                                                                    Communality  of  Land      98  2.306  0.817      1      3
 ##  inhreal                                                                                                                                                                    Dummy:  real  property  is  inherited    155  0.619  0.487      0      1
 ##  inhmove                                                                                                                                                              Dummy:  movable  property  is  inherited    152  0.862  0.346      0      1
 ##  marrgood                                                                                                                                                Dummy:  marriage  includes  transfer  of  goods    186  0.597  0.492      0      1
 ##  v64                                                                                                                                            Population  Density  (from  Murdock  and  Wilson  Data)    184  3.761  1.977      1      7
 ##  v666                                                                                                                                                      Moderate  or  Frequent  Interpersonal  Violence    131  1.672  0.471      1      2
 ##  v767                                                                                                                        (No)  Conflict  (Social  or  Political)  in  the  Local  Community      90  2.911  0.788      1      4
 ##  v768                                                                                                                                  (No)  Conflict  between  Communities  of  the  Same  Society      89  2.404  1.125      1      4
 ##  v770          (No)  Resort  to  Physical  Force  by  Disputants  in  Settling  Disputes,  Exclusive  of  Police  or  Institutionalized  Force,      90  1.889  0.800      1      3
 ##  v773                                                                                                                      (No)  Internal  Warfare  (between  Communities  of  Same  Society)      85  2.459  1.305      1      4
 ##  v891                                                                          Frequency  of  Internal  War  Otterbein  (1970:  3,  84,  143)  Definition  of  Internal  War    160  2.450  0.680      1      3
 ##  v1649                                                                                                                                            Frequency  of  Internal  Warfare  (Resolved  Rating)    152  7.250  6.483      1    17
 ##  v1650                                                                                                                                            Frequency  of  External  Warfare  (Resolved  Rating)    154  8.097  6.663      1    17
 ##  
 ##  $totry
 ##  [1]  "PCsize:PCsizeSq"  "PCsizeSq:Wy"          "v238Sq"                    "inhmove"                  "v245.d2"                  "v768"                        "v773"                      
 ##  
 ##  $didwell
 ##  [1]  "PCAP"          "PCsize"      "PCsizeSq"  "v1650"        "v206"          "v272"        
 ##  
 ##  $usedthese
 ##                                                                                                                              NOTused  used        table
 ##  Asiatic  Russia                                                                                                            1        2      region
 ##  Australia/New  Zealand                                                                                              0        3      region
 ##  Caribbean                                                                                                                      0        2      region
 ##  Central  America                                                                                                          1        6      region
 ##  Central  Asia                                                                                                                0        1      region
 ##  Eastern  Africa                                                                                                            2      14      region
 ##  Eastern  Asia                                                                                                                2        6      region
 ##  European  Russia                                                                                                          0        2      region
 ##  Melanesia                                                                                                                      1        8      region
 ##  Micronesia                                                                                                                    1        4      region
 ##  Middle  Africa                                                                                                              0        7      region
 ##  Northern  Africa                                                                                                          1        7      region
 ##  Northern  America                                                                                                        1      29      region
 ##  Northern  Europe                                                                                                          0        2      region
 ##  Polynesia                                                                                                                      0        3      region
 ##  South  America                                                                                                              3      23      region
 ##  Southeastern  Asia                                                                                                      4      14      region
 ##  Southern  Africa                                                                                                          0        2      region
 ##  Southern  Asia                                                                                                              1      12      region
 ##  Southern  Europe                                                                                                          0        3      region
 ##  Western  Africa                                                                                                            0      11      region
 ##  Western  Asia                                                                                                                0        7      region
 ##  Boreal  forest/taigas                                                                                                1        7  mht.name
 ##  Deserts  and  xeric  shrublands                                                                                1      14  mht.name
 ##  Flooded  grasslands                                                                                                    0        1  mht.name
 ##  Mediterranean  scrub                                                                                                  0        3  mht.name
 ##  Montane  grasslands                                                                                                    0        4  mht.name
 ##  Snow,  ice,  glaciers,  and  rock                                                                              0        2  mht.name
 ##  Temperate  broadleaf  and  mixed  forests                                                              1      12  mht.name
 ##  Temperate  coniferous  forests                                                                                0      15  mht.name
 ##  Temperate  grasslands,  savannas,  and  shrublands                                            1        7  mht.name
 ##  Tropical  and  subtropical  coniferous  forests                                                  0        2  mht.name
 ##  Tropical  and  subtropical  dry  broadleaf  forests                                            2        9  mht.name
 ##  Tropical  and  subtropical  grasslands,  savannas,  and  shrublands              2      30  mht.name
 ##  Tropical  and  subtropical  moist  broadleaf  forests                                      10      56  mht.name
 ##  Tundra                                                                                                                            0        4  mht.name
 ##  Water                                                                                                                              0        2  mht.name
 ##  Fishing                                                                                                                          1      18          v246
 ##  Gathering                                                                                                                      1      14          v246
 ##  Hunting,  or  Marine  animals,  or  Mounted  Hunting                                            2      10          v246
 ##  Intensive  agriculture                                                                                              4      53          v246
 ##  Pastoral                                                                                                                        2      14          v246
 ##  Shifting  Cultivation  or  Horticulture  or  Tree  fruits                                  8      52          v246
 ##  Two  or  more  sources  contribute  equally                                                            0        7          v246
 The  14th  item  in  list  h  is  a  dataframe  containing  mean  values  of  variables  across  imputations.  This  can  be  used  to  make  maps,  employing  the  functions  mkmapppng()  (for  ordinal  data)  or  mkcatmapppng()  (for  categorical  data).
 
 mkmappng(h$data,  "v238",  "v238MoralGods",  show  =  "ydata",  numnb.lg  =  3,  numnb.lm  =  20,  numch  =  5,  pvlm  =  0.05,  dfbeta.show  =  TRUE)
 ##  Loading  required  package:  mapproj
 ##  pdf  
 ##      2
 Click  here  to  see  the  map  png
 
 There  are  squared  terms  in  the  estimated  model,  which  makes  the  coefficients  a  bit  difficult  to  comprehend.  The  function  plotSq()  will  make  a  plot  for  each  of  the  variables  with  squared  terms:  the  abscissa  gives  the  values  of  the  variable  found  in  the  averaged  data,  while  the  ordinate  gives  the  marginal  effect  on  the  dependent  variable.  The  number  of  observations  at  each  value  is  shown  both  by  the  rugplots  in  green  at  the  top  of  the  plot,  and  by  the  size  of  the  red  circles  at  each  variable  value.
 
 plotSq(h)
 plot  of  chunk  unnamed-chunk-1
 
 One  can  also  write  the  list  h  to  a  csv  format  file  that  can  be  opened  as  a  spreadsheet.  The  following  command  writes  h  to  a  file  in  the  working  directory  called  “olsresults.csv”.
 
 CSVwrite(h,  "olsresults",  FALSE)
 Click  here  to  see  the  spreadsheet  csv