【问题标题】:How to access a variable of class ets in c# while using RdotNet使用 RdotNet 时如何在 c# 中访问类 ets 的变量
【发布时间】:2014-12-22 06:27:18
【问题描述】:

适合

其中 myts 是使用 ts() 函数定义的时间序列。现在我想读取输出参数,如平滑参数 alpha、beta 和 ets() 函数选择的初始状态和模型类型(例如:(A,N, N))... 我如何在 C# 中做到这一点?我正在使用 R.Net。

任何帮助将不胜感激。

【问题讨论】:

    标签: c# r time-series forecasting r.net


    【解决方案1】:

    函数 ets 的结果是一个列表,所以在 C# 中也将它强制转换为一个列表。请参阅 https://github.com/jmp75/rdotnet-onboarding 下的 SupportSamples

        static void stackoverflow_27597542_2752565 (REngine engine)
        {
            var createModel = @"
            set.seed(0)
            x <- ts(rnorm(100))
            library(forecast)
            blah <- ets(x)
            # str(blah)
            ";
            engine.Evaluate (createModel);
            var m = engine.GetSymbol ("blah").AsList ();
            var components = m ["components"].AsCharacter ().ToArray ();
            for (int i = 0; i < components.Length; i++) {
                Console.WriteLine ("m$components[{0}] = {1}", i + 1, components [i]);
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多