-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclimate_data.R
61 lines (50 loc) · 1.75 KB
/
climate_data.R
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
61
# low rank completion test case goes bonk. what's up with this'
library(longpca)
load(file = "~/data_peeks/embed2/month_dat.RData")
im = make_interaction_model(mean_val~(id&element)*(year&month),
month_dat,
duplicates = "average")
A = get_Incomplete_Matrix(im)
dim(A)
library(softImpute)
s = softImpute(A, rank.max = 5, type = "svd")
pcs = s_2_pc(im, s, "pc")
dat = pcs$column_features %>%
arrange(year, as.numeric(month)) %>%
filter(degree > 50) %>%
mutate(date = lubridate::make_date(year, month))
dat %>%
select(date, val = pc_1_columns) %>%
ggplot(aes(x = date, y = val)) + geom_line()
# this looks better..
im_p = make_interaction_model(mean_val~(id)*(year&month),
month_dat %>% filter(element == "PRCP"),
duplicates = "average")
Ap = get_Incomplete_Matrix(im_p)
dim(Ap)
library(softImpute)
sp = softImpute(Ap, rank.max = 5, type = "svd")
pcs = s_2_pc(im_p, sp, "pc")
dat = pcs$column_features %>%
arrange(year, as.numeric(month)) %>%
filter(degree > 50) %>%
mutate(date = lubridate::make_date(year, month))
dat
dat %>%
select(date, val = pc_1_columns) %>%
ggplot(aes(x = date, y = val)) + geom_line()
im_t = make_interaction_model(mean_val~(id)*(year&month),
month_dat %>% filter(element == "TMAX"),
duplicates = "average")
At = get_Incomplete_Matrix(im_t)
dim(At)
st = softImpute(At, rank.max = 5, type = "svd")
pcs = s_2_pc(im_t, st, "pc")
dat = pcs$column_features %>%
arrange(year, as.numeric(month)) %>%
filter(degree > 50) %>%
mutate(date = lubridate::make_date(year, month))
dat
dat %>%
select(date, val = pc_3_columns) %>%
ggplot(aes(x = date, y = val)) + geom_line()