-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTEST_PH.R
More file actions
53 lines (26 loc) · 1.02 KB
/
Copy pathTEST_PH.R
File metadata and controls
53 lines (26 loc) · 1.02 KB
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
source("C:/Users/aper/Documents/PH.R")
###############################################################################################################################################################
#Test
obj <- PH(alpha=c(0.2,0.3,0.5),S=matrix(c(-1,0,0,0.2,-1,0,0,0.3,-2),nrow=3))
obj
y <- 1:100
weights <- dexp(1:100,1/10)
obj <- fit(obj,y,weights,100,every=10,scale=1)
obj2 <- ph(alpha=c(0.2,0.3,0.5),S=matrix(c(-1,0,0,0.2,-1,0,0,0.3,-2),nrow=3))
obj2 <- fit(obj2,y,weight=weights,stepsEM=100)
plot(y,weights/sum(weights))
curve(dens(obj,x),add=T,col='red')
curve(dens(obj2,x),add=T,col="green")
plot(obj)
obj3 <- PH(structure = "erlang généralisée",dimension=4)
y <- 1:500
weights <- dgamma(1:500,3,1/25)
obj3 <- fit(obj3,y,weights,1000,every=100)
plot(obj3)
obj4 <- pmle(obj3)
plot(obj4)
#benchmark
library(microbenchmark)
bench <- microbenchmark(fit(obj,y,weights,stepsEM=10),fit(obj2,y,weight=weights,stepsEM=10,every=10))
bench
plot(bench)