Learn R Programming

mgwrsar (version 1.1)

simu_multiscale: Estimation of linear and local linear model with spatial autocorrelation model (mgwrsar).

Description

The simu_multiscale function is designed for simulating a spatially varying coefficient DGP (Data Generating Process) based on formulations proposed by Fotheringam et al. (2017), Gao et al. (2021), or Geniaux (2024).

Usage

simu_multiscale(n=1000,myseed=1,type='GG2024',constant=NULL,
nuls=NULL,config_beta='default',config_snr=0.7,config_eps='normal',
ratiotime=1)

Value

A named list with simulated data ('mydata') and coords ('coords')

Arguments

n

An integer number of observations

myseed

An integer seed used for the simulation.

type

Type of DGP used 'FT2017', 'Gao2021' or 'GG2024', default 'GG2024'.

constant

A boolean parameter indicating whether the intercept term should be spatially varying (TRUE) or not (FALSE).

nuls

A vector of null parameters, default NULL

config_beta

name of the type of spatial pattern of Beta coefficients

config_snr

a value of signal noise ratio

config_eps

name of the distribution of error ('normal','unif' or 'Chi2')

ratiotime

multiplicating factor, for spacetime DGP.

Examples

Run this code
# \donttest{
 library(mgwrsar)
 library(ggplot2)
 library(gridExtra)
 library(grid)
 simu=simu_multiscale(1000)
 mydata=simu$mydata
 coords=simu$coords
 p1<-ggplot(mydata,aes(x,y,col=Beta1))+geom_point() +scale_color_viridis_c()
 p2<-ggplot(mydata,aes(x,y,col=Beta2))+geom_point() +scale_color_viridis_c()
 p3<-ggplot(mydata,aes(x,y,col=Beta3))+geom_point() +scale_color_viridis_c()
 p4<-ggplot(mydata,aes(x,y,col=Beta4))+geom_point() +scale_color_viridis_c()
 grid.arrange(p1,p2,p3,p4,nrow=2,ncol=2, top = textGrob("DGP Geniaux (2024)"
 ,gp=gpar(fontsize=20,font=3)))
# }

Run the code above in your browser using DataLab