hyperbPi
πsummary
hyperbFit
V a r(X)= S E(X)2gα(ζ、π、δ)gβ(ζ、π、δ)αβ
gα(ζ、π、δ)gβ(ζ、π、δ)= ζ1 + π2−−−−−√δ= ζπδ
α∂∂ζgα(ζ、π、δ)∂∂πgα(ζ、π、δ)∂∂δgα(ζ、π、δ)= 1 + π2−−−−−√δ= πζ1 + π2−−−−−√δ= − 1 + π2−−−−−√ζδ2
β∂∂ζgβ(ζ、π、δ)∂∂πgβ(ζ、π、δ)∂∂δgβ(ζ、π、δ)= πδ= ζδ= - πζδ2
α
V R(α)≈ 1 + π2δ2⋅ V R(ζ)+ π2ζ2(1 + π2)δ2⋅ V R(π)+ (1 + π2)ζ2δ4⋅ V R(δ)+2 × [ πζδ2⋅ C O V(π、ζ)− (1 + π2)ζδ3⋅ C O V(δ、ζ)- πζ2δ3⋅ C O V(δ、π)]
β
V a r(β)≈ π2δ2⋅ V R(ζ)+ ζ2δ2⋅ V R(π)+ π2ζ2δ4⋅ V R(δ)+2 × [ πζδ2⋅ C O V(π、ζ)- π2ζδ3⋅ C O V(δ、ζ)- πζ2δ3⋅ C O V(π、δ)]
コーディング R
Dαβζ、π、δΣ3 × 3ζ、π、δvcov(my.hyperbFit)
my.hyperbFit
α
V R(α)≈ DαΣ D⊤α
β
ではR
、これは次のように簡単にコーディングできます。
#-----------------------------------------------------------------------------
# The row vector D of the partial derivatives for alpha
#-----------------------------------------------------------------------------
D.alpha <- matrix(
c(
sqrt(1+pi^2)/delta, # differentiate wrt zeta
((pi*zeta)/(sqrt(1+pi^2)*delta)), # differentiate wrt pi
-(sqrt(1+pi^2)*zeta)/(delta^2) # differentiate wrt delta
),
ncol=3)
#-----------------------------------------------------------------------------
# The row vector D of the partial derivatives for beta
#-----------------------------------------------------------------------------
D.beta <- matrix(
c(
(pi/delta), # differentiate wrt zeta
(zeta/delta), # differentiate wrt pi
-((pi*zeta)/delta^2) # differentiate wrt delta
),
ncol=3)
#-----------------------------------------------------------------------------
# Calculate the approximations of the variances for alpha and beta
# "sigma" denotes the 3x3 covariance matrix
#-----------------------------------------------------------------------------
var.alpha <- D.alpha %*% sigma %*% t(D.alpha)
var.beta <- D.beta %*% sigma %*% t(D.beta)
#-----------------------------------------------------------------------------
# The standard errors are the square roots of the variances
#-----------------------------------------------------------------------------
se.alpha <- sqrt(var.alpha)
se.beta <- sqrt(var.beta)
ログ(ζ)ログ(δ)
ζ∗= ログ(ζ)δ∗= ログ(δ)ζδ
gα(ζ∗、π、δ∗)gβ(ζ∗、π、δ∗)= exp(ζ∗)1 + π2−−−−−√exp(ζ∗)= exp(ζ∗)πexp(δ∗)
α∂∂ζ∗gα(ζ∗、π、δ∗)∂∂πgα(ζ∗、π、δ∗)∂∂δ∗gα(ζ∗、π、δ∗)= 1 + π2−−−−−√exp(- δ∗+ ζ∗)= πexp(- δ∗+ ζ∗)1 + π2−−−−−√= − 1 + π2−−−−−√exp(- δ∗+ ζ∗)
β∂∂ζ∗gβ(ζ∗、π、δ∗)∂∂πgβ(ζ∗、π、δ∗)∂∂δ∗gβ(ζ∗、π、δ∗)= πexp(- δ∗+ ζ∗)= exp(- δ∗+ ζ∗)= - πexp(- δ∗+ ζ∗)
αVar(α)≈(1+π2)exp(−2δ∗+2ζ∗)⋅Var(ζ∗)+π2exp(−2δ∗+2ζ∗)1+π2⋅Var(π)+(1+π2)exp(−2δ∗+2ζ∗)⋅Var(δ∗)+2×[πexp(−2δ∗+2ζ∗)⋅Cov(π,ζ∗)−(1+π2)exp(−2δ∗+2ζ∗)⋅Cov(δ∗,ζ∗)−πexp(−2δ∗+2ζ∗)⋅Cov(δ∗,π)]
βVar(β)≈π2exp(−2δ∗+2ζ∗)⋅Var(ζ∗)+exp(−2δ∗+2ζ∗)⋅Var(π)+π2exp(−2δ∗+2ζ∗)⋅Var(δ∗)+2×[πexp(−2δ∗+2ζ∗)⋅Cov(π,ζ∗)−π2exp(−2δ∗+2ζ∗)⋅Cov(δ∗,ζ∗)−πexp(−2δ∗+2ζ∗)⋅Cov(δ∗,π)]
R
2でのコーディング
sigma
ζ∗=log(ζ)δ∗=log(δ)ζδ
#-----------------------------------------------------------------------------
# The row vector D of the partial derivatives for alpha
#-----------------------------------------------------------------------------
D.alpha <- matrix(
c(
sqrt(1+pi^2)*exp(-ldelta + lzeta), # differentiate wrt lzeta
((pi*exp(-ldelta + lzeta))/(sqrt(1+pi^2))), # differentiate wrt pi
(-sqrt(1+pi^2)*exp(-ldelta + lzeta)) # differentiate wrt ldelta
),
ncol=3)
#-----------------------------------------------------------------------------
# The row vector D of the partial derivatives for beta
#-----------------------------------------------------------------------------
D.beta <- matrix(
c(
(pi*exp(-ldelta + lzeta)), # differentiate wrt lzeta
exp(-ldelta + lzeta), # differentiate wrt pi
(-pi*exp(-ldelta + lzeta)) # differentiate wrt ldelta
),
ncol=3)
#-----------------------------------------------------------------------------
# Calculate the approximations of the variances for alpha and beta
# "sigma" denotes the 3x3 covariance matrix with log(delta) and log(zeta)
#-----------------------------------------------------------------------------
var.alpha <- D.alpha %*% sigma %*% t(D.alpha)
var.beta <- D.beta %*% sigma %*% t(D.beta)
#-----------------------------------------------------------------------------
# The standard errors are the square roots of the variances
#-----------------------------------------------------------------------------
se.alpha <- sqrt(var.alpha)
se.beta <- sqrt(var.beta)