-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
151 lines (151 loc) · 5.42 KB
/
.Rhistory
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
install.packages("graph")
BiocManager::install("graph")
BiocManager::install("Rgraphviz")
source("~/Projects/NonergodicSD/ergodic.R")
summary(fit_inla2)
View(fit_inla2)
View(fit_inla2$summary)
View(fit_inla2)
cofit<-fit_inla2$summary.fitted.values$mean
cofit<-fit_inla2$summary.fitted.values$mean
cofit
cofit<-fit_inla2$summary.fixed.values$mean
cofit<-fit_inla2$summary.fixed$mean
matrix(cofit)
data<-matrix(nrow=length(df),length(cofit))
for (i in 1:length(df)){
data[i,]<-c(1, inladata[i,c(1:5)])
}
for (i in 1:length(df)){
data[i,]<-c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
}
data[i,]<-c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
for (i in 1:length(df)){
data[i,]<-c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
}
data<-matrix(nrow=length(df),ncol=length(cofit))
for (i in 1:length(df)){
data[i,]<-c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
}
y_pred<-cofit%*%data
size(cofit)
size(data)
cofit<-fit_inla2$summary.fixed$mean
size(cofit)
cofit<-fit_inla2$summary.fixed$mean
pred<-matrix(nrow=length(df),ncol=1)
for (i in 1:length(df)){
pred[i,]<-cofit %*% c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
}
View(y_pred)
tmp<-cbind(inladata$y,pred,y_pred$mean)
size(inladata$y)
size(pred)
pred<-matrix(nrow=length(inladata),ncol=1)
for (i in 1:length(inladata)){
pred[i,]<-cofit %*% c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
}
length(inladata)
row(inladata)
cofit<-fit_inla2$summary.fixed$mean
pred<-matrix(nrow=nrow(inladata),ncol=1)
for (i in 1:nrow(inladata)){
pred[i,]<-cofit %*% c(1, inladata[i,1],inladata[i,2],inladata[i,3],inladata[i,4],inladata[i,5])
}
tmp<-cbind(inladata$y,pred,y_pred$mean)
View(tmp)
for (i in 1:nrow(inladata)){
pred[i,]<-cofit %*% c(1, inladata[i,'M'],inladata[i,'M2'],inladata[i,'lnRef'],inladata[i,'R'],inladata[i,"lnvs"])
}
tmp<-cbind(inladata$y,pred,y_pred$mean)
View(tmp)
source("~/Projects/NonergodicSD/ergodic.R")
p0+p1+p2+p3+p4
p<-ggplot(tmp,aes(x=inladata$y,y=pred))+geom_point()
dev.off()
tmp<-data.frame(inladata$y,pred,y_pred$mean)
p<-ggplot(tmp,aes(x=inladata$y,y=pred))+geom_point()
p
p<-ggplot(tmp,aes(x=inladata$y,y=pred))+geom_point(color='black')+geom_abline(intercept = 0, slope=1, color='red')
p
dS <- deltaS$`0.5quant`
p1<-ggplot(tmp,aes(x=inladata$y,y=pred))+geom_point(color='black')+geom_abline(intercept = 0, slope=1, color='red')
p2<-ggplot(tmp,aes(x=inladata$y,y=y_pred$mean))+geom_point(color='black')+geom_abline(intercept = 0, slope=1, color='red')
p1+p2
#create list
eqlist<-list(df_plot[,c('M','q50')])
#create list
df_plot[,c('M','q50')]
View(df_plot)
dE <- deltaB$`0.5quant`
df_E<-data.frame(dataM,dE)
p0<-ggplot(df_E,aes(x=dataM,y=dE))+geom_point()+
stat_summary_bin(bins=10,color='red',width=1,geom='errorbar',fun.min=~quantile(.x,probs = .25),fun.max=~quantile(.x,probs = .75))+
stat_summary_bin(bins=10,color='red',geom='point',fun=median,size=4)
eqlist<-list(df_E)
library(Dict)
#create list
eqdic<-Dict$new()
#create list
eqdic<-Dic$new([])
cofit<-fit_inla2$summary.fixed$mean
pred<-matrix(nrow=nrow(inladata),ncol=1)
event_term<-matrix(nrow=nrow(inladata),ncol=1)
site_term<-matrix(nrow=nrow(inladata),ncol=1)
for (i in 1:nrow(inladata)){
pred[i,]<-cofit %*% c(1, inladata[i,'M'],inladata[i,'M2'],inladata[i,'lnRef'],inladata[i,'R'],inladata[i,"lnvs"])
event_term[i,]<-dE[eq_id[i]]
site_term[i,]<-dS[sta_id[i]]
}
tmp<-data.frame(inladata$y,pred,event_term,site_term,y_pred$mean)
View(tmp)
pred_fixed=pred+event_term+site_term
tmp<-data.frame(inladata$y,pred,event_term,site_term,y_pred$mean,pred_fixed)
dev.off()
ggplot(tmp,aes(x=y_pred$mean,y=pred_fixed))+geom_point()+geom_abline(intercept = 0,slope = 1,color='red')
ggplot(tmp,aes(x=pred,y=pred_fixed))+geom_point()+geom_abline(intercept = 0,slope = 1,color='red')
pred_all<-pred+event_term+site_term
pred_fixed<-y_pred$mean-event_term-site_term
tmp<-data.frame(inladata$y,pred,event_term,site_term,y_pred$mean,pred_all,pred_fixed)
ggplot(tmp,aes(x=pred,y=pred_fixed))+geom_point()+geom_abline(intercept = 0,slope = 1,color='red')
total_resid = inladata$y - pred_fixed
ggplot(as.data.frame(M,total_resid),aes(x=M,y=total_resid))+geom_point()
sig=event[,'SD']
event2<-df_flatfile %>% group_by(eqid) %>% filter(row_number()==1)
sig=event2[,'SD']
ggplot(as.data.frame(dE,sig),aes(x=dE,y=sig))+geom_point()
df_plot<-data.frame(dE,sig)
ggplot(df_plot,aes(x=dE,y=sig))+geom_point()
sig=event2$SD
df_plot<-data.frame(dE,sig)
ggplot(df_plot,aes(x=dE,y=sig))+geom_point()
library("ggpubr")
ggscatter(df_plot, x = "dE", y = "sig",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "Event Term", ylab = "Stress Drop")
res <- cor.test(df_plot$dE, df_plot$sig,
method = "pearson")
res
ggscatter(df_plot, x = "dE", y = "sig",
add = "reg.line", conf.int = FALSE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "Event Term", ylab = "Stress Drop")
source("~/Projects/NonergodicSD/ergodic.R")
source("~/Projects/NonergodicSD/ergodic.R")
source("~/Projects/NonergodicSD/ergodic.R")
dE<-df_flatfile$qPGA
df_plot<-data.frame(dE,sig)
df_plot<-data.frame(dE_trugman,sig)
dE_trugman<-event2$qPGA
df_plot<-data.frame(dE_trugman,sig)
p2<-ggscatter(df_plot, x = "dE_trugman", y = "sig",
add = "reg.line", conf.int = FALSE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "Event Term", ylab = "Stress Drop")
p1+p2
res
df_plot<-data.frame(dE_trugman,sig)
res <- cor.test(df_plot$dE_trugman, df_plot$sig,
method = "pearson")
res