I have fractionally integrated data and am running a FIECM model. I would like to do a one-step ahead forecast for three out-of-sample years. This is what my original data look like:
dput(ts_short)
structure(c(1972, 1974, 1976, 1978, 1980, 1982, 1984, 1986, 1988,
1990, 1992, 1994, 1996, 1998, 2000, 2002, 2004, 2006, 2008, 2010,
2012, 0.55946148092745, 0.611528822055138, 0.569045412418906,
0.584737363726462, 0.544819557625146, 0.574438202247191, 0.551054852320675,
0.602446483180428, 0.589184060721063, 0.641697877652934, 0.592700729927007,
0.471337579617834, 0.483026188166828, 0.48021582733813, 0.512623490669594,
0.48046875, 0.53072625698324, 0.546955154724475, 0.620826709062003,
0.441439894697685, 0.558255107675317, 3.60221811460259, 3.51809523809524,
3.56316725978648, 3.45703125, 3.52602230483271, 3.42031029619182,
3.72662826761187, 3.59926470588235, 3.79803921568627, 3.57070707070707,
3.68490945674044, 3.88523676880223, 3.66219369894982, 3.62685402029664,
3.6972883231876, 3.83653209794838, 3.81683168316832, 3.93478442863123,
3.23987941429802, 3.86992848938456, 3.50997632735881, 4.39112754158965,
5.30539682539683, 5.7326512455516, 5.41536458333333, 5.8091697645601,
5.92524682651622, 5.60567124501551, 5.41957720588235, 5.74362745098039,
5.7459595959596, 5.46277665995976, 5.39777158774373, 5.36639439906651,
5.19984387197502, 2.55118981737687, 5.09133024487095, 5.40181518151815,
3.17739623855626, 5.58096468561585, 4.42052408304238, 4.62478863713223,
0.568207024029575, 0.58031746031746, 0.579626334519573, 0.55859375,
0.569392812887237, 0.552891396332863, 0.561807709348693, 0.5625,
0.572549019607843, 0.547979797979798, 0.534004024144869, 0.534261838440111,
0.551925320886814, 0.551131928181108, 0.562811289429994, 0.560555923229649,
0.533003300330033, 0.521814337881991, 0.569767441860465, 0.517635379061372,
0.518938112952317, 0.878743068391867, 0.883809523809524, 0.865658362989324,
0.852430555555556, 0.835192069392813, 0.849083215796897, 0.797518830305716,
0.778492647058823, 0.754411764705882, 0.759090909090909, 0.762575452716298,
0.769359331476323, 0.771878646441074, 0.744730679156909, 0.747094631986718,
0.781601588352085, 0.6996699669967, 0.759753988083798, 0.490094745908699,
0.747075812274368, 0.5948596550558, 0.0987060998151571, 0.0901587301587302,
0.099644128113879, 0.100694444444444, 0.113382899628253, 0.106488011283498,
0.109880372175454, 0.144301470588235, 0.126960784313725, 0.128282828282828,
0.124748490945674, 0.108635097493036, 0.111435239206534, 0.112412177985948,
0.109573879358052, 0.0893448047650563, 0.145214521452145, 0.101397545372175,
0.241171403962102, 0.11572202166065, 0.173655732160974, 0.0155268022181146,
0.013968253968254, 0.0204626334519573, 0.0334201388888889, 0.040272614622057,
0.034555712270804, 0.0686752326096588, 0.0565257352941176, 0.0833333333333333,
0.0828282828282828, 0.0881287726358149, 0.0813370473537604, 0.0869311551925321,
0.110850897736144, 0.0774764803541782, 0.0635340833884844, 0.0924092409240924,
0.0930507125010296, 0.225236864771748, 0.0729783393501805, 0.170612106865066,
0.708641975308642, 0.594236760124611, 0.631441957313899, 0.657157157157157,
0.408135593220339, 0.513636363636364, 0.633668101386896, 0.640422467594815,
0.598449612403101, 0.649708532061473, 0.429577464788732, 0.511518015357354,
0.682624113475177, 0.737389911929544, 0.675660160734788, 0.698753462603878,
0.510135135135135, 0.403743836875679, 0.229639519359146, 0.448140431102834,
0.568142511241785, 3.24759437453738, 3.33290488431877, 3.47384890478319,
3.65706806282722, 3.68695652173913, 3.84501061571125, 3.82657155595185,
3.76486988847584, 3.7244133799301, 3.66204417051875, 3.90743801652893,
4.06488332384747, 4.18819403857393, 4.22962382445141, 4.39666666666667,
4.58144192256342, 4.40676567656766, 3.31424327446773, 4.06759098786828,
3.82032490974729, 4.41857680465275, 0.0107373908633566, 0.061039763207495,
0.00926030991923469, 0.0279084063548401, -0.0141789585867552,
0.0209123124751792, -0.00537961490643119, 0.0488785302639187,
0.0282025173257842, 0.0799369344181532, 0.0214272770861432, -0.0962033304983142,
-0.0639948367773809, -0.0603928751231265, -0.0233946951490035,
-0.0577831244400179, -0.00216197215417648, 0.00846485399001074,
0.0780828820126991, -0.115214361151664, 0.0250365001639566, -0.0643430795453473,
-0.148463007201046, -0.103385655789253, -0.209520820756525, -0.140523912294325,
-0.246235785833365, 0.0600878168691678, -0.0672865484768636,
0.131489151640284, -0.0958519601839715, 0.018356327744045, 0.218680618006669,
-0.00437299969056291, -0.0397079400757158, 0.0307293685448473,
0.169971310688181, 0.150263726504648, 0.268213661961868, -0.426698838935345,
0.203377749531977, -0.156590507951709, -0.620324700716426, 0.394464915127201,
0.715682612842578, 0.292891353321632, 0.689381093787622, 0.732484913231706,
0.358571709498085, 0.192437339052193, 0.545423434601713, 0.503242724396173,
0.200150024679976, 0.167691977240011, 0.155714531077644, 0.00184379640890685,
-2.61403021751586, 0.369738665263332, 0.457097868950991, -1.8740770554152,
0.845569772228193, -0.578080186983113, -0.27235646435317, 0.016537782380234,
0.0238777105804327, 0.0179959932706698, -0.00504834489473863,
0.0105232931741467, -0.00786218003931541, 0.00522536148038554,
0.00466961431223108, 0.0142865700935594, -0.0133542749262038,
-0.0213840134412077, -0.0152472082267571, 0.00474275966835441,
0.000259720357759477, 0.011326459862196, 0.00547419702110919,
-0.0227123375868691, -0.0264326364027301, 0.0272442149454456,
-0.036200770638436, -0.0232175043039665, 0.116394320995711, 0.0948383969932681,
0.0652618295722998, 0.0496771311855716, 0.0326017398803058, 0.0491974333794757,
-0.0053366766274339, -0.0141114267826215, -0.0304891203819611,
-0.0169547186193877, -0.0104572267415352, -0.00233634181313999,
-0.000137551920191346, -0.0274799524552715, -0.0186984937717258,
0.0179233265967094, -0.0704446313808326, 0.00641836462450188,
-0.270700474640614, 0.0463792807826996, -0.141354797787343, -0.0193966535791229,
-0.0279431342844095, -0.0184569001470049, -0.0174065263822253,
-0.00471798389727393, -0.0116133470214542, -0.00822085911276515,
0.0262001412843753, 0.00885784470051881, 0.0101798831523867,
0.00664535537903915, -0.00946803168218537, -0.00666720009989494,
-0.00569007618338764, -0.0085282915748915, -0.0287571667454576,
0.027113596805413, -0.0167053887498565, 0.123069575899161, -0.00238577286006096,
0.0555507474398361, 0.155401319817159, 0.0409889825705562, 0.078195862097559,
0.103909604446915, -0.145114023292185, -0.0396031113432886, 0.0804285399712575,
0.0871780124852817, 0.0452026776229804, 0.0964620303311412, -0.12367147878696,
-0.0417221858788441, 0.12938423768712, 0.184142919331395, 0.122407376117938,
0.145500174933751, -0.043120139156264, -0.149504184645509, -0.323600418340945,
-0.10508714500039, 0.0149118862545573, -0.703703457647846, -0.418538504886239,
-0.230275479077077, -0.0548336285550561, -0.06848356317221, 0.0715401645984553,
0.00268208865443612, -0.0716751154772386, -0.102213120054614,
-0.151555414164545, 0.116132058927364, 0.212875899379491, 0.272051764408261,
0.252177676181716, 0.379218055967917, 0.494363524144609, 0.234913219083891,
-0.84803293066775, 0.206878226616624, -0.152788940283894, 0.493960923880954
), .Dim = c(21L, 18L), .Dimnames = list(NULL, c("year", "voteDem",
"pid", "ideo", "female", "white", "black", "hispanic", "approval",
"education", "diffVoteDem", "diffPID", "diffIdeo", "diffFemale",
"diffWhite", "diffBlack", "diffApproval", "diffEducation")), .Tsp = c(1,
21, 1), class = c("mts", "ts", "matrix"))
And here are my out-of-sample data:
>dput(newdata)
structure(c(2016, 2018, 2020, 3.83817330210773, 3.74202011368605,
3.8713768115942, 4.196018735363, 3.91616526273566, 4.79408212560386,
0.528923660502608, 0.5596, 0.541823937659808, 0.711475409836066,
0.7416, 0.720169082125604, 0.0929742388758782, 0.102, 0.0876811594202899,
0.519176136363636, 0.418807139747497, 0.408969372873116, 4.71756086031671,
3.5908, 4.90575530739968, 0.171616650590426, 0.0754529335191861,
0.204809389376158, -0.700975181868257, -0.905880212516067, 0.0518540162799177,
-0.00995642630972868, 0.019701554810122, -0.00669017194268604,
0.00127088959823005, 0.0144544064645176, -0.0181342560873177,
-0.02513247486487, -0.0161038839159584, -0.0304218999179234,
-0.0340601032129632, -0.134429173547999, -0.144262492381023,
0.63983974986072, -0.622740696546108, 0.953866587515262), .Dim = c(3L,
15L), .Dimnames = list(NULL, c("year", "pid", "ideo", "female",
"white", "black", "approval", "education", "diffPID", "diffIdeo",
"diffFemale", "diffWhite", "diffBlack", "diffApproval", "diffEducation"
)), .Tsp = c(1, 3, 1), class = c("mts", "ts", "matrix"))
FYI: The variables with the "diff" prefix are my fractionally differenced versions of my variables.
So what I do is run my FIECM:
model = tslm(diffVoteDem ~ lag(voteDem) + diffPID + lag(pid), data = ts_short)
Then try to forecast it:
library(forecast)
forecast(model, newdata = newdata)
And get the following error:
Error in attr(x, "tsp") <- c(1, NROW(x), 1) :
invalid time series parameters specified
Does anyone have any suggestions about what is causing the package to throw this error?
Any help would be much appreciated!