我想运行一个应用函数,该函数使用具有越来越多数据的不同多变量GARCH模型。要运行GARCH模型,我需要运行cgarchspec
函数来确定之后我将适合的变量数。出于某种原因,以下apply
功能不起作用
library(rmgarch)
func.garch.i <- function(x) {
cgarch11spec.loop <- cgarchspec(uspec =multispec(replicate(x,garch11.spec)), VAR = TRUE, robust = FALSE, lag = 1, lag.max = NULL,
lag.criterion = c("AIC", "HQ", "SC", "FPE"), external.regressors = NULL,
robust.control = list(gamma = 0.25, delta = 0.01, nc = 10, ns = 500),
dccOrder = c(1, 1), asymmetric = FALSE,
distribution.model = list(copula = c("mvnorm"),
method = c("Kendall"), time.varying = TRUE,
transformation = c("parametric")),
start.pars = list(), fixed.pars = list())
}
nb <- seq(2,3)
apply(nb, func.garch.i(x))
参数garch11.spec
被定义为:
garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)),
variance.model = list(garchOrder = c(1,1),
model = "sGARCH"),
distribution.model = "norm")
但是,如果我尝试运行func.garch.i(2)
,那么效果很好...为什么函数在apply
函数中不起作用?
答案 0 :(得分:0)
对于那些可能遇到同样问题的人,我终于找到了解决方案。必须先隔离并计算函数<Card@ImageButton>:
size_hint: 0.8,0.8
pos_hint: {'x':0, 'y':0.1}
on_press: print('confirming press')
on_press: root.main_pop.open()
<PlayMatWidget>:
id: PlayMat
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'tron1.png'
StackLayout:
id: OppHand
size_hint: 0.6, 0.1
pos_hint: {'x':0.2,'y': 0.9}
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'background.png'
StackLayout:
id: OppField
size_hint: 0.6, 0.4
pos_hint: {'x':0.2, 'y':0.5}
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'background.png'
StackLayout:
id: cards
size_hint: 0.6,0.4
pos_hint: {'x':0.2, 'y':0.1}
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'background.png'
AnchorLayout:
id: PlayerFieldAnchor
anchor_x: 'center'
anchor_y: 'center'
size_hint: 0.6,0.4
pos_hint: {'x':0.2, 'y':0.1}
canvas.before:
Rectangle:
size: self.size
pos: self.pos
source: 'background.png'
BoxLayout:
id: PlayerField
orientation: 'horizontal'
StackLayout:
id: PlayerHand
orientation: 'lr-tb'
size_hint: 0.6,0.1
pos_hint: {'x': 0.2, 'y':0}
canvas:
Rectangle:
size: self.size
pos: self.pos
source: 'background.png'
ImageButton:
id: PlayerDeck
source: 'cardback.png'
size_hint: 0.15, 0.15
pos_hint: {'x':0.025,'y':0.05}
on_press: root.draw()
:
multispec