Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6086685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:47:02+00:00 2026-05-23T11:47:02+00:00

Would like to explore package beyond examples in docs but get hung up on

  • 0

Would like to explore package beyond examples in docs but get hung up on
coercion of ts object class to hts object:

Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent

Any thoughts?

#to replicate error run below
#install.packages("hts") # if not already installed

# Note:
# Series "AA","AB","AC","AD","AE" are children to "A"
# Series "BA","BB","BC" are children to "B"


require(hts)
Month <- c("2007-02-28","2007-03-31","2007-04-30","2007-05-31","2007-06-30","2007-07-31","2007-08-31"
          ,"2007-09-30","2007-10-31","2007-11-30","2007-12-31","2008-01-31","2008-02-29","2008-03-31"
          ,"2008-04-30","2008-05-31","2008-06-30","2008-07-31","2008-08-31","2008-09-30","2008-10-31"
          ,"2008-11-30","2008-12-31","2009-01-31","2009-02-28","2009-03-31","2009-04-30","2009-05-31"
          ,"2009-06-30","2009-07-31","2009-08-31","2009-09-30","2009-10-31","2009-11-30","2009-12-31"
          ,"2010-01-31","2010-02-28","2010-03-31","2010-04-30","2010-05-31","2010-06-30","2010-07-31"
          ,"2010-08-31","2010-09-30","2010-10-31","2010-11-30","2010-12-31","2011-01-31","2011-02-28"
          ,"2011-03-31","2011-04-30","2011-05-31","2011-06-30")
Month <- as.Date(Month, "%Y-%m-%d")
mdt <- min(Month)
AA <- c(145,51,-202,-187,-266,-187,119,-75,-210,-24,26,33,355,219,-17,-141,-281,-42,-64,-3,-21,-86,-51
      ,-115,248,193,-91,-229,-193,-220,-90,-50,-100,-121,-181,-131,37,24,-65,-213,-224,-257,-151,75,-184
      ,-480,-310,-134,97,146,-140,-310,-306)
AB <- c(3395,2463,1344,1123,-1136,-906,67,-41,-1429,-578,-14938,-7378,1739,1396,1252,298,444,-42,1439,1538
       ,306,-882,-805,-961,2727,542,-1460,-1570,1518,-85,1873,-636,-1258,601,252,-598,919,1199,-790,-813,-1283
       ,-1333,-758,794,-1865,-525,-3056,-1789,1039,998,-226,-1336,-1873)
AC <- c(4429,1139,1506,-4144,-5875,-1507,12329,4780,685,2119,-5755,-9353,3032,4001,2338,-4273,-1022,-2508
       ,4504,2289,916,-940,-4451,-1463,-293,1692,832,-6576,-524,1981,6002,367,-1328,-22,1221,-1961,3146
       ,1465,945,-6478,-3333,-1674,2307,5733,-2277,-1688,-5946,-4596,-698,1716,52,-9328,-4540)
AD <- c(1894,1265,650,-404,-1143,-883,-340,849,-563,420,100,-5107,1587,937,602,68,-1231,-1389,-156,1479
       ,-25,-444,-167,-371,1650,661,108,-2267,836,-1437,-1259,-601,-1431,-751,-1585,-126,-422,406,390,-194
       ,-633,-1366,-2301,3660,-2761,-910,-1893,-3266,-1580,-323,-257,-3622,-1584)
AE <- c(2303,2088,1419,-236,-327,562,409,1694,239,459,3601,-6524,2872,2602,1280,-63,-1241,-88,1321,-512,-402
       ,-136,-388,-699,3854,1740,187,-1600,-903,-324,-1197,-1045,-997,-108,-231,-1515,579,2784,-504,-1627,-1600
       ,-1236,-1759,5529,-1144,-1358,-4006,-1481,-328,1797,83,-1133,-1342)
BA <- c(2679,609,-6,283,-540,-442,530,-7,-17413,1002,-853,-1965,-1298,1213,-1507,-559,-2113,-1442,-228,329
       ,-2130,-3266,-2584,-1842,-5106,1640,-289,5423,-1051,15337,-818,1565,-533,-762,-630,-2154,190,188,-1569
       ,-2596,-4334,-2969,-3304,-2038,-3532,-1808,-679,-2954,-1249,1304,-106,-892,-2758)
BB <- c(-1388,785,-4372,-5128,-6652,-10177,-12592,-8006,-1489,-5107,-2952,-7470,396,3562,5779,1858,-6067,-4875
       ,-4132,-3066,-4386,-2217,-11683,-1841,4100,1508,-2061,-4579,-1840,-3147,-5087,-2529,-1369,-4674,-4578
       ,-3754,269,1645,9393,-3453,-5223,-6060,-5364,-4301,-2125,-3467,-2791,-3605,-262,4006,3058,-111,648)
BC <- c(4335,3685,-1075,-114,-94,-1672,-1551,-819,15167,-2060,-3176,-3585,3119,3775,595,931,-348,-2088,-1690
       ,169,-2936,-2615,-4086,-2397,6403,3334,-1208,-2952,-3246,-20580,-5820,-1917,-3430,-243,-3362,-3443,541
       ,1669,-1356,-2669,-3551,-3826,-3882,-2831,-2372,-2181,-2769,-4518,1278,4119,1582,-181,-1447)

tsdata <- data.frame(Month,AA,AB,AC,AD,AE,BA,BB,BC)
mts <- ts(tsdata, start =c(as.numeric(format.Date(mdt, "%Y")),as.numeric(format.Date(mdt, "%m"))), frequency=12 )
# "AA","AB","AC","AD","AE" are children to "A"
# "BA","BB","BC" are children to "B"
g.mts  <-  rbind(c("AA","AB","AC", "AD","AE","BA","BB","BC"),  c("A","A","A","A","A","B","B","B"))
hts.mts  <-  hts(y  =  mts,  g  =  g.mts)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:47:02+00:00Added an answer on May 23, 2026 at 11:47 am

    I am not quite clear what you are trying to do, but it seems there may be an issue of having 9 columns in mts but 8 in g.mts. For example

    hts.mts  <-  hts(y  =  mts[,-1],  g  =  g.mts)
    

    does not produce the error message

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting started with ASP.NET MVC, but would like to explore further. I've walked
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I'm a newcomer to the idea of aspect-oriented programming but I would like to
I'm starting learning EJBs and would like to explore it by creating a toy
I would like to explore the folder in the Windows Explorer from the shell.
I would like the Package Explorer view, if possible, just to show the order
OK here's what I would like: in the Eclipse package explorer, I see the
I get the following IDE error which appears inline or on the package declaration
I would like explorer opened up on a certain folder, after the deployment has
The explorer control in Windows Vista is very handy and I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.