Doug's substitution of v877 for v79
From InterSciWiki
To install the package spdep - see spdep manual. Go to the menu bar and click 'Packages'; on the drop down menu click 'Install package(s)...'. After being prompted for a mirror, you will be presented with a (very long) list of the available packages; scroll down until you find spdep, and click it. Some packages (such as foreign) are part of core R; spdep is not in core R, so you have to install it yourself. 'Load package' only calls in the packages you have already installed.
The model evaluated regression coefficients predicting female contribution to subsistence
- femsubs~fishimp+huntimp+pathstress+rainfall+polygamy+eboysxp+fixres+landtrans+polinteg+socstrat
- variables having .15 > p > .10: polygamy fixres landtrans
- variables having .10 > p > .05: polinteg (+)
- variables having .05 > p > .01: socstrat (-)
- variables having .01 > p >.001: rainfall eboysxp (+) fishimp (-)
- variables having .001>p: hunting path(ogen)stress (-)
Residual autocorrelation is nonsignificant
#Spatial Lag Model, one weight matrix, MLE #datafile 1: http://intersci.ss.uci.edu/wiki/Eff/SCCS_stata.dta #distancematrix: http://intersci.ss.uci.edu/wiki/Eff/distmat.dbf #languagemetrix: http://intersci.ss.uci.edu/wiki/Eff/langmat.dbf #This program: http://intersci.ss.uci.edu/wiki/Eff/A_EFF_SAR_R #Change the following to your own working directory (note UNIX slant of slashes--even on Windows machine) setwd("d:/projects/dow/") #XP setwd("/Users/doug/Desktop") #MacBook #source("http://intersci.ss.uci.edu/wiki/pub/R-KinSim.R") #net=source("C:/Program Files/pajek/PAJEK/PajekR.r") #setwd("C:/Program Files/pajek/PAJEK/") ###setwd("C:/Program Files/pajek/PAJEK/Anthon_Eff-Autocorrelation") options(echo=TRUE) library(foreign) library(spdep) #Read in the dbf format weight matrices-the dbf file is 186x186 (no row names) #Comment the matrix you do NOT want to use lds<-read.dbf("langmat.dbf") #language phylogeny #lds<-read.dbf("distmat.dbf") #great circle distance #convert to matrix lds<-as.matrix(lds) #take a quick look at the upper left hand corner to see that it is OK lds[1:5,1:5] #read in SCCS data. It is in STATA format, since this is numeric--there are problems with the SPSS version, #since R imports the value labels from SPSS and the variables become non-numeric gg<-read.dta("SCCS_stata.dta") length(gg[,1]) #the number of observations length(gg[1,]) #the number of variables #create a data frame containing our variables, also give the variables names df<-data.frame(femsubs=gg$v826,fishimp=gg$v816,huntimp=gg$v817,pathstress=gg$v1260,rainfall=gg$v855,polygamy=gg$v877,eboysxp=gg$v353,fixres=gg$v150,landtrans=gg$v154,polinteg=gg$v157,socstrat=gg$v158) #since the estimation doesn't work with missing values, here we identify all observations with non-missing values kk<-as.matrix(df) oo<-matrix(1,length(kk[1,]),1) tm<-kk%*%oo rr<-which(tm[,1]!="NA") #here we restrict the weight matrix and data to include only non-missing values wmat<-mat2listw(lds[rr,rr]) ffd<-df[rr,] length(df[,1]) #number of observations before dropping those with missing values length(ffd[,1]) #number of observations after dropping those with missing values summary(ffd) #We estimate a spatial lag model library(spdep) #I ADDED THIS AFTER INSTALLING SPDEP-DW col.lm<-lagsarlm(femsubs~fishimp+huntimp+pathstress+rainfall+polygamy+eboysxp+fixres+landtrans+polinteg+socstrat, data=ffd,wmat,quiet=FALSE) #this next displays parameter estimates and diagnostics for the spatial lag model summary(col.lm) pseudoR2<-cor(col.lm$fitted.values,ffd$femsubs)^2 #could not find function lagsarlm--> install packages -->spdep library(spdep) #help{"lagsarlm") PseudoR2 for SAR
ResultsEff0001 -- Doug's modification The R^2 for this model, with v877 (polygyny with co-wife autonomy) replacing v79 as a measure of polyginy, adds 2% to the variance accounted for. How does a "better" polygyny measure affect the significance of the other variables? Next v878 might be added to check whether the more sororal type of polygyny has any effect, I suspect not -- check the SCCS codebook - DRW.
