Hi,
Thanks to Mr Grimmer for the precious advice,
I've done some test with some parameters , here are the results:
TEST 1) z.out1<- zelig(Diff(Y, 0, 0, 24)~ lag.eps(0, 0) + lag.y(0, 1),
model="arima", data="your.data")
R calculates coefficients but when i do the predictions ( with sim() .. )
it shows me this error:
Error in if (temp[i] == 2 | temp[i] == 4) { :
missing value where it is demanded TRUE/FALSE
TEST 2) z.out1<- zelig(Diff(Y, 0, 0, 24)~ lag.eps(0, 2) + lag.y(0, 2),
model="arima", data="your.data")
All ok, but the expected values aren't so realistic..
TEST 3) z.out1<- zelig(Diff(Y, 0, 0, 24)~ lag.eps(0, 1) + lag.y(0, 1),
model="arima", data="your.data")
All ok, but the expected values aren't so realistic..
and it displays some warnings:
the seasonal part MA isn't invertible in: in: predict.Arima(temp, newxreg =
NULL, n.ahead = (pred.ahead))
TEST 4) z.out1<- zelig(Diff(Y, 0, 1, 24)~ lag.eps(0, 1) + lag.y(0, 1),
model="arima", data="your.data")
All ok, values quite realistic.
and it displays some warnings:
the seasonal part MA isn't invertible in: in: predict.Arima(temp, newxreg =
NULL, n.ahead = (pred.ahead))
TEST 5) z.out1<- zelig(Diff(Y, 0, 1, 24)~ lag.eps(0, 2) + lag.y(0, 2),
model="arima", data="your.data")
All ok, values quite realistic.
and it displays some warnings:
the seasonal part MA isn't invertible in: in: predict.Arima(temp, newxreg =
NULL, n.ahead = (pred.ahead))
TEST 6) z.out1<- zelig(Diff(Y, 0, 1, 24)~ lag.eps(0, 0) + lag.y(0, 3),
model="arima", data="your.data")
R calculates coefficients but when i do the predictions ( with sim() .. )
it shows me this error:
Error in if (temp[i] == 2 | temp[i] == 4) { :
missing value where it is demanded TRUE/FALSE
TEST 7) z.out1<- zelig(Diff(Y, 0, 1, 24)~ lag.eps(0, 3) + lag.y(0, 3),
model="arima", data="your.data")
All ok, values not so realistic.
TEST 8) z.out1<- zelig(Diff(Y, 1, 1, 24)~ lag.eps(0, 1) + lag.y(0, 1),
model="arima", data="your.data")
All ok, values not so realistic.
i've put the graphics online on this link ( 120 kB if somebody wanna
wiew!!):
http://rascal.netsons.org/Graph.zip
Concluding, i think the most accurate prevision for my dataSet is in TEST 5.
If you have some suggestion i'm here to listen!
All the Best
Riccardo
> -----Messaggio originale-----
> Da: owner-zelig_at_lists_gking_harvard_edu(a)mail.hmdc.harvard.edu
> [mailto:owner-zelig_at_lists_gking_harvard_edu@mail.hmdc.harvard.edu] Per
> conto di Justin Ryan Grimmer
> Inviato: sabato 3 marzo 2007 18.24
> A: zelig(a)lists.gking.harvard.edu
> Oggetto: [zelig] [Zelig] seasonal time series
>
> Hi Riccardo,
>
> Great question. Zelig provides an intuitive format for analying seasonal
> ARIMA models (here after sARIMA). The following is the general set-up for
> a sARIMA model
>
> z.out1<- zelig(Diff(Y,d,ds,per) ~ lag.eps(q,qs) + lag.y(p,ps), data =
> mydata, model = "arima")
>
> where:
> Y<- time series to be analyzed
> d<- order of intergration for time series
> d.s<- order of integration for seasonal components
> per<- the period of the time series
> q<- number of error terms (innovations) to lag
> q.s<- number of seasonal error terms to lag
> p<- number of dependent variables to lag
> p.s<- number of seasonal dependent variables to lag, based upon per, the
> period
>
>
> Let's say that you want to estimate an
> ARIMA model with a period of 24, and you want to have a lag of one
> dependent variable from the previous season, then you would specify the
> following model:
>
> z.out1<- zelig(Diff(Y, 0, 0, 24)~ lag.eps(0, 0) + lag.y(0, 1),
> model="arima", data="your.data")
>
>
> You can use more complicated ARIMA structures just by filling in the
> appropriate arguments.
>
> If you do not have any covariates to include, you can then forecast your
> time series. Zelig offers a simulation approach that allows you to
> include uncertainty from estimating coefficients in your forecasts, while
> usually negligible, this provides more accurate representation of
> uncertainty for long forecasts.
>
> To do this you enter a "setx" command as follows,
>
> x.out<- setx(z.out1, pred.ahead=10)
>
> this predicts 10 periods ahead.
>
> Then, you can generate simulated results as follows:
>
> s.out<- sim(z.out1, x=x.out)
>
> Please let me know if you are still running into trouble with the ARIMA
> package.
>
> Cheers,
> Justin Grimmer
> PhD Student
> Department of Government
> Harvard University
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
I would follow the example in here:
http://gking.harvard.edu/zelig/docs/Examples.html#mi.ex
Kosuke
On Mon, 5 Mar 2007, Anders Schwartz Corr wrote:
>
> It looks like the amelia output has the full datasets, but the mi() output
> has nothing. I'll check if the model can be run on one of the datasets.
>
>
>> summary(mi4$m1)
> Length Class Mode
> 0 NULL NULL
>> summary(ameliaoutput4$m1)
> year ccode country ter
> Min. :1815 Min. : 0 United Kingdom: 304 Min. :-102.98
> 1st Qu.:1889 1st Qu.: 160 France : 215 1st Qu.: 0.51
> Median :1949 Median : 339 USSR : 199 Median : 3.05
> Mean :1933 Mean : 377 Turkey : 198 Mean : 12.59
> 3rd Qu.:1980 3rd Qu.: 600 Spain : 185 3rd Qu.: 12.23
> Max. :2001 Max. :7693 (Other) :11214 Max. : 226.15
> NA's : 137 NA's : 2732
> elf85 tradeope_log demo fed
> Min. :-0.536 Min. :-3.0182 Min. :-29.871 Min. :-2.089
> 1st Qu.: 0.308 1st Qu.:-1.4121 1st Qu.: -7.000 1st Qu.: 0.000
> Median : 0.487 Median :-0.5647 Median : -3.000 Median : 0.000
> Mean : 0.487 Mean : 0.0297 Mean : -0.954 Mean : 0.321
> 3rd Qu.: 0.667 3rd Qu.: 0.5747 3rd Qu.: 6.000 3rd Qu.: 0.505
> Max. : 1.803 Max. :33.5713 Max. : 23.298 Max. : 2.967
>
>
> On Mon, 5 Mar 2007, Kosuke Imai wrote:
>
>> That's strange since mi() function is working as in demo(mi). I would first
>> check your multiply-imputed data sets and then check whether the model can
>> be run on one of the data sets.
>>
>> Hope this helps,
>> Kosuke
>>
>> On Sun, 4 Mar 2007, Anders Schwartz Corr wrote:
>>
>>>
>>> Hi Kosuke,
>>>
>>> Same problem. Please see below. Help! Sorry!
>>>
>>> Anders
>>>
>>>
>>> R version 2.4.1 (2006-12-18)
>>> Copyright (C) 2006 The R Foundation for Statistical Computing
>>> ISBN 3-900051-07-0
>>>
>>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>>> You are welcome to redistribute it under certain conditions.
>>> Type 'license()' or 'licence()' for distribution details.
>>>
>>> R is a collaborative project with many contributors.
>>> Type 'contributors()' for more information and
>>> 'citation()' on how to cite R or R packages in publications.
>>>
>>> Type 'demo()' for some demos, 'help()' for on-line help, or
>>> 'help.start()' for an HTML browser interface to help.
>>> Type 'q()' to quit R.
>>>
>>>>
>>>> install.packages("Zelig",repos="http://gking.harvard.edu")
>>> trying URL
>>> 'http://gking.harvard.edu/bin/windows/contrib/2.4/Zelig_2.8-2.zip'
>>> Content type 'application/zip' length 2142431 bytes
>>> opened URL
>>> downloaded 2092Kb
>>>
>>>
>>> The downloaded packages are in
>>> C:\Documents and Settings\Anders Corr\Local
>>> Settings\Temp\Rtmpz4eyrb\downloaded_packages
>>> updating HTML package descriptions
>>>> library(Zelig)
>>> Loading required package: MASS
>>> Loading required package: boot
>>> ##
>>> ## Zelig (Version 2.8-2, built: 2007-03-03)
>>> ## Please refer to http://gking.harvard.edu/zelig for full documentation
>>> ## or help.zelig() for help with commands and models supported by Zelig.
>>> ##
>>>> load("C:\\Documents and Settings\\Anders Corr\\My
>>> Documents\\data\\tcworkingtwo\\ameliaoutput4.rData")
>>>> ls()
>>> [1] "ameliaoutput4"
>>>> mi4<-mi(ameliaoutput4)
>>>>
>>>> z.out<-zelig(formula = log(ncc+1) ~ p_norm_total + cinc +
>>> log(ter+110.77) + demo + polarity + log(year) + fed + elf85 +
>>> dems6/num_stat + (war_new^3 + mid_new)/num_stat , model = "normal",
>>> + data = mi4)
>>>> summary(z.out)
>>> Length Class Mode
>>> 0 list list
>>>>
>>>>
>>>
>>>
>>
>> -
>> Zelig Mailing List, served by Harvard-MIT Data Center
>> Send messages: zelig(a)lists.gking.harvard.edu
>> [un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
>> Zelig program information: http://gking.harvard.edu/zelig/
>>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
That's strange since mi() function is working as in demo(mi). I would
first check your multiply-imputed data sets and then check whether the
model can be run on one of the data sets.
Hope this helps,
Kosuke
On Sun, 4 Mar 2007, Anders Schwartz Corr wrote:
>
> Hi Kosuke,
>
> Same problem. Please see below. Help! Sorry!
>
> Anders
>
>
> R version 2.4.1 (2006-12-18)
> Copyright (C) 2006 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
>>
>> install.packages("Zelig",repos="http://gking.harvard.edu")
> trying URL 'http://gking.harvard.edu/bin/windows/contrib/2.4/Zelig_2.8-2.zip'
> Content type 'application/zip' length 2142431 bytes
> opened URL
> downloaded 2092Kb
>
>
> The downloaded packages are in
> C:\Documents and Settings\Anders Corr\Local
> Settings\Temp\Rtmpz4eyrb\downloaded_packages
> updating HTML package descriptions
>> library(Zelig)
> Loading required package: MASS
> Loading required package: boot
> ##
> ## Zelig (Version 2.8-2, built: 2007-03-03)
> ## Please refer to http://gking.harvard.edu/zelig for full documentation
> ## or help.zelig() for help with commands and models supported by Zelig.
> ##
>> load("C:\\Documents and Settings\\Anders Corr\\My
> Documents\\data\\tcworkingtwo\\ameliaoutput4.rData")
>> ls()
> [1] "ameliaoutput4"
>> mi4<-mi(ameliaoutput4)
>>
>> z.out<-zelig(formula = log(ncc+1) ~ p_norm_total + cinc +
> log(ter+110.77) + demo + polarity + log(year) + fed + elf85 + dems6/num_stat
> + (war_new^3 + mid_new)/num_stat , model = "normal",
> + data = mi4)
>> summary(z.out)
> Length Class Mode
> 0 list list
>>
>>
>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi,
This model used to work with Zelig, and now it doesn't. R seems to be
working, I reloaded it, reloaded Zelig. Any more guesses?
Thank you!
Anders
> load("C:\\Documents and Settings\\Anders Corr\\My
Documents\\data\\tcworkingtwo\\ameliaoutput4.rData")
> local({pkg <- select.list(sort(.packages(all.available = TRUE)))
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Loading required package: MASS
Loading required package: boot
##
## Zelig (Version 2.7-5, built: 2006-12-25)
## Please refer to http://gking.harvard.edu/zelig for full documentation
## or help.zelig() for help with commands and models supported by Zelig.
##
> ls()
[1] "ameliaoutput4"
>
> mi4<-mi(ameliaoutput4)
>
> z.out<-zelig(formula = log(ncc+1) ~ p_norm_total + cinc +
log(ter+110.77) + demo + polarity + log(year) + fed + elf85 + gpconcsq +
dems6/num_stat + (war_new^3 + mid_new)/num_stat , model = "normal",
+ data = mi4)
> summary(z.out)
Length Class Mode
0 list list
> summary(ameliaoutput4)
Length Class Mode
m1 69 data.frame list
m2 69 data.frame list
m3 69 data.frame list
m4 69 data.frame list
m5 69 data.frame list
theta1 3969 -none- numeric
theta2 3969 -none- numeric
theta3 3969 -none- numeric
theta4 3969 -none- numeric
theta5 3969 -none- numeric
code 1 -none- numeric
amelia.args 24 -none- list
> summary(ameliaoutput4$m1)
year ccode country ter
Min. :1815 Min. : 0 United Kingdom: 304 Min. :-102.98
1st Qu.:1889 1st Qu.: 160 France : 215 1st Qu.: 0.51
Median :1949 Median : 339 USSR : 199 Median : 3.05
Mean :1933 Mean : 377 Turkey : 198 Mean : 12.59
3rd Qu.:1980 3rd Qu.: 600 Spain : 185 3rd Qu.: 12.23
Max. :2001 Max. :7693 (Other) :11214 Max. : 226.15
NA's : 137 NA's : 2732
elf85 tradeope_log demo fed
Min. :-0.536 Min. :-3.0182 Min. :-29.871 Min. :-2.089
1st Qu.: 0.308 1st Qu.:-1.4121 1st Qu.: -7.000 1st Qu.: 0.000
Median : 0.487 Median :-0.5647 Median : -3.000 Median : 0.000
Mean : 0.487 Mean : 0.0297 Mean : -0.954 Mean : 0.321
3rd Qu.: 0.667 3rd Qu.: 0.5747 3rd Qu.: 6.000 3rd Qu.: 0.505
Max. : 1.803 Max. :33.5713 Max. : 23.298 Max. : 2.967
[I omitted some more data summary below. Anders]
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi Riccardo,
Great question. Zelig provides an intuitive format for analying seasonal
ARIMA models (here after sARIMA). The following is the general set-up for
a sARIMA model
z.out1<- zelig(Diff(Y,d,ds,per) ~ lag.eps(q,qs) + lag.y(p,ps), data =
mydata, model = "arima")
where:
Y<- time series to be analyzed
d<- order of intergration for time series
d.s<- order of integration for seasonal components
per<- the period of the time series
q<- number of error terms (innovations) to lag
q.s<- number of seasonal error terms to lag
p<- number of dependent variables to lag
p.s<- number of seasonal dependent variables to lag, based upon per, the
period
Let's say that you want to estimate an
ARIMA model with a period of 24, and you want to have a lag of one
dependent variable from the previous season, then you would specify the
following model:
z.out1<- zelig(Diff(Y, 0, 0, 24)~ lag.eps(0, 0) + lag.y(0, 1),
model="arima", data="your.data")
You can use more complicated ARIMA structures just by filling in the
appropriate arguments.
If you do not have any covariates to include, you can then forecast your
time series. Zelig offers a simulation approach that allows you to
include uncertainty from estimating coefficients in your forecasts, while
usually negligible, this provides more accurate representation of
uncertainty for long forecasts.
To do this you enter a "setx" command as follows,
x.out<- setx(z.out1, pred.ahead=10)
this predicts 10 periods ahead.
Then, you can generate simulated results as follows:
s.out<- sim(z.out1, x=x.out)
Please let me know if you are still running into trouble with the ARIMA
package.
Cheers,
Justin Grimmer
PhD Student
Department of Government
Harvard University
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi,
i want to predict a seasonal time series (number of time series value =
240), (period of season =24),
i use zelig function , but i don't know the right use of argument and the
prediction that I obtain isn't right.
For example:
z.out1<- zelig(Diff(Y,d,ds,per) ~ lag.eps(q,qs) + lag.y(p,ps), data =
mydata, model = "arima")
arguments:
Diff:
Y<- a column of my data
d<-?
ds<-?
per <- 24
lag.eps:
q<-?
qs<-?
lag.y:
p<- ?
ps<-?
Can anybody help me?
P.S
i've found this tutorial but i can't understand so much:
In addition to independent variables, zelig() accepts the following
arguments to specify the ARIMA model:
. Diff(Y, d, ds, per) for a dependent variable Y sets the number
of non-seasonal differences (d), the
number of seasonal differences (ds), and the period of the season (per).
. lag.y(p, ps) sets the number of lagged observations of the
dependent variable for non-seasonal (p) and
seasonal (ps) components.
. lag.eps(q, qs) sets the number of lagged innovations, or
differences between the observed value of the
time series and the expected value of the time series for non-seasonal (q)
and seasonal (qs) components.
Thanks
Riccardo