SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Feb 29, 2020 12:49 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jun 23, 2011 8:51 pm 
Offline

Joined: Sun Jun 01, 2008 1:18 pm
Posts: 32
Location: Paris France
After downloading from
http://code.google.com/p/rdotnet/

the zip package allowing to use the routines in the statistics R library (multivariate regression ANOVA, etc.)

I tried to get the following to work...but OQ doesn't recognize
using System.Linq; //should this be using System.Data.Linq; ?
and above all
using RDotNet;

on my xp home/Open Quant 2 ver 2.9.3 platform....
service pack problem? registry problem? folder for .dll file problem...they don't work when installed in the OpenQuant.API.dll folder either...

code:

using System;
using OpenQuant.API;
using System.Linq; //should this be using System.Data.Linq; ?
//using System.XML.Linq;
using RDotNet;
namespace R.NET_Wrapper
{
class Program
{
public static void Main(string[] args)
{
//Console.WriteLine("Hello World!");
// Point the R Engine to the dll dir
RDotNet
.REngine
.SetDllDirectory(
@"C:\Program Files\R\R-2.12.1\bin\i386"
);

// make an instance, go ahead, do it
using
(REngine engine =
REngine
.CreateInstance("RInstance")
)
{
// Let's see what it'll do.
// Let's create a numeric vector with a double[]
// .NET framework array to vector
NumericVector group1 =
engine.CreateNumericVector(
new double[] {
30.02,
29.99,
30.11,
29.97,
30.01,
29.99
});
engine
.SetSymbol("group1", group1); // Dont forget this!

// Here's the sssllooww way
NumericVector group2 =
engine
.EagerEvaluate(
"group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)")
.AsNumeric();
// EagerEvaluate will also accept IO.Stream (R scripts, anyone?)

// Test difference of mean (student's t-test) and get P-value
GenericVector testResult =
engine
.EagerEvaluate("t.test(group1, group2)")
.AsList();
double p =
testResult["p.value"]
.AsNumeric()
.First();

Console.WriteLine(
"Group 1 [{0}]",
string.Join(
", ",
group1.Select(i => i.ToString()))
);
Console.WriteLine(
"Group 2 [{0}]",
string.Join(
", ",
group2.Select(i => i.ToString())
)
);
Console.WriteLine("P-value = { 0.000}", p);
}


//+ TODO: finish getting data into managed space

Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}

Could be worth a look for someone interested in a powerful statistics library....

_________________
Thx!!


Top
 Profile  
 
PostPosted: Thu Jun 23, 2011 9:55 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
Hi,

have you added System.Data.Linq dll through OQ main menu -> Tools -> Options -> Projects and Solutions -> Build?

Regards,
Anton


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group