Hi all,

Got a few inquiries for data, thank you.

I attach code and data below. Copy it to your R script and it should be
runnable.

Now the Snorm with skew = 1 does have same result with Norm (for this set of
data). But all other innovations still got same coefficients.

Thank you,

Tian

#GARCH analysis of monthly return
rm(list=ls(all=TRUE))

logr <- c(0.0107098575567282, 0.0238439568947517, 0.0170914961728296,
0.0138732445655177, -0.00210495583051609, -0.00709127573708259,
-0.0385827936083661, 0.00490449365266998, 0.00385685394698455,
-0.00672488595832236, 0.0179700812080439, -0.00813073003671577,
0.0274033576545142, -0.0250778743362483, -0.000252972595615477,
-0.0184633479948336, 0.0281585718422547, -0.00732056749937242,
0.0223343433626314, -0.0274913993701448, -0.0264806322770031,
0.0115490548518633, -0.0327936279909903, 0.0247646111707177,
0.0306908994386586, 0.00673907585573934, 0.00214245677973209,
-0.00489315945076054, -0.0420701182378048, 0.0106513092268381,
0.00483314418308997, -0.0241112735170185, -0.0236721006924634,
0.00495722080665149, 0.00995100224049281, 0.0423410192839968,
-7.4654666429242e-05, 0.0463263884424721, -0.0191941125904601,
0.0105374637681618, 0.00891562645629928, 0.00408074598837779,
0.0424677854668133, 0.0707494700070023, 0.00114499423035526,
-0.0243277242813142, -0.0349753736938974, -0.0694071571523498,
0.0483227046536378, 0.0757365410062828, -0.123739048470341, -
0.00230833563215873,
-0.0894777518603734, -0.0823922232983805, -0.0163008223196004,
-0.0705625628068879, 0.028902196230284, -0.0281627666976421,
-0.0228742536894077, 0.000367412011421635, 0.0653064704108988,
0.0107593083066410, -0.0924344952694643, -0.0734334859099414,
-0.0179761012283746, -0.0325320322718984, -0.00210059232386598,
0.066829130533506, -0.0735364239526057, -0.104008970439016,
0.0268723664276674,
-0.00313268679975119, -0.0906340137330617, -0.0121396649961373,
-0.0621441723072229, 0.0517502775657374, -0.0236541332868366,
0.0164737511342563, -0.029336578252438, -0.0384578572805523,
0.0851459320997492, -0.0274909426329228, -0.0594227029752583,
0.0490549196316311, 0.0117045927385518, 0.0534838867245415, -
0.036145147104809,
-0.0134516584002713, -0.0397486953757553, 0.0458303597691911,
-0.0324653458761952, 0.0300639359263621, 0.0308827205446822,
-0.0399929706878522, 0.0330129512566845, 0.0476656477094465,
0.0502661919846773, 0.0700555274728492, 0.0533484191777131, -
0.164763950096769,
-0.0188612611651085, 0.0315025148659792, -0.026183523443084,
0.00185764564623504, 0.0415605496104671, 0.0609005489249022,
0.00292109288076270, 0.00843129126020518, 0.0364435424654694,
-0.0422639215772581, 0.0446111390279706, -0.0663607453035695,
0.0680648616436016, 0.0353571745939384, 0.0497475635284525,
0.0495856850474945,
-0.0507265004938753, -0.00126783225527763, 0.052332767500398,
-0.0289178666588803, 0.0636310849271901, 0.0185883019590537,
0.0456074218283171, 0.0114612960614454, -0.0540054008094362,
-0.00492372717398046, 0.0154182797009216, 0.0061641662077013,
0.000707504517465771, -0.000268063662287813, 0.0249188086513136,
0.0101155993444056, 0.0330509893647089, -0.0121696993613180,
0.0321366073123792, -0.00749818182068220, 0.0241037519137133,
0.013877482054341, 0.0284900964619952, 0.0203986640653641,
0.0197845872016367,
0.0282608312416226, 0.0168097602528238, 0.00504624695886614,
-0.047483970806859, 0.0134418482374845, -0.0344232233373743,
0.0297312626164135, 0.0238263428912005, -0.0343340943399759,
0.00514305696494622, 0.00428675908876259, -0.0540037546954394,
-0.0376835393117851, 0.0248059444691968, 0.00286271109440267,
-0.0201726197962942, 0.0120294090576544, -0.0172160135048806,
0.0266745775509609, -0.0125191786357240, -0.00642292839233706,
0.0152853839659078, -0.0329232528272489, 0.0113467545039784,
0.00325116163241795, -0.000156615943755373, 0.00287917888713352,
0.0226350405134303, -0.00507382415825686, 0.00188653413193280,
-0.0314680606930909, 0.0314404828152606, -0.0246891655066154,
-0.00621437278185084, 0.0203328943393480, -0.0292515600983759,
0.00236594272243002, -0.0273027918584042, 0.0986116252116223,
-0.0520744999798322, 0.00458681078225353, -0.0265072106468637,
0.0122803714060437, 0.036704412456513, -0.0562553901943863,
0.0307005847712896,
-0.00685811877481276, 0.0147820750313374, 0.0579365372444414,
0.0335011692685766, 0.0173466769183716, 0.0510289606341445, -
0.0138986659133316,
-0.0597185581683447, -0.106240705003888, -0.0124147403601571,
-0.0161039038326663, 0.0808230314002266, -0.0344330483221435,
0.0167876627118019, 0.00132482639172523)

hist(logr, freq = F, ylim = c(0, 13), breaks = 'FD')

norm_fit <- normFit(logr)
curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add = TRUE,
col=2)

t_fit <- stdFit(logr)
curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15, add =
TRUE, col=6)

snorm_fit <- snormFit(logr)
curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]), -.25,
.15, add = TRUE, col=4)

st_fit <- sstdFit(logr)
curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3], st_fit$est[4]),
-.25, .15, add = TRUE, col=3)

legend('topleft', '---Normal', text.col = 'red', bty = 'n')
legend('topleft', '---Student t', text.col = 6, bty = 'n', inset = c(0,
.05))
legend('topleft', '---Skew Normal', text.col = 'blue', bty = 'n', inset =
c(0, .1))
legend('topleft', '---Skew t', text.col = 'green', bty = 'n', inset = c(0,
.15))

library(fSeries)

#normal innovation
garch_norm <- garchFit(series = logr, include.mean = F)

#skew normal innovation
garch_snorm1 <- garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, skew = snorm_fit$est[3], include.skew = T)

#t inovation
garch_t <- garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
include.shape = T)
garch_t1 <- garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
shape = t_fit$est[3], include.shape = T)

#skew t innovation
garch_st <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
include.skew = T, include.shape = T)
garch_st1 <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T, include.shape= T)
garch_st2 <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = F, include.shape= F)
garch_st3 <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3])
garch_st4 <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F)

plot_sd <- function(x, ylim = null, col = null, ...) {
        xcsd = x@sigma.t
        plot(xcsd, type = "l", col = col, ylab = "x",
            main = "Conditional SD", ylim = ylim)
        abline(h = 0, col = "grey", lty = 3)
        grid()
}

plot_sd(garch_norm, ylim = c(0.02, 0.13), col = 2)
xcsd = garch_t@sigma.t
lines(xcsd, col = 3)

legend('topleft', '---Normal innovation', text.col = 'red', bty = 'n', inset
= c(0, .05))
legend('topleft', '---Skew innovation', text.col = 'green', bty = 'n', inset
= c(0, .1))

On 11/22/06, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:

> As a courtesy to others you might summarize the responses to the list.
> Also,
> I suggest you also include the data by issuing the command:
>
>   dput(x, control = "all") # x is your data
>
> and pasting its result into your post so others can reproduce
> what you have done.
>
> On 11/22/06, T Mu <muster@gmail.com > wrote:
> > Hi all,
> >
> > Thank you for responses. If any one need the data, I can email it to
> you. I
> > don't think I can attach it to R-help. It is only S&P 500 monthly
> returns I
> > downloaded from Yahoo finance, with only date and adj. close kept.
> >
> > Thank you,
> >
> > Tian
> >
> >
> > On 11/22/06, T Mu <muster@gmail.com> wrote:
> > >
> > > Hi all,
> > >
> > > I post it on both r-help and r-finance since I don't know where is
> most
> > > appropriate for this topic. Sorry if it bothers you.
> > >
> > > I did garch fitting on S&P500 monthly returns with garchFit from
> fSeries.
> > > I got same coefficients from all cond.dist except normal. I thought
> that
> > > is probabaly usual for the data. But when I play with it, I got
> another
> > > question.
> > >
> > > I plot skew normal with skew = 1 and a standard normal, they overlap
> > > eachother, so I think they are the same. Skew = 1 means no skewness (I
> can
> > > not find the paper defining the distribution).
> > >
> > > library(fSeries)
> > > curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #skew normal
> with
> > > skew 1
> > > curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal
> > >
> > > Then I try them as innovations,
> > >
> > > #normal innovation
> > > garch_norm <- garchFit(series = logr, include.mean = F)
> > >
> > > #skew normal innovation
> > >
> > > #this line do not include skew, so it got same result as normal
> > > garch_snorm <- garchFit(series = logr, cond.dist = 'dsnorm',
> include.mean= F,
> > > include.skew = F)
> > >
> > > #this line includes skew, but use default skew = 1, and it got results
> > > different from normal, which I don't understand
> > >
> > > garch_snorm <- garchFit(series = logr, cond.dist = 'dsnorm',
> include.mean= F,
> > > include.skew = T)
> > >
> > > Have I done something wrong? I am attaching the code, thank you.
> > >
> > > Tian
> > >
> > > #GARCH analysis of monthly return
> > > rm(list=ls(all=TRUE))
> > > sp500 <- read.csv('s&p_m90.csv', header=TRUE)
> > > sp500 <- sp500[,2] #only adjusted close
> > > n <- length(sp500)
> > >
> > > logr <- log(sp500[1:n-1] / sp500[2:n])
> > > acf(logr)
> > > ar5 <- arima(logr, order = c(5, 0, 0), include.mean = T)
> > > logr<- ar5$res
> > > acf(logr)
> > >
> > > #fit GARCH distribution
> > > hist(logr, freq = F, ylim = c(0, 12), breaks = 'FD')
> > >
> > > norm_fit <- normFit(logr)
> > > curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add =
> TRUE,
> > > col=2)
> > >
> > > t_fit <- stdFit(logr)
> > > curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15,
> add =
> > > TRUE, col=6)
> > >
> > > snorm_fit <- snormFit(logr)
> > > curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]),
> > > -.25, .15, add = TRUE, col=4)
> > >
> > > st_fit <- sstdFit(logr)
> > > curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3],
> > > st_fit$est[4]), -.25, .15, add = TRUE, col=3)
> > >
> > > library(fSeries)
> > >
> > > #normal innovation
> > > garch_norm <- garchFit(series = logr, include.mean = F)
> > >
> > > #t inovation
> > > garch_t <- garchFit(series = logr, cond.dist = 'dstd', include.mean =
> F,
> > > include.shape = T)
> > > garch_t1 <- garchFit(series = logr, cond.dist = 'dstd', include.mean =
> F,
> > > shape = t_fit$est[3], include.shape = T)
> > >
> > > #skew normal innovation
> > > garch_snorm <- garchFit(series = logr, cond.dist = 'dsnorm',
> include.mean= F,
> > > include.skew = T)
> > > garch_snorm1 <- garchFit(series = logr, cond.dist = 'dsnorm',
> include.mean= F, skew = snorm_fit$est[3],
> > > include.skew = T)
> > >
> > > #skew t innovation
> > > garch_st <- garchFit(series = logr, cond.dist = 'dsstd', include.mean= F,
> > > include.skew = T, include.shape = T)
> > > garch_st1 <- garchFit(series = logr, cond.dist = 'dsstd', include.mean=
> > > F, skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T,
> > > include.shape = T)
> > >
> > > vix <- read.csv('D:/Documents and Settings/Mu Tian/Desktop/8780/8780
> > > project/vix_m.csv', header=TRUE)
> > > vix <- (vix[,2]/100) / (12^.5)
> > >
> > > plot_sd <- function(x, ylim = null, col = null, ...) {
> > >         xcsd = x@sigma.t
> > >         plot(xcsd, type = "l", col = col, ylab = "x",
> > >             main = "Conditional SD", ylim = ylim)
> > >         abline(h = 0, col = "grey", lty = 3)
> > >         grid()
> > > }
> > >
> > > plot_sd(garch_norm, ylim = c( 0.02, 0.13), col = 2)
> > > xcsd = garch_t@sigma.t
> > > lines(xcsd, col = 3)
> > > lines(1:n, vix)
> > >
> > > #predict
> > > predict(garch_norm)
> > > predict(garch_t)
> > >
> > > #demonstration of skew distributions
> > > #skew normal
> > > curve(dsnorm(x, 0, 1, .1), -2, 2, add = F, col = 'green')
> > > curve(dsnorm(x, 0, 1, snorm_fit$est[3]), type = 'l', col = 'blue', add
> =
> > > T)
> > > curve(dsnorm(x, 0, 1, 1), -2, 2, add = T, col = 'red') #normal
> > >
> > > #skew t
> > > curve(dsstd(x, 0, 1, 4, 1), -2, 2, add = F, col = 'red')
> > > curve(dsstd(x, 0, 1, st_fit$est[3], st_fit$est[4]), type = 'l', col =
> > > 'blue', add = T)
> > > curve(dsstd(x, 0, 1, 100, .5), -2, 2, add = T, col = 'green')
> > >
> > > #t
> > > curve(dstd(x, 0, 1, 4), -2, 2, add = T, col = 'red')
> > > curve(dstd(x, 0, 1, t_fit$est[3]), type = 'l', col = 'blue', add = T)
> > > curve(dstd(x, 0, 1, 100), -2, 2, add = T, col = 'green')
> > >
> > > curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #normal
> > > curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal
> > > curve(dsnorm(x, 0, 1, .1), -2, 2, add = T, col = 'green') #normal
> > >
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

	[[alternative HTML version deleted]]

