-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
64 lines (45 loc) · 1.47 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# wcshapes
The goal of wcshapes is to make spatial lagging with country-year but also other panel data easier.
Goals, basically none implemented yet:
- make a spatial lagger function that plays nicely with sf tibbles
- integrate cshapes data to make spatial lagging with country-year-like data easier
- a country-year spatial lagger solution that respects changes in state-system membership / aka unbalanced panels
- add multiple spatial weight options (see #1)
- add W normalization options (see #2)
## Installation
``` r
library("remotes")
install_github("andybega/wcshapes")
```
NOPE NOT YET:
You can install the released version of wcshapes from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("wcshapes")
```
## Example
```{r}
library("wcshapes")
library("sf")
library("ggplot2")
data("est_adm1")
est_adm1$x <- as.integer(est_adm1$NAME_1 == "Harju")
w0 <- w_dist_power(st_geometry(est_adm1), alpha = .5)
w1 <- w_dist_power(st_geometry(est_adm1), alpha = 1)
w2 <- w_dist_power(st_geometry(est_adm1), alpha = 2)
est_adm1$x_sl0 <- as.numeric(w0 %*% est_adm1$x)
est_adm1$x_sl1 <- as.numeric(w1 %*% est_adm1$x)
est_adm1$x_sl2 <- as.numeric(w2 %*% est_adm1$x)
plot(est_adm1[, c("x", "x_sl0", "x_sl1", "x_sl2")])
```