【发布时间】:2012-12-11 07:57:56
【问题描述】:
require(fracdiff)
#load your data, n is the sample size
x<-matrix(scan("data.txt", n = ), n, 1, byrow = TRUE)
x<-log(x)
x<-x-mean(x)
n<-length(x)
#select the truncation
m<-round(n^(0.7))
perdx<-px[2:n]
fn<-function(h)
{
lambda<-freq[1:m]^(2*h-1)
Gh=mean(perdx[1:m]*lambda)
Rh=log(Gh)-(2*h-1)*mean(log(freq[1:m]))
return(Rh)
}
est<-optimize(fn,c(0,1.5),tol = 0.00001)
hhat<-est$minimum
b <- hhat-0.5
b
我有这个用 R 编写的函数,我想为 m 做循环,其中 m
【问题讨论】:
-
请make the example reproducible 提供
freq和perdx。 -
-1 因为 1) 这仍然无法重现; 2)有人(我)回答后,您更改了问题的参数; 3) 为什么
require(fracdiff)?代码中的每个函数都在base.