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 9311425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:21:42+00:00 2026-06-19T01:21:42+00:00

I am using R.Net 1.5 to attempt to do a simple forecast using ARIMA.

  • 0

I am using R.Net 1.5 to attempt to do a simple forecast using ARIMA. I’ve tried with R 2.14 and R 2.15. I’m using Visual Studio 2012 target .NET 4 though I’ve also tried .NET 4.5 and Visual Studio 2010.

Here is a piece of the code I’ve written:

string rhome = System.Environment.GetEnvironmentVariable("R_HOME");
        if (string.IsNullOrEmpty(rhome))
            rhome = @"C:\Program Files\R\R-2.14.0";

        System.Environment.SetEnvironmentVariable("R_HOME", rhome);
        System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + rhome + @"\bin\x64");
        using (REngine engine = REngine.CreateInstance("RDotNet"))
        {

            engine.Initialize();

            NumericVector testGroup = engine.CreateNumericVector(submissions);
            engine.SetSymbol("testGroup", testGroup);
            engine.Evaluate("testTs <- c(testGroup)");
            NumericVector ts = engine.GetSymbol("testTs").AsNumeric();

            engine.Evaluate("tsValue <- ts(testTs, frequency=1, start=c(2010, 1, 1))");
            engine.Evaluate("library(forecast)");
            engine.Evaluate("arimaFit <- auto.arima(tsValue)");
            engine.Evaluate("fcast <- forecast(tsValue, h=36)");
            engine.Evaluate("plot(fcast)");

            NumericVector nv = engine.GetSymbol("fcast").AsNumeric();

It fails when I attempt to retrieve the numeric vector. TI get a few errors here. The first is “Error: object cannot be coerced to type ‘double'” and the second is “Error: caught access violation – continue with care”

If I retrieve the forecast as a GenericVector I get a list of RDotNet.SymbolicExpressions. I’ve looped through those to see what they contain and it does seem to be related to the ARIMA function but I cannot locate the actual forecast output. I can find the inputs and other related values as well as a bunch of lists of numbers that I can’t determine what they are.

If I run the script within Revolution I can see what the outputs SHOULD be and that is how I’m determining whether the outputs from R.Net are accurate. I suppose it’s possible R.Net is performing the forecast differently than Revolution (though unlikely, I think) and one of the outputs in the genericvector is indeed the correct output.

Here is the GenericVector initialization. I wrapped in a blanket try, catch just for debugging purposes: Inside the DynamicVector is where I can actually inspect the details.

GenericVector newVector = engine.GetSymbol("fcast").AsList();

            foreach (var vector in newVector)
            {
                try
                {
                    DynamicVector dv = vector.AsVector();
                }
                catch (Exception)
                {
                }
  • 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-06-19T01:21:43+00:00Added an answer on June 19, 2026 at 1:21 am

    It is not a R.Net problem, you just try to run a wrong script. Let’s run your code on pure R:

    > testTs <- c(1, 2, 3)
    > tsValue <- ts(testTs, frequency=1, start=c(2010, 1, 1))
    > library("forecast")
    > arimaFit <- auto.arima(tsValue)
    > fcast <- forecast(tsValue, h=36)
    > plot(fcast)
    

    Now class(fcast) equals to forecast:

    > class(fcast)
    [1] "forecast"
    > as.numeric(fcast)
    Error: (list) object cannot be coerced to type 'double'
    

    fcast strucure:

    > str(fcast)
    List of 11
     $ method   : chr "Mean"
     $ level    : num [1:2] 80 95
     $ x        : Time-Series [1:3] from 2010 to 2012: 1 2 3
     $ xname    : chr "object"
     $ mean     : Time-Series [1:36] from 2013 to 2048: 2 2 2 2 2 2 2 2 2 2 ...
     $ lower    : mts [1:36, 1:2] -0.177 -0.177 -0.177 -0.177 -0.177 ...
      ..- attr(*, "dimnames")=List of 2
      .. ..$ : NULL
      .. ..$ : chr [1:2] "80%" "95%"
      ..- attr(*, "tsp")= num [1:3] 2013 2048 1
      ..- attr(*, "class")= chr [1:2] "mts" "ts"
     $ upper    : mts [1:36, 1:2] 4.18 4.18 4.18 4.18 4.18 ...
      ..- attr(*, "dimnames")=List of 2
      .. ..$ : NULL
      .. ..$ : chr [1:2] "80%" "95%"
      ..- attr(*, "tsp")= num [1:3] 2013 2048 1
      ..- attr(*, "class")= chr [1:2] "mts" "ts"
     $ model    :List of 4
      ..$ mu   : num 2
      ..$ mu.se: num 0.577
      ..$ sd   : num 1
      ..$ call : language meanf(x = object, h = h, level = level, fan = fan)
     $ lambda   : NULL
     $ fitted   : Time-Series [1:3] from 2010 to 2012: NA 1 1.5
     $ residuals: Time-Series [1:3] from 2010 to 2012: NA 1 1.5
     - attr(*, "class")= chr "forecast"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Visual Studio 2010, I have written a simple WCF service and some integration
Trying to do basic SSL-authenticated Web Service using Visual Studio 2008 .NET 3.5 Service
I was just about to attempt scraping using the Simple HTML DOM Framework: http://simplehtmldom.sourceforge.net/
I'm currently using VS2008 and VB.NET. When I attempt to populate a Queue that
I'm using .NET framework (tried 3.5 & 4.0) to load a .TIFF file and
I have a relatively simple ASP.net MVC 2 app that is using SubSonic. Everything
I wrote a simple file upload application using ASP.NET MVC. I tested it successfully
I am familar developing .net web apps. Try to attempt to build a simple
I'm following (or rather not following!) the tutorial found here: http://www.flashuser.net/flash-tricks/tips-tricks-10-using-drag-drop-in-actionscript-3-0.html I've drawn a
Intro: I'm using MATLAB's Neural Network Toolbox in an attempt to forecast time series

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.