Skip to content

Commit 41b5d14

Browse files
committed
version 4.2
2 parents 1c44539 + a3e2658 commit 41b5d14

File tree

3 files changed

+40
-32
lines changed

3 files changed

+40
-32
lines changed

R/MCM.sde.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ print.MCM.sde <- function(x, digits=NULL, ...)
281281
if (length(index) > 1) {
282282
index <- index[1]
283283
warning("The first element of 'index' will be used")}
284-
if (index > dim(data)[1] | index < 1 ) stop("Subscript out of bounds")
284+
if (index > dim(data)[1] | index < 1 )
285+
stop("Subscript out of bounds")
285286
#if (is.null(x$call$names)) {name <- paste("t",1:dim(data)[1],"*",sep="")}else{
286287
#name <- sapply(2:length(x$call$names),function(i) x$call$names[[i]])}
287288
type <- match.arg(type)

tests/MCM_test.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
options(prompt="R> ",scipen=16,digits=4,warning=FALSE, message=FALSE)
22
library(Sim.DiffProc)
33

4-
4+
RNGkind(kind="L'Ecuyer-CMRG")
55
######
66

77
theta = 0.75; x0 = 1
@@ -20,6 +20,8 @@ sde.fun1d <- function(data, i){
2020
return(c(mean(d),var(d)))
2121
}
2222
# Parallel MOnte Carlo for mod1
23+
mcm.mod1 = MCM.sde(model=mod1,statistic=sde.fun1d,R=5, exact=list(m=E.mod1(1),S=V.mod1(1)))
24+
mcm.mod1 = MCM.sde(model=mod1,statistic=sde.fun1d,R=5, exact=list(m=E.mod1(1),S=V.mod1(1)),parallel="snow",cl= parallel::makeCluster(getOption("cl.cores", 2)),ncpus=2)
2325
mcm.mod1 = MCM.sde(model=mod1,statistic=sde.fun1d,R=5, exact=list(m=E.mod1(1),S=V.mod1(1)),parallel="snow",ncpus=2)
2426
print(mcm.mod1)
2527
# Parallel MOnte Carlo for mod2
@@ -55,6 +57,8 @@ sde.fun2d <- function(data, i){
5557
return(c(mean(d$x),mean(d$y),var(d$x),var(d$y),cov(d$x,d$y)))
5658
}
5759
## Parallel Monte-Carlo of 'OUI' at time 10
60+
mcm.mod2d = MCM.sde(OUI,statistic=sde.fun2d,time=10,R=5,exact=tvalue)
61+
mcm.mod2d = MCM.sde(OUI,statistic=sde.fun2d,time=10,R=5,exact=tvalue,parallel="snow",cl= parallel::makeCluster(getOption("cl.cores", 2)),ncpus=2)
5862
mcm.mod2d = MCM.sde(OUI,statistic=sde.fun2d,time=10,R=5,exact=tvalue,parallel="snow",ncpus=2)
5963
print(mcm.mod2d)
6064
plot(mcm.mod2d)
@@ -94,6 +98,8 @@ sde.fun3d <- function(data, i){
9498
return(c(mean(d$x),median(d$x),Mode(d$x),var(d$x),cov(d$x,d$y),cov(d$x,d$z)))
9599
}
96100
## Monte-Carlo at time = 10
101+
mcm.mod3d = MCM.sde(modtra,statistic=sde.fun3d,R=5)
102+
mcm.mod3d = MCM.sde(modtra,statistic=sde.fun3d,R=5,parallel="snow",cl= parallel::makeCluster(getOption("cl.cores", 2)),ncpus=2)
97103
mcm.mod3d = MCM.sde(modtra,statistic=sde.fun3d,R=5,parallel="snow",ncpus=2)
98104
print(mcm.mod3d)
99105
plot(mcm.mod3d)
@@ -113,4 +119,5 @@ sde.fun3d <- function(data, i){
113119
mcm.mod3d = MCM.sde(modtra,statistic=sde.fun3d,R=5,parallel="snow",ncpus=2)
114120
print(mcm.mod3d)
115121
plot(mcm.mod3d)
122+
plot(mcm.mod3d,index=c(1,7))
116123

tests/snssde_test.R

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
options(prompt="R> ",scipen=16,digits=4,warning=FALSE, message=FALSE)
1+
options(prompt="R> ",scipen=16,digits=8,warning=FALSE, message=FALSE)
22
library(Sim.DiffProc)
33

44

@@ -42,7 +42,7 @@ plot(mod1[[1]],type="n",plot.type="single")
4242
lines(mod1[[1]],col=2,lwd=2)
4343
points(mod1[[1]],pch=21,col=5,cex=0.5)
4444

45-
s = 0.05547
45+
s = 0.0554747
4646
mean(mod1[[1]], at = s)
4747
moment(mod1[[1]], at = s , center = TRUE , order = 2) ## variance
4848
Median(mod1[[1]], at = s)
@@ -167,7 +167,7 @@ moment(mod3[[1]], at = s , center= FALSE , order = 4)
167167
bconfint(mod3[[1]], at =s)
168168

169169
#############################
170-
170+
s= 0.00458
171171
f <- expression( 2*(1-x) )
172172
g <- expression( 1 )
173173

@@ -176,15 +176,15 @@ plot(mod1,type="n")
176176
lines(mod1,col=2)
177177
points(mod1,cex=0.1,pch=19)
178178

179-
mean(mod1)
180-
moment(mod1, center = TRUE , order = 2) ## variance
181-
Median(mod1)
182-
quantile(mod1)
183-
kurtosis(mod1)
184-
skewness(mod1)
185-
cv(mod1)
186-
min(mod1)
187-
max(mod1)
179+
mean(mod1,at = s)
180+
moment(mod1,at = s, center = TRUE , order = 2) ## variance
181+
Median(mod1,at = s)
182+
quantile(mod1,at = s)
183+
kurtosis(mod1,at = s)
184+
skewness(mod1,at = s)
185+
cv(mod1,at = s)
186+
min(mod1,at = s)
187+
max(mod1,at = s)
188188

189189

190190
####
@@ -199,15 +199,15 @@ lines(mod2,col=2)
199199
points(mod2,cex=0.1,pch=19)
200200
plot2d(mod2)
201201

202-
mean(mod2)
203-
moment(mod2, center = TRUE , order = 2) ## variance
204-
Median(mod2)
205-
quantile(mod2)
206-
kurtosis(mod2)
207-
skewness(mod2)
208-
cv(mod2)
209-
min(mod2)
210-
max(mod2)
202+
mean(mod2,at = s)
203+
moment(mod2,at = s, center = TRUE , order = 2) ## variance
204+
Median(mod2,at = s)
205+
quantile(mod2,at = s)
206+
kurtosis(mod2,at = s)
207+
skewness(mod2,at = s)
208+
cv(mod2,at = s)
209+
min(mod2,at = s)
210+
max(mod2,at = s)
211211

212212
####
213213

@@ -221,14 +221,14 @@ lines(mod3,col=2)
221221
points(mod3,cex=0.1,pch=19)
222222
plot3D(mod3,display="rgl")
223223

224-
mean(mod3)
225-
moment(mod3, center = TRUE , order = 2) ## variance
226-
Median(mod3)
227-
quantile(mod3)
228-
kurtosis(mod3)
229-
skewness(mod3)
230-
cv(mod3)
231-
min(mod3)
232-
max(mod3)
224+
mean(mod3,at = s)
225+
moment(mod3,at = s, center = TRUE , order = 2) ## variance
226+
Median(mod3,at = s)
227+
quantile(mod3,at = s)
228+
kurtosis(mod3,at = s)
229+
skewness(mod3,at = s)
230+
cv(mod3,at = s)
231+
min(mod3,at = s)
232+
max(mod3,at = s)
233233

234234

0 commit comments

Comments
 (0)