AWC

From InterSciWiki
Jump to: navigation, search

Hi Doug,

  • It came to my attention that your original approval email to pay for AWS charges for the Galaxy/Cloudman instance was only valid for the 2015-2016 academic year. I need to have your approval for the 2016-2017 academic year to continue running the AWS instance.
  • Can you please confirm that you would like to continue to pay for the AWS instance using your AppleBy fund, PR? The charges have been around $5 per month, so very minimal, but to be safe please approve up to $500 per year (in case monthly costs increase).
  • Best, -- Jonathan Leung-Nilsson

SSPB 1265 | 949.824.1536 EAv17.AWC2

Original below then revision

.Dow-Eff Functions - DEf

#SEE JokAvo - Comments83 - EAv17.AWC

Script R Gui SCCS to pull AWC out of EA

setwd("/Users/drwhite/Desktop/R")
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
#load(url("http://dl.dropbox.com/u/9256203/DEf01b.Rdata"), .GlobalEnv)  # dont use b
#ls()  #-can see the objects contained in DEf01b.Rdata
#setwd("/Users/drwhite/Desktop/R")
AWC561<-read.csv("EA_AWC.csv", header=TRUE)
#TRY NEXT load(url("http://dl.dropbox.com/u/9256203/DEf01.Rdata"), .GlobalEnv)
#TRY NEXT ls()  #-can see the objects contained in DEf01b.Rdata
load(url("http://dl.dropbox.com/u/9256203/DEf01b.Rdata"), .GlobalEnv)  # dont use b
ls()  #-can see the objects contained in DEf01b.Rdata
setDS("EA")   ### DATASET EA OPEN SO AS TO DRAW THE SUBSET IN AWC
names(dx)
dx$code #the 1267 EA codes, e.g., Af32" "Af33" "Af34"  are to be SUBSETTED
#This transformation works:
wddbkup<-wed
wllbkup<-wll
AWC   <-dx$code              #THE 1267 codes in EA : "Aa1"  "Aa2"  "Aa3"  "Aa4"
#setwd("/Users/drwhite/Documents/R")
EAawc<-AWC561$EA_AWC  #THE SUBSET OF 561 codes in AWC : "Aa1"  "Aa2"  "Aa3"  "Aa5"  "Aa7"  
##FIND the  SUBSET EAawc<- (IN) AWC$EA_AWC  = AWC   <-dx$code
#set dx$eanumber=1 if EAawc exists in EA dx$code  <--- needs to be done by Tolga
dx$largepat=dx$v17  
addesc("largepat","largepat")
#=== list and modify variables for use in model===
# --make new variables-- 
###dx$BridePrice<-dx
# --create new dummy variables
mkdummy("v6", 1) ## [1] "Dummy variable named v6.d1" Bridewealth
evm <- c("bio.4","largepat","sdalt","bio.5","bio.9","v37","v70","v34") ### v70 xtra #add dpV name = largepat
smi <- doMI(evm, nimp = 2, maxit = 3)   ###remove "v73","v38","v68","v35","v66","v36","v6.d1"
aa<-aggregate(smi[,sapply(smi,function(x) is.numeric(x))],list(smi$.id),mean) # lists imputed variables from evm
#01b !!![1] "WARNING: variable may not be ordinal--v73" "WARNING: variable may not be ordinal--v38" "WARNING: variable may not be ordinal--v66"
#01b !!![4] "WARNING: variable may not be ordinal--v68" "WARNING: variable may not be ordinal--v35"
#find EA_awc (561 atlas IDS) in AWC (1267 atlas IDS) and set smi$eanum=1 if a match smi$eanum=0 is not
#dx$eanumber    [1]    1    2    3    4    5    6    7    8    9   10   not what we want  rather we want dx$code   [1] "Aa1"  "Ab1"  "Ab2"  "Ac1" 
ind <- c()
for(i in 1:length(EAawc)){ind<-c(ind,which(EA$code==EAawc[i]))}  #N=563
ind[1:20)
# [1]    1  101  102  202  636  726    2  404  405  411  103  104  203  204  302  303    4  728  731  737  105  748  752  106  206  304  6 
# OK TO HERE
z <- rep(FALSE,length(EA$code))   #THIS ISNT WORKING ALL FALSE EA$code is ok
for(i in 1:length(ind)){z[ind[i]]=TRUE}
wdd<-wdd[z,z]
wll<-wll[z,z]
wee<-wee[z,z]
dx <- dx[z,]
z1 <- rep(z,5)
smi1<-smi[z1,]
#Error in `[.data.frame`(smi, z1, ) :   (subscript) logical subscript too long
#q <- doLogit(smi1, depvar = dpV, indpv = UiV, rindpv = RiV, dw = TRUE, lw = TRUE, ew = FALSE, doboot = 1000, mean.data = TRUE,  getismat = FALSE, othexog = NULL)
#Error: could not find function "doLogit"
#OR AND THIS SEEMS TO BE WRONG:  MATCH THE h<-- to the 01b
h <- doOLS(smi2, 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 = c("v213.d3"), mean.data = TRUE, doboot = 500)
#OR
h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = oxog, dw = TRUE,  lw = TRUE, ew = FALSE, stepW = TRUE, relimp = TRUE, slmtests = FALSE)
CSVwrite(h, "AWCv17olsresultsNo.eW", FALSE)
h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = oxog, dw = TRUE,  lw = TRUE, ew = TRUE, stepW = TRUE, relimp = TRUE, slmtests = FALSE)
CSVwrite(h, "AWCv17olsresults.eW", FALSE)



#SKIP
z<-which(smi$eanum=1)
smi1<-smi[z,]
z<-which(EA$eanum=1)
wdd<-wdd[z,z]
wll<-wll[z,z]
dx <- dx[z,]
h <- doOLS(...)  or
q <- doLogit(...)
# --dependent variable--
dpV <- "largepat" 
# --independent variables in UNrestricted model-- 
UiV <- c("sdalt","bio.5","bio.9","v73","v36","v38","v37","v6.d1","v66","v68","v70","v34")
# --additional exogenous variables (use in Hausman tests)--
oxog <- c("bio.5","bio.9") ###,"v206" = %dependence on Animal Husbandry
# --independent variables in restricted model (all must be in UiV above)--
RiV <- c("sdalt","bio.5","bio.9","v73","v6.d1","v66","v68","v34")  #"v36","v37","v38","v70"
h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = oxog, dw = TRUE,  lw = TRUE, ew = FALSE, stepW = TRUE, relimp = TRUE, slmtests = FALSE)
CSVwrite(h, "AWCv17olsresultsNo.eW", FALSE)
h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = oxog, dw = TRUE,  lw = TRUE, ew = TRUE, stepW = TRUE, relimp = TRUE, slmtests = FALSE)
CSVwrite(h, "AWCv17olsresults.eW", FALSE)

Script R Gui SCCS to pull AWC out of EA Preparting - Ignore

setwd("/Users/drwhite/Desktop/R")
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
#load(url("http://dl.dropbox.com/u/9256203/DEf01b.Rdata"), .GlobalEnv)  # dont use b
#ls()  #-can see the objects contained in DEf01b.Rdata
#setwd("/Users/drwhite/Desktop/R")
AWC561<-read.csv("EA_AWC.csv", header=TRUE)
#TRY NEXT load(url("http://dl.dropbox.com/u/9256203/DEf01.Rdata"), .GlobalEnv)
#TRY NEXT ls()  #-can see the objects contained in DEf01b.Rdata
load(url("http://dl.dropbox.com/u/9256203/DEf01b.Rdata"), .GlobalEnv)  # dont use b
ls()  #-can see the objects contained in DEf01b.Rdata
setDS("EA")   ### DATASET EA OPEN SO AS TO DRAW THE SUBSET IN AWC
names(dx)
dx<-dx[which(!is.na(dx$awc)),]
dim(dx)
dim(dxf)
dxf<-dxf[which(!is.na(dxf$awc)),]
dim(dxf)
#The number of rows in dx should fall from 1265 to 558. 
dx$code #the 1267 EA codes, e.g., Af32" "Af33" "Af34"  are SUBSETTED
#This transformation works:
#wddbkup<-wed
#wllbkup<-wll
##AWC   <-dx$code              #THE 1267 codes in EA : "Aa1"  "Aa2"  "Aa3"  "Aa4"
#setwd("/Users/drwhite/Documents/R")
##EAawc<-AWC561$EA_AWC  #THE SUBSET OF 561 codes in AWC : "Aa1"  "Aa2"  "Aa3"  "Aa5"  "Aa7"  
##FIND the  SUBSET EAawc<- (IN) AWC$EA_AWC  = AWC   <-dx$code
#set dx$eanumber=1 if EAawc exists in EA dx$code  <--- needs to be done by Tolga
dx$largepat=dx$v17  
addesc("largepat","largepat")
#=== list and modify variables for use in model===
# --make new variables-- 
###dx$BridePrice<-dx
# --create new dummy variables
mkdummy("v6", 1) ## [1] "Dummy variable named v6.d1" Bridewealth
evm <- c("bio.4","largepat","sdalt","bio.5","bio.9","v37","v70","v34") ### v70 xtra #add dpV name = largepat
smi <- doMI(evm, nimp = 2, maxit = 3)   ###remove "v73","v38","v68","v35","v66","v36","v6.d1"
aa<-aggregate(smi[,sapply(smi,function(x) is.numeric(x))],list(smi$.id),mean) # lists imputed variables from evm
#01b !!![1] "WARNING: variable may not be ordinal--v73" "WARNING: variable may not be ordinal--v38" "WARNING: variable may not be ordinal--v66"
#01b !!![4] "WARNING: variable may not be ordinal--v68" "WARNING: variable may not be ordinal--v35"
#find EA_awc (561 atlas IDS) in AWC (1267 atlas IDS) and set smi$eanum=1 if a match smi$eanum=0 is not
#dx$eanumber    [1]    1    2    3    4    5    6    7    8    9   10   not what we want  rather we want dx$code   [1] "Aa1"  "Ab1"  "Ab2"  "Ac1" 
##ind <- c()
##for(i in 1:length(EAawc)){ind<-c(ind,which(EA$code==EAawc[i]))}  #N=563
##ind[1:20)
# [1]    1  101  102  202  636  726    2  404  405  411  103  104  203  204  302  303    4  728  731  737  105  748  752  106  206  304  6 
# OK TO HERE
##z <- rep(FALSE,length(EA$code))   #THIS ISNT WORKING ALL FALSE EA$code is ok
##for(i in 1:length(ind)){z[ind[i]]=TRUE}
##wdd<-wdd[z,z]
##wll<-wll[z,z]
##wee<-wee[z,z]
##dx <- dx[z,]
##z1 <- rep(z,5)
##smi1<-smi[z1,]
#Error in `[.data.frame`(smi, z1, ) :   (subscript) logical subscript too long
#q <- doLogit(smi1, depvar = dpV, indpv = UiV, rindpv = RiV, dw = TRUE, lw = TRUE, ew = FALSE, doboot = 1000, mean.data = TRUE,  getismat = FALSE, othexog = NULL)
#Error: could not find function "doLogit"
#OR AND THIS SEEMS TO BE WRONG:  MATCH THE h<-- to the 01b
h <- doOLS(smi2, 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 = c("v213.d3"), mean.data = TRUE, doboot = 500)
#OR
h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = oxog, dw = TRUE,  lw = TRUE, ew = FALSE, stepW = TRUE, relimp = TRUE, slmtests = FALSE)
CSVwrite(h, "AWCv17olsresultsNo.eW", FALSE)
h <- doOLS(smi, depvar = dpV, indpv = UiV, rindpv = RiV, othexog = oxog, dw = TRUE,  lw = TRUE, ew = TRUE, stepW = TRUE, relimp = TRUE, slmtests = FALSE)
CSVwrite(h, "AWCv17olsresults.eW", FALSE)