tests/test_algorithm.R

# todo: move this to testthat
# # Title     : TODO
# # Objective : TODO
# # Created by: iosefa
# # Created on: 2021/02/25
#
# library(sf)
# library(geodist)
# library(dplyr)
# library(GWpcor)
# library(Rcpp)
# library(corpcor)
#
# sourceCpp("src/gwpcor.cpp")
# source("R/fct_gwpcor.R")
#
# # load data in various required formats
#
# # selected variables
# selected_vars <- c("total.population", "Daytime.Population", "Population.Density")
#
# # sf
# sdata <- st_read("data-raw/tokyo2005_sf.gpkg") %>%
#   st_transform(.,4326)
#
# # parameters
#
# # bandwidth
# bw <- 0.2
#
# # bandwidth type
# adaptive <- TRUE
#
# # coordinates
# dp.locat <- st_centroid(sdata) %>% st_coordinates()
#
# # distance matrix
# dMat <- geodist(dp.locat, measure = "cheap")
#
# # correlation type
# method <- "pearson"
#
# # kernel
# kernel <- "bisquare"
#
# app <- gwpcor(
#   sdata=sdata,
#   vars=selected_vars,
#   method=method,
#   kernel=kernel,
#   bw=bw,
#   adaptive=adaptive,
#   dMat=dMat
# )
#
# lib <- GWpcor::gwpcor(
#   sdata=sdata,
#   vars=selected_vars,
#   method=method,
#   kernel=kernel,
#   bw=bw,
#   adaptive=adaptive,
#   dMat=dMat
# )
#
# all.equal(app$SDF$corr_Daytime.Population.Population.Density, lib$SDF$corr_Daytime.Population.Population.Density)
# all.equal(app$SDF$corr_pval_Daytime.Population.Population.Density, lib$SDF$corr_pval_Daytime.Population.Population.Density)

Try the gwpcormapper package in your browser

Any scripts or data that you put into this service are public.

gwpcormapper documentation built on Dec. 11, 2021, 9:39 a.m.