Hi All

Not sure about mailing list etiquette but I thought it would good to post a 
solution for others. Thanks for the quick help!

# Purpose: test the rpy python bindings with the R plm package (Panel Data)

import rpy

# test data - the plm package needs the individual and time info in the first 
two columns of data.frame
id = [1,1,1,2,2,2,3,3,3,4,4,4]
year = [1970,1971,1972, 1970, 1971, 1972, 1970, 1971, 1972, 1970, 1971, 1972]
y = [2170, 2655, 1345, 2560, 2330, 3325, 2747, 3735, 3265,3453, 4653, 4563]
x1 = [33, 26, 33, 34, 24, 18, 25, 36, 20, 35, 56, 23]
x2 = [500, 654, 390, 845, 234, 458, 233, 234, 853, 345, 346, 345]

rpy.set_default_mode(rpy.NO_CONVERSION)

testdata = rpy.r.data_frame(ids=id, years=year, ys=y, x1s=x1, x2s=x2)
testdata_1 = rpy.r.plm_data(testdata, index = rpy.r.c("ids", "years"))
stuff = rpy.r.plm(rpy.r("ys ~ x1s"), data=testdata_1, model="within")

rpy.set_default_mode(rpy.BASIC_CONVERSION)

results = rpy.r.summary(stuff)
print results

Thanks for the help.

Ryan





>>> Peter <rpy-l...@maubp.freeserve.co.uk> 04/25/09 8:21 AM >>>
On 4/25/09, Ryan Banerjee-R <banerje...@econ.umd.edu> wrote:
>
>  Hi
>
>  I am trying to use the "plm" panel data package in R through Rpy.
>  ...
>  stuff = rpy.r.plm(("ys ~ x1s"), data=testdata_1, model="within")
>
>  rpy.set_default_mode(rpy.BASIC_CONVERSION)
>
>  results = rpy.r.summary(stuff)['CoefTable']
>
>  The program stumbles at:
>  File "py_rTest.py",
>     stuff = rpy.r.plm(("ys ~ x1s + x2s"), data=testdata_1, model="within")
>  rpy.RPy_RException: Error: inherits(object, "formula") is not TRUE
>
>  I any ideas how to get this working?

I suspect the problem is how you are trying to supply the formula (you
just used a string, "ys ~ x1s").  Read this:
http://www.warwick.ac.uk/go/peter_cock/python/lin_reg/#lm which should
help.

Peter

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list



------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to