Ask Your Question
0

linear regression with R in sagemath

asked 2016-08-24 17:49:25 +0100

debian_economist gravatar image

updated 2016-08-24 17:55:25 +0100

Hi,

I know it is possible to do a linear regression directly inside sage. However, I was wondering if it was possible to call the lm function from R to do it as well. I tried the following code:

reader = r.read_csv('"databrent2.csv"', header=true, sep='";"')    
a =  r.lm(LLCCS00 ~ OILBRNP, data = reader)

LLCCS00 and OILBRNP are my two variables. They are in row. It is time series so for each variable, there is a value at each date (dates are columns). The issue I have is that I have a syntax error. I don't understand why.

edit retag flag offensive close merge delete

Comments

It would be helpful if you provide the complete error message you got.

vdelecroix gravatar imagevdelecroix ( 2016-08-24 19:04:28 +0100 )edit

File "<ipython-input-4-8b7ce4bd7df2>", line 2 a = r.lm(LLCCS00 ~ OILBRNP, data = reader) ^ SyntaxError: invalid syntax

debian_economist gravatar imagedebian_economist ( 2016-08-25 17:44:43 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-25 15:03:02 +0100

calc314 gravatar image

From the documentation at http://doc.sagemath.org/html/en/refer..., it looks like the tilde operator is not recognized. So, I think you need the following:

a =  r.lm(LLCCS00.tilde(OILBRNP), data = reader)
edit flag offensive delete link more

Comments

Thank you for the hint. Now, I have an other issue: name "LLCCS00" is not defined.It seems to be a Python error. EDIT: The equivalent command works in R studio.

debian_economist gravatar imagedebian_economist ( 2016-08-25 17:46:29 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-24 17:49:25 +0100

Seen: 651 times

Last updated: Aug 25 '16