Hi Alexios,

Thanks a lot for your reply and also your enormous effort on the development of this pakage.

1. I see the reason now: I forgot to reset the specification in each step of the loop.
    Hope others who see this wont make such mistake anymore.

2. Really appreciate that, I guess I should just use
    myfit = ugarchfit(spec,  logexr[(i*refit.every):(fitindx.start[i]+refit.every)], out.sample =  refit.every, solver.control=list())
    ldpx=length(dpx)
    ugarchforecast(myfit, n.ahead=1, external.forecasts = list(mregfor = dpx[ ldpx], vregfor = dpx[ ldpx ]) )
    # where dpx[ldpx] is the last element of dpx which is already supplied to R when out.sample =1

Thank you again.

Best regards
Guoshi




At 2012-05-24 04:05:55,"alexios ghalanos" <alexios@4dscape.com> wrote:
>Hi Guoshi,
>
>1.
>#################################
># part of the code is straight out of the 'rugarch-rolling.R' file
># which I suggest you take a closer look at.
>forecast.length = 400
>refit.every = 1
>n.ahead = 1
># your data size
>T = 750
>fwindex = t(rugarch:::.embed((T - forecast.length - n.ahead + 2):T, 
>refit.every, by = refit.every, TRUE ) )
>fitindx.start = c(fwindex[1,]-1)
>fwindex.end = fwindex[refit.every,]
>nf = length(fwindex.end)
>forecast.length = floor(forecast.length/refit.every) * refit.every
>####################################
>
># Do 10 fits to convince yourself it is the same:
>
>lik = rep(0, 10)
>for(i in 1:10){
>dpx =  matrix(dp[(i*refit.every):(fitindx.start[i]+refit.every)], ncol=1)
>spec = ugarchspec(variance.model = list(model = "eGARCH", garchOrder = 
>c(1,1),
>external.regressors =dpx ),
>mean.model = list(armaOrder=c(0,0), include.mean = T, 
>external.regressors = dpx), distribution.model = "norm");
>myfit = ugarchfit(spec, 
>logexr[(i*refit.every):(fitindx.start[i]+refit.every)], out.sample = 
>refit.every, solver.control=list())
>lik[i] = likelihood(myfit)
>}
>
># use your the 'uGARCHroll' object to compare:
>all.equal(lik, test@roll$LLH[1:10])
>[1] TRUE
>
>
>2. Correct. The rolling method does not take into account the presence 
>of external regressors...most likely an omission on my part which I'll 
>look to rectify during the next release. Do keep in mind that the 
>ugarchroll method is just a convenience wrapper for fitting/forecasting 
>with the existing methods.
>
>
>-Alexios
>
>
>
>On 23/05/2012 19:54, linpack wrote:
>> Hi there,
>>
>> I have two questions (which might be related).
>> I am trying to predict mean and variance of monthly stock excess return
>> using dividend price ratio with a eGarch model.
>>
>> Data format is the following
>> column 1 column 2 column 3
>> gross S&P return gross t-bill return lagged dividend price ratio
>> #data dimension is nrow=750 and ncolumns =3 and the "redp.dat" file is
>> attached.
>>
>> code is following
>> library(rugarch);
>> dat=read.csv('C:\\redp.dat',header=F);
>>
>> logexr=log(dat$V1)-log(dat$V2); # log of gross excess return
>> as.matrix(logexr);
>> dp=log(dat$V3); #log of dividend price ratio
>> as.matrix(dp);
>>
>> spec = ugarchspec(variance.model = li! st(model = "eGARCH", garchOrder =
>> c(1,1), external.regressors = as.matrix(dp)),
>> mean.model = list(armaOrder=c(0,0), include.mean = T,
>> external.regressors = as.matrix(dp)), distribution.model = "norm");
>> # dividend price ratio are used as external regressor in both mean and
>> variance equation
>>
>> test=ugarchroll(spec, n.ahead=1, data=logexr, forecast.length=400,
>> refit.every=1, refit.window="moving");
>> as.data.frame(test, which='LLH')
>> # where I did a rolling window forecast and display all the likelyhood
>>
>> #then I did a double check on the rolling estimation by doing
>> for (j in 1:10) # I am justing printing the first ten loop step
>> myfit = ugarchfit(spec, logexr[j:349+j]);
>> likelihood(myfit)
>> end
>>
>> # Question 1: the first likelihood from ugarchfit exactly equals that in
>> ugarchroll, while the values are different from then on.
>> # When I modify the spec to exclude any external regressor, the two sets
>> of likelihood are then exactly the same.
>> # reducing the forecast length (and therefore increase the length of the
>> estimation window) seems to mitigate the estimation difference.
>>
>> # Question 2: I then compare the density forecast
>> as.data.frame(test, which='density')
>> # this seem to produce
>> for (j in 1:10) # I am justing printing the first ten loop step
>> ugarchforecast(myfit, n.ahead=1); # and again when the likelihood are
>> different, the forecast is different.
>> end
>> # however, I am a bit confused since I thought it should produce
>> for (j in 1:10)
>> ugarchforecast(myfit, n.ahead=1,external.forecasts = list(mregfor =
>> dp[350+j], vregfor = dp[350+j] ));
>> end
>>
>> looking forward to your help.
>>
>>
>> Guoshi
>>
>>
>>
>>
>>
>> _______________________________________________
>> R-SIG-Finance@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.
>

	[[alternative HTML version deleted]]

