Running ‘CheckExploreMLSpawAggregate.R’ [170s/195s]
  Comparing ‘CheckExploreMLSpawAggregate.Rout’ to ‘CheckExploreMLSpawAggregate.Rout.save’ ... OK
  Running ‘CheckOrderSpawExact.R’
  Comparing ‘CheckOrderSpawExact.Rout’ to ‘CheckOrderSpawExact.Rout.save’ ... OK
  Running ‘spacom_MLA.R’ [12s/26s]
Running the tests in ‘tests/spacom_MLA.R’ failed.
Complete output:
  > #### new tests on the test data
  > library(spacom)
  > library(methods)
  > 
  > data(d_geo)
  > data(traces_event)
  > traces_event=traces_event[seq(1, nrow(traces_event), by=100),]
  > data(traces_ind)
  > data(homog_census)
  > 
  > ### create weight matrices
  > 
  > geow.50 <- WeightMatrix(d_geo, bandwidth=50)
  > geow.100 <- WeightMatrix(d_geo, bandwidth=100)
  > geow.200 <- WeightMatrix(d_geo, bandwidth=200)
  > 
  > ### MLA EXACT
  > 
  > ## prepare first spaw exact object
  > 
  > homog.0.50 <- SpawExact(precise.data=homog_census,
  +                         context.id="area.name",
  +                         contextual.names=c("Homog_00", "Homog_00"),
  +                         contextual.weight.matrices=list(NULL,geow.50))
  > colnames(homog.0.50)[2:3] <- c("homog.0", "homog.50")
  > 
  > 
  > wv.agg <- SpawAggregate(contextual.data=traces_event,
  +                         context.id="area.name",
  +                         contextual.names=c("w_all","w_all"),
  +                         contextual.weight.matrices=list(NULL, geow.50),
  +                         aggregation.functions="weighted.mean",
  +                         design.weight.names="weight",
  +                         nb.resamples=0,
  +                         verbose=FALSE)
  
  description done                                                   
  > 
  > colnames(wv.agg)[2:3] <- c("w_all.0", "w_all.50")
  > ## merge 2 outputs
  > cont.data <- merge(homog.0.50, wv.agg, by="area.name")
  > 
  > 
  > ## prepare ind level data
  > traces_ind <- na.exclude(traces_ind)
  > 
  > ## MlSpawExact
  > ass_test1 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0+homog.0,
  +     precise.data=cont.data,
  +     verbose=FALSE)
  > ### emypt model
  > ass_test1.1 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~1+(1|area.name),
  +     precise.data=NULL,
  +     verbose=FALSE)
  > ### only individual level
  > ass_test1.2 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name),
  +     precise.data=NULL,
  +     verbose=FALSE)
  > 
  > ### add lmer argument
  > ass_test2 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0+homog.0,
  +     precise.data=cont.data,
  +     verbose=FALSE,
  +     REML=FALSE)
  > 
  > ##### perform Moran on residuals
  > mor.test1 <- MLSpawResidMoran(ml.spaw.obj=ass_test1,
  + 							  distance.matrix=d_geo,
  + 							  bandwidths=c(25,50,100,200),
  +                               verbose=FALSE)
  Computing I for bandwidth 25
  
  moran done                                                         
  Computing I for bandwidth 50
  
  moran done                                                         
  Computing I for bandwidth 100
  
  moran done                                                         
  Computing I for bandwidth 200
  
  moran done                                                         
  > 
  > print(mor.test1)
                I
  h.25  0.2358700
  h.50  0.2571815
  h.100 0.2484977
  h.200 0.1791367
  > 
  > ############################# CHANGING FORMULA
  > ### add individual level interaction
  > ass_test3 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0 + victim_d:male,
  +     precise.data=cont.data,
  +     verbose=FALSE)
  > ## everything ok except standardized coef
  > 
  > ## add categorical ind level var
  > traces_ind2 <- traces_ind
  > traces_ind2$edu_all <- 0
  > traces_ind2$edu_all[traces_ind2$high_school==1] <- 1
  > traces_ind2$edu_all[traces_ind2$higher_edu==1] <- 2
  > 
  > ass_test3.1 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind2,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+ as.factor(edu_all) +
  +     (1|area.name)+ w_all.0,
  +     precise.data=cont.data,
  +     verbose=FALSE)
  > ## everything ok except standardized coef
  > 
  > ### random slope
  > ass_test3.2 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     cg_acc+ (1 + cg_acc|area.name)+ w_all.0,
  +     precise.data=cont.data,
  +     verbose=FALSE)
  > ## all okay
  > 
  > ### cross-level interaction
  > ass_test3.3 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     cg_acc+ (1 + cg_acc|area.name)+ w_all.0 + cg_acc:w_all.0,
  +     precise.data=cont.data,
  +     verbose=FALSE)
  > ## everything ok except standardized coef
  > 
  > 
  > 
  > ########### data issues
  > 
  > ## one area missing in individual level data
  > tr.ind <- traces_ind[traces_ind$area.name!="LJ",]
  > 
  > ass_test4 <-
  +   MLSpawExact(
  +     individual.level.data=tr.ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0,
  +     precise.data=cont.data,
  +     verbose=FALSE)
  Warning message:
  In checkContexts(obj@precise.data[[obj@context.id]], obj@individual.level.data[[obj@context.id]]) :
    The following context id(s) appear in the aggregated data, but not in the individual level data: ''.
  Please make sure this is what you wanted.
  
  > ### doesn't give error message!
  > 
  > ## one are missing in contextual level data
  > cont.data.1 <- cont.data[cont.data$area.name!="BG",]
  > 
  > ass_test5 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0,
  +     precise.data=cont.data.1,
  +     verbose=FALSE)
  Warning message:
  In checkContexts(obj@precise.data[[obj@context.id]], obj@individual.level.data[[obj@context.id]]) :
    The following context id(s) appear in the individual level data, but not in the aggregated data: 'BG'.
  This is almost certainly not what you wanted.
  
  > ## it computes, no error message!
  > 
  > ## same number of context areas but different
  > 
  > ass_test5 <-
  +   MLSpawExact(
  +     individual.level.data=tr.ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0,
  +     precise.data=cont.data.1,
  +     verbose=FALSE)
  Warning messages:
  1: In checkContexts(obj@precise.data[[obj@context.id]], obj@individual.level.data[[obj@context.id]]) :
    The following context id(s) appear in the individual level data, but not in the aggregated data: 'BG'.
  This is almost certainly not what you wanted.
  
  2: In checkContexts(obj@precise.data[[obj@context.id]], obj@individual.level.data[[obj@context.id]]) :
    The following context id(s) appear in the aggregated data, but not in the individual level data: 'BG'.
  Please make sure this is what you wanted.
  
  > ## computes only on the same ones (n.area=78), doesn't give error msg
  > 
  > ## missing values in context data
  > cont.data.2 <- cont.data
  > cont.data.2$w_all.0[c(5,25,50,80)] <- NA
  > 
  > ass_test6 <-
  +   MLSpawExact(
  +     individual.level.data=traces_ind,
  +     context.id="area.name",
  +     formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+higher_edu+
  +     (1|area.name)+w_all.0,
  +     precise.data=cont.data.2,
  +     verbose=FALSE)
  Warning message:
  In PerformMLSpawExact(obj, ...) : There are NA's in your data!
  . This is almost certainly *not* what you wanted. Spacom may not be able to compute standardized coefficients correctly (although it will try).
  
  > ## it computes on 76 areas, no error msg, no std coeff for cont var
  > 
  > ## missing values in ind data
  > ind.data.1 <- traces_ind
  > ind.data.1$cg_ass[c(2,50,100,125)] <- NA
  > 
  > ass_test6 <-
  +   MLSpawExact(individual.level.data=ind.data.1,
  +               context.id="area.name",
  +               formula=cg_ass~victim_d+comb_d+male+age_1990+high_school+
  +               higher_edu+(1|area.name)+w_all.0,
  +               precise.data=cont.data,
  +               verbose=FALSE)
  
   *** caught segfault ***
  address 20000022, cause 'memory not mapped'