DEf01b SCCS
## DEf01c replaced DEf01b here without a problem: AND NEW h< functions and csv functions added for DEf01c
Currently you can map and apply convex hulls to any variable in the unrestricted model (dpV,Wy,UiV). But you can only plot the dfbetas for RiV. I could put all of the evm variables in, if you want, but thought that might be a little big. Let me know...
aa<-h$data is not the imputed data but is an alphabetized version of the imputed data imputed data are in DEf01b #8/28/13 DEf01c #9/16/13 8:32 PM
Contents
html
List of Rgui to CoSSci Models http://capone.mtsu.edu/eaeff/DEf01b_SCCS.html #replaced by [http://capone.mtsu.edu/eaeff/DEf01c_SCCS.html see: ToDo ##v67.d3" DpV= "The variable description is: 'Household Form == Single family dwellings'"
Most recent DEf01b SCCS with scales, logit, maps
Objects contained in R workspace DEf01b.Rdata] - 15pp htm <--p5.fv4scale p7.mkscale p11.doLogit p13.mkmapping
DEf01b and DEf01c SCCS
Latest version Sept 10 2013 of the Dow-Eff functions (Manual: pdf; html) which can perform analyses on four different ethnological datasets
abbreviation dataset codebook WNAI Western North American Indians codebook SCCS Standard Cross-Cultural Sample codebook EA Ethnographic Atlas codebook LRB Louis R. Binford's forager 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:
DEf01b and DEf01c script can start here thru - bb - below- then through code for output
Note that h[[12 is an alphabetized imputed dataset but dew added bb is the imputed dataset in original order so as to make the two types of color maps in 1):
- 1) Thomas Uram, Doug White, and Tolga Oztan's http://intersci.ss.uci.edu/wiki/index.php/Draw.Rworldmap in color (not good for publication because of cost)
- 2) Anthon Eff's Black and White maps with local autocorrelation
#install.packages("mice") # --set working directory and load needed libraries-- #setwd("/home/yagmur/Dropbox/functions") ## Error: cannot change working directory
#run from here to h[[12 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) ###not library(maps) ) - corrected library(plyr) library(aod) library(reshape) library(mapproj) #trying URL 'http://cran.rstudio.com/bin/macosx/leopard/contrib/2.15/mapproj_1.2-1.tgz' #library(map) used by Eff
The Dow-Eff functions, as well as the four ethnological datasets, are contained in an R-workspace, located in the cloud.
#load(url("http://dl.dropbox.com/u/9256203/DEf01b.Rdata"), .GlobalEnv) load(url("http://dl.dropbox.com/u/9256203/DEf01c.Rdata"), .GlobalEnv) #ls() #-can see the objects contained in DEf01b.Rdata ## [1] "addesc" "chK" "chkpmc" "CSVwrite" "doLogit" ## [6] "doMI" "doOLS" "EA" "EAcov" "EAfact" ## [11] "EAkey" "fv4scale" "gSimpStat" "kln" "llm" ## [16] "LRB" "LRBcov" "LRBfact" "LRBkey" "mkdummy" ## [21] "mkmappng" "mkscale" "mmgg" "resc" "rnkd" ## [26] "SCCS" "SCCScov" "SCCSfact" "SCCSkey" "setDS" ## [31] "spmang" "widen" "WNAI" "WNAIcov" "WNAIfact" ## [36] "WNAIkey" ls() #-can see the objects contained in DEf01c.Rdata ## [1] "aa" "addesc" "AWC" "bb" "capwrd" "chK" "chkpmc" "cov" ## [9] "CSVwrite" "doLogit" "doMI" "doOLS" "dpV" "dx" "dxf" "EA" ## [17] "EAawc" "EAcov" "EAfact" "EAkey" "evm" "fec" "femecon" "fv4scale" ## [25] "gSimpStat" "h" "i" "ind" "k" "key" "kln" "llm" ## [33] "LRB" "LRBcov" "LRBfact" "LRBkey" "mkcatmappng" "mkdummy" "mkmappng" "mknwlag" ## [41] "mkscale" "mmgg" "oo" "oxog" "plotSq" "q" "quickdesc" "resc" ## [49] "RiV" "rnkd" "SCCS" "SCCScov" "SCCSfact" "SCCSkey" "setDS" "showlevs" ## [57] "smi" "spmang" "UiV" "wdd" "wddbkup" "wee" "widen" "wll" ## [65] "wllbkup" "WNAI" "WNAIcov" "WNAIfact" "WNAIkey" "z" "z1"
The setDS( xx ) command sets one of the four ethnological datasets as the source for the subsequent analysis. The four valid options for xx are: “WNAI”, “LRB”, “EA”, “SCCS”. 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$rectang <- (dx$v65 >= 8 & dx$v65 <= 9) * 1 addesc("rectang", "Dwelling is rectangular")
Dummy variables (variables taking on the values zero or one) should be added using the command mkdummy(). This command will, in most cases, 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("v279", 1) ## [1] "This dummy variable is named v279.d1" ## [1] "The variable description is: 'Inheritance of Movable Property: Rule or Practice for Inheritance == Absence of individual property rights or rules'" mkdummy("v213", 3) ## [1] "This dummy variable is named v213.d3" ## [1] "The variable description is: 'Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents'" mkdummy("v279", 5) ## [1] "This dummy variable is named v279.d5" ## [1] "The variable description is: 'Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes'" mkdummy("v1127", 2) ## [1] "This dummy variable is named v1127.d2" ## [1] "The variable description is: 'Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye,'" mkdummy("v2002", 2) ## [1] "This dummy variable is named v2002.d2" ## [1] "The variable description is: 'World Religions (1807) == Deep Islamization'" mkdummy("v67", 3) ## [1] "This dummy variable is named v67.d3" ## [1] "The variable description is: 'Household Form == Single family dwellings'"
One can make a scale (also known as a “composite index”) by combining information from various variables. The function fv4scale can be of use in identifying variables with similar meanings, which can potentially be combined into a scale. The implementation below scans the codebook, looking for the keywords mentioned under lookword=, keeping only those that also mention keepword=, and then retaining only those that correlate highly with variables containing terms in coreword=. The resulting variable names are output to femecon.
femecon <- fv4scale(lookword = c("market", "exchange", "wage", "trade", "subsistence", "goods", "product", "labor"), keepword = c("female", "women", "woman"), coreword = c("subsistence"), nmin = 60, chklevels = TRUE, verbose = FALSE) ##RETURNS## c("v889", "v890", "v887", "v826", "v886", "v885", "v585", "v888", "v593", "v658", "v660", "v594")
After making any new variables, list the variables you intend to use in your analysis in the following form.
evm <- c("v67.d3", "v2002.d2", "v1845", "v1649", "v1127.d2", "v2137", "v279.d5", "v213.d3", "v1265", "v1", "v234", "rectang", femecon, "v1260")
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 (these values are too low: nimp=10 and maxit=7 are the defaults and are reasonable for most purposes). 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)
oo<-h12 k<-match(rownames(oo),SCCS$society) oo$numid<-SCCS[k,"sccsid"] oo<-oo[order(oo$numid),]
bb<-aggregate(smi[,sapply(smi,function(x) is.numeric(x))],list(smi$.id),mean) #IMPUTED AVERAGES Used in [[1]] #bb$v1 ##NOTE TO Thomas Uram: If you clean up my Draw.Rworldmap script it could be used to improve your Rworldmap maps -- my idea is to have output for maps automatically include the colored maps for the depvar and all the RiV independent variables, AND ALSO include Anthon Eff's black and white map for only the depvar because it is perfect for publication purposes. The two scripts are:
- 1) Thomas Uram, Doug White, and Tolga Oztan's [[2]] in color (not good for publication because of cost)
- 2) Anthon Eff's Black and White maps with local autocorrelation
## [1] "v1845" ## [1] "v1649" ## [1] "v1127.d2" ## [1] "v2137" ## [1] "v279.d5" ## [1] "v213.d3" ## [1] "v1265" ## [1] "v1" ## [1] "v889" ## [1] "v890" ## [1] "v887" ## [1] "v826" ## [1] "v886" ## [1] "v885" ## [1] "v585" ## [1] "v888" ## [1] "v593" ## [1] "v658" ## [1] "v660" ## [1] "v594" ## Time difference of 18.15 secs dim(smi) # dimensions of new dataframe smi ## [1] 930 104 smi[1:2, ] # first two rows of new multiiple imputation dataframe smi ## .imp .id v1845 v1649 v1127.d2 v2137 v279.d5 v213.d3 v1265 v1 v889 v890 ## 1 1 Nama 2 17 0 0 0 1 4 4 35 4 ## 2 1 Kung 3 1 0 0 0 1 2 2 40 4 ## v887 v826 v886 v885 v585 v888 v593 v658 v660 v594 v67.d3 v2002.d2 v234 ## 1 26 26 43 35 5 7 3 2 2 4 1 0 1 ## 2 19 19 50 60 5 41 1 2 2 4 1 0 1 ## rectang v1260 mht.name.d12 mht.name.d13 Emht.name.d12 koeppengei.d1 ## 1 0 8 0 0 0 0 ## 2 0 10 0 0 0 0 ## koeppengei.d4 continent.d1 continent.d2 continent.d5 continent.d7 ## 1 0 1 0 0 0 ## 2 0 1 0 0 0 ## Dcontinent.d5 region.d13 region.d16 bio.1 bio.2 bio.3 bio.4 ## 1 0 0 0 0.1332 1.955 0.07924 0.04614 ## 2 0 0 0 0.3268 1.570 -0.01787 -0.02053 ## bio.5 bio.6 bio.8 bio.9 bio.10 bio.11 bio.12 bio.13 bio.14 ## 1 0.4791 -0.21950 0.4183 -0.24498 0.1780 0.05293 -1.1220 -1.1109 -0.7111 ## 2 0.5716 -0.09703 0.5845 -0.08423 0.3051 0.19304 -0.9511 -0.7084 -0.7111 ## bio.15 bio.16 bio.17 bio.18 bio.19 meanalt mnnpp sdalt x ## 1 1.39 -1.078 -0.7497 -0.7118 -0.9043 1.0240 -1.0200 -0.4929 0.02853 ## 2 1.45 -0.805 -0.7546 -0.7380 -0.9074 0.6772 -0.6861 -0.7336 0.06620 ## y x2 y2 xy Austronesian Nigercongo v1845Sq v1649Sq ## 1 -1.513 0.0008138 2.290 -0.04317 0 0 4 289 ## 2 -1.373 0.0043821 1.885 -0.09090 0 0 9 1 ## v1265Sq v1Sq v889Sq v890Sq v887Sq v826Sq v886Sq v885Sq v585Sq v888Sq ## 1 16 16 1225 16 676 676 1849 1225 25 49 ## 2 4 4 1600 16 361 361 2500 3600 25 1681 ## v593Sq v594Sq v234Sq v1260Sq bio.1Sq bio.2Sq bio.3Sq bio.4Sq bio.5Sq ## 1 9 16 1 64 0.01775 3.821 0.0062787 0.0021291 0.2295 ## 2 1 16 1 100 0.10681 2.464 0.0003193 0.0004214 0.3267 ## bio.6Sq bio.8Sq bio.9Sq bio.10Sq bio.11Sq bio.12Sq bio.13Sq bio.14Sq ## 1 0.048181 0.1750 0.060014 0.03168 0.002802 1.2588 1.2341 0.5057 ## 2 0.009415 0.3417 0.007095 0.09308 0.037263 0.9045 0.5019 0.5057 ## bio.15Sq bio.16Sq bio.17Sq bio.18Sq bio.19Sq meanaltSq mnnppSq sdaltSq ## 1 1.933 1.162 0.5621 0.5066 0.8178 1.0485 1.0405 0.2429 ## 2 2.103 0.648 0.5695 0.5446 0.8234 0.4587 0.4707 0.5382
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 the variables contained in femecon are combined into a scale based on linear programming.
fec <- mkscale(compvarbs = "femecon", udnavn = paste("femecon", ".lp", sep = ""), impdata = smi, type = "LP", add.descrip = "female economic contribution (LP scale)") ## [1] "femecon.lp" names(fec) ## [1] "scales" "stats" "corrs" head(fec$scales) ## femecon.lp femecon.lpSq ## 1 6 36 ## 2 8 64 ## 3 7 49 ## 4 3 9 ## 5 6 36 ## 6 7 49 fec$stats ## std.alpha ## 1 0.7409 fec$corrs ## varb cor.w.scale inv ## 3 v594 0.034 1 ## 5 v660 0.088 1 ## 4 v658 0.136 1 ## 2 v593 0.336 1 ## 10 v888 0.396 1 ## 1 v585 0.406 1 ## 8 v886 0.440 1 ## 7 v885 0.460 1 ## 6 v826 0.478 1 ## 9 v887 0.486 -1 ## 12 v890 0.516 1 ## 11 v889 0.552 1 ## description ## 3 Control of Disposal and Use of Fruits of the Labor Done Solely by Women ## 5 Female Economic Control of Products of Own Labor ## 4 Females Produce Goods for Nondomestic Distribution ## 2 Control of Disposal and Use of Fruits of the Labor Done by Men and Women ## 10 Female Contribution to Subsistence: Maximal Difference of Three Scores ## 1 Proportional Contribution of Women to Overall Subsistence ## 8 Female Contribution to Subsistence: Martin Whyte ## 7 Female Contribution to Subsistence: Ethnographic Atlas ## 6 Average Female Contribution to Subsistence ## 9 Female Contribution to Subsistence: Barry and Schlegel ## 12 Female Contribution to Subsistence: Average of Three Scores (Ordinated) ## 11 Female Contribution to Subsistence: Average of Three Scores ## levels ## 3 1 Men have virtually total say or predominant say |+| 2 Men and women have equal say |+| 3 Women have the predominant say, or no indication of preference |+| 4 Women have virtually total say ## 5 1 Absent |+| 2 Present ## 4 1 Absent |+| 2 Present ## 2 1 Men have virtually total say |+| 2 Men have the predominant say |+| 3 Men and women have equal say, or no indication of preference |+| 4 Women have the predominant or total say ## 10 0 0 |+| 1 1 |+| 2 2 |+| 3 3 |+| 4 4 |+| 5 5 |+| 6 6 |+| 7 7 |+| 8 8 |+| 9 9 |+| 10 10 |+| 11 11 |+| 12 12 |+| 13 13 |+| 14 14 |+| 15 15 |+| 16 16 |+| 17 17 |+| 18 18 |+| 19 19 |+| 20 20 |+| 21 21 |+| 22 22 |+| 23 23 |+| 25 25 |+| 26 26 |+| 27 27 |+| 28 28 |+| 29 29 |+| 32 32 |+| 33 33 |+| 35 35 |+| 38 38 |+| 39 39 |+| 41 41 |+| 45 45 |+| 46 46 |+| 49 49 |+| 52 52 ## 1 1 Low |+| 2 2 |+| 3 3 |+| 4 4 |+| 5 5 |+| 6 6 |+| 7 7 |+| 8 High ## 8 0 0 |+| 7 7 |+| 17 17 |+| 20 20 |+| 21 21 |+| 22 22 |+| 25 25 |+| 28 28 |+| 31 31 |+| 32 32 |+| 33 33 |+| 34 34 |+| 35 35 |+| 36 36 |+| 38 38 |+| 39 39 |+| 40 40 |+| 41 41 |+| 42 42 |+| 43 43 |+| 44 44 |+| 46 46 |+| 47 47 |+| 48 48 |+| 50 50 |+| 56 56 |+| 57 57 |+| 58 58 |+| 60 60 |+| 67 67 |+| 70 70 |+| 75 75 |+| 90 90 ## 7 0 0 |+| 5 5 |+| 8 8 |+| 10 10 |+| 13 13 |+| 15 15 |+| 18 18 |+| 20 20 |+| 22 22 |+| 23 23 |+| 25 25 |+| 28 28 |+| 30 30 |+| 33 33 |+| 35 35 |+| 38 38 |+| 39 39 |+| 40 40 |+| 43 43 |+| 45 45 |+| 48 48 |+| 50 50 |+| 53 53 |+| 55 55 |+| 58 58 |+| 60 60 |+| 63 63 |+| 68 68 |+| 70 70 |+| 73 73 |+| 75 75 ## 6 0 0 |+| 2 2 |+| 3 3 |+| 4 4 |+| 7 7 |+| 8 8 |+| 9 9 |+| 10 10 |+| 11 11 |+| 13 13 |+| 14 14 |+| 16 16 |+| 17 17 |+| 18 18 |+| 19 19 |+| 20 20 |+| 21 21 |+| 22 22 |+| 23 23 |+| 24 24 |+| 25 25 |+| 26 26 |+| 27 27 |+| 28 28 |+| 29 29 |+| 30 30 |+| 31 31 |+| 32 32 |+| 33 33 |+| 34 34 |+| 35 35 |+| 36 36 |+| 37 37 |+| 38 38 |+| 39 39 |+| 40 40 |+| 41 41 |+| 42 42 |+| 43 43 |+| 44 44 |+| 45 45 |+| 46 46 |+| 47 47 |+| 48 48 |+| 49 49 |+| 50 50 |+| 52 52 |+| 53 53 |+| 54 54 |+| 55 55 |+| 56 56 |+| 58 58 |+| 59 59 |+| 61 61 |+| 63 63 |+| 65 65 |+| 67 67 |+| 70 70 |+| 71 71 |+| 75 75 |+| 77 77 |+| 78 78 |+| 79 79 ## 9 0 0 |+| 2 2 |+| 3 3 |+| 4 4 |+| 7 7 |+| 8 8 |+| 9 9 |+| 10 10 |+| 11 11 |+| 13 13 |+| 14 14 |+| 16 16 |+| 17 17 |+| 18 18 |+| 19 19 |+| 20 20 |+| 21 21 |+| 22 22 |+| 23 23 |+| 24 24 |+| 25 25 |+| 26 26 |+| 27 27 |+| 28 28 |+| 29 29 |+| 30 30 |+| 31 31 |+| 32 32 |+| 33 33 |+| 34 34 |+| 35 35 |+| 36 36 |+| 37 37 |+| 38 38 |+| 39 39 |+| 40 40 |+| 41 41 |+| 42 42 |+| 43 43 |+| 44 44 |+| 45 45 |+| 46 46 |+| 47 47 |+| 48 48 |+| 49 49 |+| 50 50 |+| 52 52 |+| 53 53 |+| 54 54 |+| 55 55 |+| 56 56 |+| 58 58 |+| 59 59 |+| 61 61 |+| 63 63 |+| 65 65 |+| 67 67 |+| 70 70 |+| 71 71 |+| 75 75 |+| 77 77 |+| 78 78 |+| 79 79 ## 12 0 0- 4 pct |+| 1 5-14 pct |+| 2 15-24 pct |+| 3 25-34 pct |+| 4 35-44 pct |+| 5 45-54 pct |+| 6 55-64 pct |+| 7 65-74 pct |+| 8 75-84 pct ## 11 0 0 |+| 4 4 |+| 5 5 |+| 7 7 |+| 8 8 |+| 9 9 |+| 11 11 |+| 12 12 |+| 14 14 |+| 15 15 |+| 16 16 |+| 17 17 |+| 19 19 |+| 20 20 |+| 21 21 |+| 22 22 |+| 23 23 |+| 24 24 |+| 25 25 |+| 26 26 |+| 27 27 |+| 28 28 |+| 29 29 |+| 30 30 |+| 31 31 |+| 32 32 |+| 33 33 |+| 34 34 |+| 35 35 |+| 36 36 |+| 37 37 |+| 38 38 |+| 39 39 |+| 40 40 |+| 41 41 |+| 42 42 |+| 43 43 |+| 44 44 |+| 45 45 |+| 46 46 |+| 47 47 |+| 48 48 |+| 49 49 |+| 50 50 |+| 51 51 |+| 52 52 |+| 53 53 |+| 54 54 |+| 55 55 |+| 58 58 |+| 61 61 |+| 62 62 |+| 64 64 |+| 66 66 |+| 69 69 |+| 70 70 |+| 80 80 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 <- "v67.d3" # --independent variables in UNrestricted model-- UiV <- c("v2002.d2", "v1845", "v1649", "v1127.d2", "v2137", "v279.d5", "v213.d3", "v1265", "v1", "v234", "femecon.lp", "rectang") # --additional exogenous variables (use in Hausman tests)-- oxog <- c("v1260") # --independent variables in restricted model (all must be in UiV above)-- RiV <- c("v1649", "v1127.d2", "v2137", "v279.d5", "v213.d3", "v1265", "v234")
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 = oxog, dw = TRUE, lw = TRUE, ew = FALSE, stepW = TRUE, boxcox = FALSE, getismat = FALSE, relimp = TRUE, slmtests = FALSE, haustest = c("v213.d3"), mean.data = TRUE, doboot = 500) h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = NULL, dw = TRUE, lw = TRUE, ew = TRUE, stepW = TRUE, boxcox = FALSE, getismat = FALSE, relimp = TRUE, slmtests = FALSE, haustest = NULL, mean.data = TRUE, doboot = 1000) #Works with DEf01c CSVwrite(h, "v67.d3.olsresults.ew", FALSE) # DEf01b SCCS DEf01c SCCS ------------------------- ew = TRUE h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = NULL, dw = TRUE, lw = TRUE, ew = FALSE, stepW = TRUE, boxcox = FALSE, getismat = FALSE, relimp = TRUE, slmtests = FALSE, haustest = NULL, mean.data = TRUE, doboot = 1000) #Works with DEf01c CSVwrite(h, "v67.d3.olsresultsNo.ew", FALSE) # DEf01b SCCS DEf01c SCCS ----------------------- ew = FALSE ## [1] "--finding optimal weight matrix------" ## [1] "Exogenous variables used to instrument Wy: xWv1845, xWv1649, xWv1127.d2, xWv2137, xWv279.d5, xWv1265, xWv1, xWv234, xWrectang, xWv234Sq, xWv213.d3" ## [1] "--looping through the imputed datasets--" ## [1] 1 ## [1] 2 ## [1] 3 ## [1] 4 ## [1] 5 ## Time difference of 24.22 secs
names(h) ## [1] "DependVarb" "URmodel" ## [3] "Rmodel" "EndogeneityTests" ## [5] "Diagnostics" "OtherStats" ## [7] "DescripStatsImputedData" "DescripStatsOriginalData" ## [9] "totry" "didwell" ## [11] "dfbetas" "data"
The output from doOLS, here called h, is a list containing 12 items.
name description #1 DependVarb Description of dependent variable #2 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. #3 Rmodel Coefficient estimates from the restricted model. If relimp=TRUE, the R2 assigned to each independent variable is shown here. #4 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). #5 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. #6 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. #7 DescripStatsImputedData Descriptive statistics for variables in unrestricted model. #8 DescripStatsOriginalData Descriptive statistics for variables in unrestricted model. #9 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. #10 didwell Character string of variables that were most significant in the unrestricted model. #11 dfbetas Influential observations for dfbetas (see details) #12 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 ten provide a nice overview.
h[1:10] ## $DependVarb ## [1] "Dependent variable='v67.d3': Household Form == Single family dwellings" ## ## $URmodel ## coef stdcoef VIF stepkept pval hcpval bootpval star ## (Intercept) 0.56936 NaN NaN 1 0.07821 0.06646 0.07688 * ## femecon.lp 0.02209 0.07177 1.101 1 0.35853 0.35050 0.34491 ## rectang 0.00715 0.00560 1.289 0 0.94231 0.94266 0.94127 ## v1 -0.03829 -0.09646 1.229 1 0.20922 0.18920 0.20516 ## v1127.d2 0.30583 0.23690 1.527 1 0.00490 0.00445 0.00407 *** ## v1265 -0.06027 -0.12881 1.124 1 0.08825 0.08585 0.08006 * ## v1649 -0.01990 -0.25963 1.085 1 0.00031 0.00016 0.00011 *** ## v1845 -0.01301 -0.02906 1.103 0 0.70071 0.70756 0.70460 ## v2002.d2 0.17249 0.10470 1.248 1 0.16824 0.16698 0.14189 ## v213.d3 0.10764 0.08142 1.150 1 0.27027 0.27385 0.27530 ## v2137 -0.23618 -0.20116 1.816 1 0.02772 0.01935 0.02601 ** ## v234 -0.01241 -0.05981 1.881 0 0.52170 0.51398 0.50356 ## v279.d5 0.18898 0.13961 1.126 1 0.07309 0.06527 0.06628 * ## Wy 0.83896 0.16875 1.378 1 0.04191 0.01010 0.03228 ** ## desc ## (Intercept) <NA> ## femecon.lp female economic contribution (LP scale) ## rectang Dwelling is rectangular ## v1 Intercommunity Trade as Food Source ## v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, ## v1265 Occurrence of Famine ## v1649 Frequency of Internal Warfare (Resolved Rating) ## v1845 Modernization: Sum of Technological Changes ## v2002.d2 World Religions (1807) == Deep Islamization ## v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents ## v2137 Food Production: Planting (task present==1, absent==0) ## v234 Settlement Patterns ## v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes ## Wy Network lag term ## ## $Rmodel ## coef stdcoef VIF relimp pval hcpval bootpval star ## (Intercept) 0.60247 NaN NaN NaN 0.01714 0.00643 0.01384 ** ## v1127.d2 0.30383 0.23535 1.225 0.04059 0.00159 0.00186 0.00195 *** ## v1265 -0.06801 -0.14534 1.030 0.02733 0.04071 0.04090 0.03888 ** ## v1649 -0.01825 -0.23820 1.055 0.05583 0.00076 0.00044 0.00029 *** ## v213.d3 0.11246 0.08506 1.095 0.00856 0.23195 0.24697 0.22988 ## v2137 -0.22205 -0.18912 1.767 0.03650 0.03505 0.02459 0.03157 ** ## v234 -0.01362 -0.06561 1.727 0.01520 0.45943 0.44812 0.45550 ## v279.d5 0.16850 0.12453 1.103 0.02694 0.09902 0.09514 0.09201 * ## Wy 0.77311 0.15559 1.281 0.06117 0.05118 0.01229 0.03928 * ## desc ## (Intercept) <NA> ## v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, ## v1265 Occurrence of Famine ## v1649 Frequency of Internal Warfare (Resolved Rating) ## v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents ## v2137 Food Production: Planting (task present==1, absent==0) ## v234 Settlement Patterns ## v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes ## Wy Network lag term ## ## $EndogeneityTests ## weakidF p.Sargan n.IV Fstat df pvalue star ## v213.d3 2.855 0.53 2 0 4497 0.993 ## ## $Diagnostics ## Fstat df ## RESET test. H0: model has correct functional form 0.0000 3.855e+11 ## Wald test. H0: appropriate variables dropped 0.9474 2.542e+04 ## Breusch-Pagan test. H0: residuals homoskedastic 1.0066 1.254e+03 ## Shapiro-Wilkes test. H0: residuals normal 8.1091 2.300e+03 ## Hausman test. H0: Wy is exogenous 7.5717 9.200e+01 ## Sargan test. H0: residuals uncorrelated with instruments 0.0482 1.149e+05 ## pvalue star ## RESET test. H0: model has correct functional form 0.9988 ## Wald test. H0: appropriate variables dropped 0.3304 ## Breusch-Pagan test. H0: residuals homoskedastic 0.3159 ## Shapiro-Wilkes test. H0: residuals normal 0.0044 *** ## Hausman test. H0: Wy is exogenous 0.0071 *** ## Sargan test. H0: residuals uncorrelated with instruments 0.8262 ## ## $OtherStats ## d l e Weak.Identification.Fstat R2.final.model R2.UR.model nimp ## 1 0.52 0.48 0 14.65 0.201 0.219 5 ## nobs BClambda ## 1 186 none ## ## $DescripStatsImputedData ## desc nobs mean sd min max ## femecon.lp female economic contribution (LP scale) 930 5.78 1.686 1 9 ## ## $DescripStatsOriginalData ## desc ## v67.d3 Household Form == Single family dwellings ## v2002.d2 World Religions (1807) == Deep Islamization ## v1845 Modernization: Sum of Technological Changes ## v1649 Frequency of Internal Warfare (Resolved Rating) ## v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, ## v2137 Food Production: Planting (task present==1, absent==0) ## v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes ## v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents ## v1265 Occurrence of Famine ## v1 Intercommunity Trade as Food Source ## v234 Settlement Patterns ## rectang Dwelling is rectangular ## nobs mean sd min max ## v67.d3 186 0.468 0.500 0 1 ## v2002.d2 186 0.102 0.304 0 1 ## v1845 135 1.637 1.156 0 6 ## v1649 152 7.250 6.483 1 17 ## v1127.d2 184 0.185 0.389 0 1 ## v2137 185 0.762 0.427 0 1 ## v279.d5 152 0.145 0.353 0 1 ## v213.d3 185 0.173 0.379 0 1 ## v1265 170 3.318 1.057 1 4 ## v1 183 3.546 1.261 1 7 ## v234 186 4.925 2.411 1 8 ## rectang 186 0.188 0.392 0 1 ## ## $totry ## [1] "v2137:v234" "femecon.lp" "v1" "v2002.d2" ## ## $didwell ## [1] "v1127.d2" "v1265" "v1649" "v213.d3" "v2137" "v279.d5"
The 12th item in list h is a dataframe containing mean values of variables across imputations. This can be used to make maps, employing the function mkmapppng.
mkmappng(h12, "v1649", "v1649FrequencyInternalWarfare", show = "ydata", numnb.lg = 3, numnb.lm = 20, numch = 5, pvlm = 0.05, dfbeta.show = TRUE) mkmappng(h12, "v1", "v1Dependence_on_Trade", show = "ydata", numnb.lg = 3, numnb.lm = 20, numch = 5, pvlm = 0.05, dfbeta.show = TRUE) aa=h$data ##??? no aa=h12 ##??? no aa$v1 is incorrect as listed in h12 below BECAUSE THESE CASES ARE ALPHABETIZED !!! v1=1.0 is O, 5.0 is S=Ajie, 4.0 is U=Ainu ## Loading required package: mapproj ## pdf ## 2 ###h[[12]] ### v67.d3 Wy v2002.d2 v1845 v1649 v1127.d2 v2137 v279.d5 v213.d3 v1265 v1 v234 femecon.lp rectang dfb.Wy dfb.v1649 dfb.v1127.d2 dfb.v2137 dfb.v279.d5 ###Abipon 1 0.5844529 0 1.0 13.0 0 0 0.4 1.0 2.0 1.0 1 5.2 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 ###Abkhaz 0 0.4675963 0 1.0 17.0 0 1 0.0 0.0 4.0 1.0 5 6.2 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 ###Ainu 0 0.4490349 0 4.0 5.0 0 1 0.0 0.0 4.0 4.0 3 7.4 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 ###Ajie 0 0.4321597 0 0.6 15.8 0 1 0.0 0.0 4.0 5.0 7 6.0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
You can't click here to see Eff's png but it is saved to your directory from R gui
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) ##moved just below (RENAME YOUR olsresults.csv to same and allow a new run) getwd() #to see what your working directory is. Then look in that folder.
Models with binary dependent variables are usually estimated with logit or probit ML methods. However, it is a good idea to first estimate the model with OLS, as we did above, to find a good model, and then estimate it with logit, as we do below, using the function doLogit.
dpV <- "v67.d3" UiV <- c("v2002.d2", "v1845", "v1649", "v1127.d2", "v2137", "v279.d5", "v213.d3", "v1265", "v1", "v234", "femecon.lp", "rectang") RiV <- c("v1649", "v1127.d2", "v2137", "v1265") q <- doLogit(smi, depvar = dpV, indpv = UiV, rindpv = RiV, dw = TRUE, lw = TRUE, ew = FALSE, ##ew = FALSE, doboot = 1000, mean.data = TRUE, getismat = FALSE, othexog = NULL)
#CSVwrite(h, "v67.d3.olsresultsNo.ew", FALSE) h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = NULL, dw = TRUE, lw = TRUE, ew = FALSE, stepW = TRUE, boxcox = FALSE, getismat = FALSE, relimp = TRUE, slmtests = FALSE, haustest = NULL, mean.data = TRUE, doboot = 1000) #Works with DEf01c CSVwrite(h, "v67.d3.olsresultsNo.ew", FALSE) #DEf01b SCCS DEf01c SCCS
#CSVwrite(h, "v67.d3.olsresults.eW", TRUE) h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = NULL, dw = TRUE, lw = TRUE, ew = TRUE, stepW = TRUE, boxcox = FALSE, getismat = FALSE, relimp = TRUE, slmtests = FALSE, haustest = NULL, mean.data = TRUE, doboot = 1000) #Works with DEf01c CSVwrite(h, "v67.d3.olsresults.ew", FALSE) #DEf01b SCCS DEf01c SCCS
Code for output
dx$v1<=bb$v1 #this makes an integer map although TRUE/FALSE mkmappng(h12, "v1", "v1Dependence on Trade", show = "ydata", numnb.lg = 3, numnb.lm = 20, numch = 5, pvlm = 0.05, dfbeta.show = TRUE) #This works dx$v1
dx$v67.d3<=bb$v67.d3 #this makes an integer map although TRUE/FALSE 0/1 mkmappng(h12, "v67.d3", "v67.d3SingleFamilyDwellings", show = "ydata", numnb.lg = 3, numnb.lm = 20, numch = 5, pvlm = 0.05, dfbeta.show = TRUE) #This runs but does it make the png? dx$v1 ## [1] "--finding optimal weight matrix------" ## [1] "Exogenous variables used to instrument Wy: xWv2002.d2, xWv1845, xWv1649, xWv1127.d2, xWv2137, xWv279.d5, xWv1265, xWv1, xWv234, xWrectang, xWv1845Sq, xWv234Sq" ## [1] "--looping through the imputed datasets--" ## [1] 1 ## [1] 2 ## [1] 3 ## [1] 4 ## [1] 5 ## Time difference of 1.103 mins names(q) ## [1] "DependVarb" "URmodel" "Rmodel" "Diagnostics1" ## [5] "Diagnostics2" "OtherStats" "data" q[1:6] ## $DependVarb ## [1] "Dependent variable='v67.d3': Household Form == Single family dwellings" ## ## $URmodel ## coef fst df pval star ## (Intercept) 0.54656 0.08 4 0.7871 ## Wy 4.45190 4.27 5 0.0936 * ## v2002.d2 1.02552 1.59 4 0.2755 ## v1845 -0.07276 0.12 5 0.7383 ## v1649 -0.11460 10.53 4 0.0315 ** ## v1127.d2 1.64360 7.20 4 0.0551 * ## v2137 -1.18435 4.16 4 0.1110 ## v279.d5 0.99704 2.15 5 0.2025 ## v213.d3 0.53154 0.80 4 0.4227 ## v1265 -0.34476 2.86 5 0.1518 ## v1 -0.24574 1.61 4 0.2728 ## v234 -0.07469 0.47 4 0.5307 ## femecon.lp 0.12949 0.86 5 0.3958 ## rectang 0.01716 0.00 4 0.9768 ## desc ## (Intercept) <NA> ## Wy Network lag term ## v2002.d2 World Religions (1807) == Deep Islamization ## v1845 Modernization: Sum of Technological Changes ## v1649 Frequency of Internal Warfare (Resolved Rating) ## v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, ## v2137 Food Production: Planting (task present==1, absent==0) ## v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes ## v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents ## v1265 Occurrence of Famine ## v1 Intercommunity Trade as Food Source ## v234 Settlement Patterns ## femecon.lp female economic contribution (LP scale) ## rectang Dwelling is rectangular ## ## $Rmodel ## coef fst df pval star ## (Intercept) 0.20696 0.03 5 0.8642 ## Wy 4.82723 7.26 5 0.0431 ** ## v1649 -0.09365 11.42 4 0.0278 ** ## v1127.d2 1.37058 9.02 4 0.0398 ** ## v2137 -1.26049 9.09 4 0.0394 ** ## v1265 -0.37668 5.26 5 0.0703 * ## desc ## (Intercept) <NA> ## Wy Network lag term ## v1649 Frequency of Internal Warfare (Resolved Rating) ## v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, ## v2137 Food Production: Planting (task present==1, absent==0) ## v1265 Occurrence of Famine ## ## $Diagnostics1 ## fst df pval star ## LRtestNull-R 36.6886 2788 0.0000 *** ## LRtestNull-UR 32.5188 13606 0.0000 *** ## LRtestR-R 2.2828 2069 0.1310 ## waldtestR-R 0.3387 15111317 0.5606 ## desc ## LRtestNull-R H0:All coefficients in restricted model equal zero ## LRtestNull-UR H0:All coefficients in UNrestricted model equal zero ## LRtestR-R H0:Variables dropped from unrestricted model have coefficients equal zero (likelihood ratio test) ## waldtestR-R H0:Variables dropped from unrestricted model have coefficients equal zero (Wald test) ## ## $Diagnostics2 ## R.model UR.model desc ## pLargest 0.5323 0.5323 max(Prob(y==1),Prob(y==0)) [best guess] ## pRight 0.6882 0.7129 Prob(y==yhat) [prop. correct] ## NetpRight 0.1559 0.1806 prop. correct net of best guess ## McIntosh.Dorfman 1.3743 1.4230 prop. correct 0s + prop. correct 1s ## McFadden.R2 0.2007 0.2502 McFadden pseudo R2 ## Nagelkerke.R2 0.2422 0.2923 Nagelkerke psuedo R2 ## ## $OtherStats ## d l e nimp nobs ## 1 0.6 0.4 0 5 186
Results
h[1] $DependVarb [1] "Dependent variable='v67.d3': Household Form == Single family dwellings" > h[2] $URmodel coef stdcoef VIF stepkept pval hcpval bootpval star (Intercept) 0.63251 NaN NaN 1 0.05238 0.04680 0.05695 * femecon.lp 0.01809 0.06361 1.12875 1 0.46031 0.45474 0.45271 rectang 0.01366 0.01070 1.28515 0 0.88738 0.89083 0.88777 v1 -0.04289 -0.10797 1.22795 1 0.14885 0.13345 0.14671 v1127.d2 0.29310 0.22704 1.51848 1 0.00607 0.00725 0.00837 *** v1265 -0.06763 -0.14385 1.10251 1 0.04771 0.04519 0.04160 ** v1649 -0.02059 -0.26834 1.06692 1 0.00011 0.00006 0.00005 *** v1845 -0.01642 -0.03646 1.11738 0 0.64738 0.65783 0.65585 v2002.d2 0.18375 0.11153 1.24646 1 0.14123 0.13521 0.12246 v213.d3 0.10966 0.08295 1.14199 1 0.24772 0.23942 0.23528 v2137 -0.23432 -0.19957 1.81712 1 0.02549 0.01723 0.02548 ** v234 -0.01279 -0.06164 1.86368 0 0.49816 0.48380 0.48254 v279.d5 0.22549 0.16472 1.11789 1 0.03023 0.02448 0.02722 ** Wy 0.83297 0.16492 1.38952 1 0.04062 0.01001 0.03321 ** desc (Intercept) <NA> femecon.lp female economic contribution (LP scale) rectang Dwelling is rectangular v1 Intercommunity Trade as Food Source v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, v1265 Occurrence of Famine v1649 Frequency of Internal Warfare (Resolved Rating) v1845 Modernization: Sum of Technological Changes v2002.d2 World Religions (1807) == Deep Islamization v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents v2137 Food Production: Planting (task present==1, absent==0) v234 Settlement Patterns v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes Wy Network lag term > h[3] $Rmodel coef stdcoef VIF relimp pval hcpval bootpval star (Intercept) 0.66075 NaN NaN NaN 0.00550 0.00149 0.00477 *** v1127.d2 0.29003 0.22466 1.20831 0.03863 0.00215 0.00318 0.00326 *** v1265 -0.07868 -0.16732 1.01987 0.03380 0.01563 0.01551 0.01532 ** v1649 -0.01920 -0.25023 1.04430 0.06381 0.00026 0.00016 0.00012 *** v213.d3 0.11800 0.08926 1.08524 0.00898 0.19686 0.20387 0.19316 v2137 -0.22346 -0.19032 1.75410 0.03679 0.02991 0.01974 0.02212 ** v234 -0.01285 -0.06192 1.70779 0.01506 0.47383 0.45889 0.46645 v279.d5 0.20688 0.15122 1.08946 0.03788 0.04153 0.03794 0.04220 ** Wy 0.72392 0.14325 1.25890 0.05460 0.05828 0.01344 0.05101 * desc (Intercept) <NA> v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, v1265 Occurrence of Famine v1649 Frequency of Internal Warfare (Resolved Rating) v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents v2137 Food Production: Planting (task present==1, absent==0) v234 Settlement Patterns v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes Wy Network lag term > h[4] $EndogeneityTests weakidF p.Sargan n.IV Fstat df pvalue star v213.d3 2.855 0.458 2 0.013 288008 0.909 > h[5] $Diagnostics Fstat df pvalue star RESET test. H0: model has correct functional form -0.0007 966633 1.0000 Wald test. H0: appropriate variables dropped 1.1130 138 0.2933 Breusch-Pagan test. H0: residuals homoskedastic 1.0173 1873 0.3133 Shapiro-Wilkes test. H0: residuals normal 6.5850 1636 0.0104 ** Hausman test. H0: Wy is exogenous 8.4334 314 0.0039 *** Sargan test. H0: residuals uncorrelated with instruments 0.3201 2620 0.5716 > h[6] $OtherStats d l e Weak.Identification.Fstat R2.final.model R2.UR.model nimp nobs BClambda 1 0.5 0.5 0 16.74852 0.229875 0.2459698 5 186 none The optimal weight matrix is W=.50*Wd+.50*Wl. > h[7] $DescripStatsImputedData desc nobs mean sd min max femecon.lp female economic contribution (LP scale) 930 6.095 1.781 1 9 > h[8] $DescripStatsOriginalData desc nobs mean sd min max v67.d3 Household Form == Single family dwellings 186 0.468 0.500 0 1 v2002.d2 World Religions (1807) == Deep Islamization 186 0.102 0.304 0 1 v1845 Modernization: Sum of Technological Changes 135 1.637 1.156 0 6 v1649 Frequency of Internal Warfare (Resolved Rating) 152 7.250 6.483 1 17 v1127.d2 Crop Type Plow-positive or -negative == Plow-positive (Buckwheat, Wheat, Barley, Wet Rice, Rye, 184 0.185 0.389 0 1 v2137 Food Production: Planting (task present==1, absent==0) 185 0.762 0.427 0 1 v279.d5 Inheritance of Movable Property: Rule or Practice for Inheritance == Children, equally for both sexes 152 0.145 0.353 0 1 v213.d3 Marital Residence with Kin: First Years (Atlas 10 Combined) == Uxorilocal: with wifes parents 185 0.173 0.379 0 1 v1265 Occurrence of Famine 170 3.318 1.057 1 4 v1 Intercommunity Trade as Food Source 183 3.546 1.261 1 7 v234 Settlement Patterns 186 4.925 2.411 1 8 rectang Dwelling is rectangular 186 0.188 0.392 0 1 > h[9] $totry [1] "v2137:v234" "femecon.lp" "v1" "v2002.d2" > h[10] $didwel [1] "v1127.d2" "v1265" "v1649" "v213.d3" "v2137" "v279.d5" > h[12] $data v67.d3 Wy v2002.d2 v1845 v1649 v1127.d2 v2137 v279.d5 v213.d3 v1265 v1 v234 femecon.lp rectang dfb.Wy Abipon 1 0.5706493 0 1.0 13.0 0 0 0.4 1 2.0 1.0 1 5.6 0 0.0000000 Abkhaz 0 0.4759691 0 1.0 17.0 0 1 0.0 0 4.0 1.0 5 2.4 0 0.0000000 Ainu 0 0.4451692 0 4.0 5.0 0 1 0.0 0 4.0 4.0 3 6.4 0 0.0000000
Special Functions partially copied from http://capone.mtsu.edu/eaeff/downloads/Manual_DEf1b.htm
mkmapping with convex hulls for local autocorrelation clusters: this script separately but is called in the main program
http://capone.mtsu.edu/eaeff/downloads/Manual_DEf1b.htm mkdummy("v2002", 2) mkdummy("v1127", 2) mkdummy("v279", 5) mkdummy("v213", 3) dx$rectang <- (dx$v65 >= 8 & dx$v65 <= 9) * 1 dpV<-"v67.d3" UiV<-c("v2002.d2", "v1845", "v1649", "v1127.d2", "v2137", "v279.d5", "v213.d3", "v1265", "v1", "v234", "femecon.lp", "rectang") RiV<-c("v1649", "v1127.d2", "v2137", "v1265") h<-doOLS(MIdata=smi, depvar=dpV, indpv=UiV, rindpv=RiV, othexog=NULL, dw=TRUE, lw=TRUE, ew=FALSE, stepW=TRUE, boxcox=FALSE, getismat=FALSE, relimp=TRUE, slmtests=FALSE, haustest=NULL, mean.data=TRUE, doboot=500) #FIXED WITH Error in which(!is.na(dx[, depvar])) : error in evaluating the argument 'x' in selecting a method for function 'which': Error in `[.data.frame`(dx, , depvar) : undefined columns selected
##h[[12]] p<-h12 latilong<-data.frame(h12) ###workaround h12
# experimenting to find the right number of convex hulls sapply(latilong(2:11), function(x) mkmappng(p, "femecon.lp", paste("Womenswork", x, sep=""), show="lmtp", numch=x, dfbeta.show=TRUE))
##sapply(2:11, function(x) mkmappng(p, "femecon.lp", paste("Womenswork", x, sep=""), #Error in mkmappng(p, "femecon.lp", paste("Womenswork", x, sep = ""), show = "lmtp", : input data needs to have two variables, one named 'long', the other 'lati'
# creates file called “Womenswork_ydata.png” mkmappng(usedata=p, varb="femecon.lp", filetitle="Womenswork", show="ydata", numch=8, dfbeta.show=TRUE)
fv4scale p5
http://capone.mtsu.edu/eaeff/downloads/Manual_DEf1b.htm #Examples p5 TRANSLATES WORDS TO variable numbers # --finds SCCS variables related to female economic contribution-- femecon<-fv4scale(lookword=c("market", "exchange", "wage", "trade", "subsistence", "goods", "product", "labor"), keepword=c("female", "women", "woman"), coreword=c("subsistence"), nmin=60, chklevels=TRUE, verbose=FALSE) #returns SCCS variables related to female economic contribution c("v889", "v890", "v887", "v826", "v886", "v885", "v585", "v888", "v593", "v658", "v660", "v594")
mkscale Calculate scale (composite index from component variables p7
http://capone.mtsu.edu/eaeff/downloads/Manual_DEf1b.htm A Scale for Markets pdf by Eff 2010 mkscale(compvarbs, udnavn=NULL, impdata, type="LP", add.descrip=NULL) #USAGE BELOW #Arguments #compvarbs #names of component variables to include in the scale. #udnavn the name of the scale. #impdata the name of the multiply imputed dataset containing component variables. #type the method to use in calculating the scale (one of “LP”, “mean”, “pc1”). #add.descrip the description of the scale, to add to the metadata file.
scnn<-c(femecon, "v1649", "v1127", "v2137", "v1265") smi<-doMI(scnn, nimp=10, maxit=7) ##PROBLEM?: femecon defined as WITH NO COMMAS? [1] "v889" "v890" "v887" "v826" "v886" "v885" "v585" "v888" "v593" "v658" "v660" "v594" although #scnn<-c(femecon) and scnn is "v889" "v890" "v887" "v826" "v886" "v885" "v585" "v888" "v593" "v658" "v660" "v594" *Error in which(apply(is.na(dx[, tivv]), 2, sum) > 0) : error in evaluating the argument 'x' in selecting a method for function 'which': Error in apply(is.na(dx[, tivv]), 2, sum) : dim(X) must have a positive length
fec<-mkscale(compvarbs="femecon", udnavn="femecon.lp", impdata=smi, type="LP", add.descrip="female economic contribution (LP scale)") #--check reasonableness of scale-- fec$stats fec$corrs smi[,names(fec$scales)]<-fec$scales #Error in which(apply(is.na(dx[, tivv]), 2, sum) > 0) : error in evaluating the argument 'x' in selecting a method for function 'which': Error in apply(is.na(dx[, tivv]), 2, sum) : dim(X) must have a positive length
doMI Produce multiply imputed databases p6
#Examples scnn<-c("v1649", "v1127", "v2137", "v1265") smi<-doMI(scnn, nimp=10, maxit=7) #Error in which(apply(is.na(dx[, tivv]), 2, sum) > 0) : error in evaluating the argument 'x' in selecting a method for function 'which': Error in apply(is.na(dx[, tivv]), 2, sum) : dim(X) must have a positive length dim(smi) smi[1,2 ]