473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mutliple regression using rpy

Hi,

I am trying to perform multiple regression in python using rpy.
I can get it to work for two arrays, however when I try to regress a matrix and an array (as in the following code) I get an error message (below.)
Can someone please help?

Thanks,
Ondrej


Expand|Select|Wrap|Line Numbers
  1. from rpy import *
  2.  
  3. phenotypes = array([4,5,4,3])
  4. X = array([1,2,3,4],[3,2,4,5],[6,5,4,3])
  5. d = r.data_frame(x=X, y=phenotypes)
  6. model = r("y~x")
  7. set_default_mode(NO_CONVERSION)
  8. linear_model = r.lm(model, data = d)
  9. set_default_mode(BASIC_CONVERSION)
  10. print r.summary(linear_model)
  11.  
  12.  
  13. Traceback (most recent call last):
  14.   File "genback.py", line 242, in ?
  15.     linear_model = r.lm(model, data = d)
  16. rpy.RException: Error in eval(expr, envir, enclos) : object "x" not found
Mar 27 '07 #1
1 2536
bartonc
6,596 Expert 4TB
Hi,

I am trying to perform multiple regression in python using rpy.
I can get it to work for two arrays, however when I try to regress a matrix and an array (as in the following code) I get an error message (below.)
Can someone please help?

Thanks,
Ondrej


Expand|Select|Wrap|Line Numbers
  1. from rpy import *
  2.  
  3. phenotypes = array([4,5,4,3])
  4. X = array([1,2,3,4],[3,2,4,5],[6,5,4,3])
  5. d = r.data_frame(x=X, y=phenotypes)
  6. model = r("y~x")
  7. set_default_mode(NO_CONVERSION)
  8. linear_model = r.lm(model, data = d)
  9. set_default_mode(BASIC_CONVERSION)
  10. print r.summary(linear_model)
  11.  
  12.  
  13. Traceback (most recent call last):
  14.   File "genback.py", line 242, in ?
  15.     linear_model = r.lm(model, data = d)
  16. rpy.RException: Error in eval(expr, envir, enclos) : object "x" not found
I don't use that package, but one thing stands out:
Expand|Select|Wrap|Line Numbers
  1. d = r.data_frame(x=X, y=phenotypes)
Ok; get d from the object r's data_frame() method.
Expand|Select|Wrap|Line Numbers
  1. model = r("y~x")
? What does r do when called instead of using an access method?
Expand|Select|Wrap|Line Numbers
  1. linear_model = r.lm(model, data = d)
Ok; get linear_model from the object r's lm() method.
Mar 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Michael van der Veeke | last post by:
Hi All, Does anyone use any regression testing tools with MS Access? We have tried a few and none seem to work very well with a MS Access Front end and I need one. Can anyone provide any...
15
by: nikie | last post by:
I'm a little bit stuck with NumPy here, and neither the docs nor trial&error seems to lead me anywhere: I've got a set of data points (x/y-coordinates) and want to fit a straight line through...
3
by: sql guy123 | last post by:
This is a real challenge. I hope someone is smart enough to know how to do this. I have a table TABLE1
1
by: wirecom | last post by:
Hi all, I am seeking a module that will do the equivalent of linear regression in 3D to yield a best fit a plane through a set of points (X1, Y1, Z1), (X1, Y1, Z1),... (Xn, Yn, Zn). The...
1
by: Nod Lee | last post by:
Hi all Is there any tools/objects from Microsoft that I can use to perform linear regression in webform and generate the results into a graph? If not, is there any recommendations for 3rd...
1
by: abefroeman | last post by:
I am trying to automate the regression function in the analysis tool pack. I tried to simply record myself doing a regression. When I run the macro, it cannot find the analysis tool pack. It says...
3
by: ntuyen01 | last post by:
Hi All, Does anyone has examples for Linear Regression formula using c#. Or any good third party software create this. Thanks in advance Regards, Ted
7
by: PlsHelp | last post by:
Hi every1,this is my 1st time using this forum....pls can any1 tell me how to create a code in VB that can do LINEAR REGRESSION in excel.....i'm not sure how to xplain exactly what i need but...
0
by: drfish | last post by:
Hi, I'm a complete novice when it comes to VB so need some help. I would like a macro that performs linear regression for different cell ranges each time it is run, depending on the number of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.