First time here? Check out the FAQ!

Ask Your Question
0

linear regression with R in sagemath

asked 8 years ago

debian_economist gravatar image

updated 8 years ago

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.

Preview: (hide)

Comments

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

vdelecroix gravatar imagevdelecroix ( 8 years ago )

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

debian_economist gravatar imagedebian_economist ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 8 years ago

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)
Preview: (hide)
link

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 ( 8 years ago )

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: 8 years ago

Seen: 726 times

Last updated: Aug 25 '16