Hi,

I am having a number of problems using rpy with locfit. One example of a problem is the following code:

import re
import rpy
from scipy import rand
from math import sin


r = rpy.r
rpy.set_default_mode (rpy.NO_CONVERSION)
r.library("locfit")
x = []
y = []
for i in range(0, 1000):
    x.append(i)
    y.append(sin(i/300) + rand())
r.assign("x", x)
r.assign("y", y)

alpha = 63.0
r.assign("alpha", alpha)
# Calculation 1
residuals = r("residuals(locfit(y~x, alpha = alpha, deg = 1, maxk=1000))")
rpy.set_default_mode(rpy.BASIC_CONVERSION)
print "residuals calculation 1"
print rpy.r.summary(residuals)

# Calculation 2
rpy.set_default_mode(rpy.NO_CONVERSION)
test1 = r("locfit(y~x, alpha = alpha, deg = 1, maxk=1000)")
residuals = r.residuals(test1)
rpy.set_default_mode (rpy.BASIC_CONVERSION)
print "residuals calculation 2"
print rpy.r.summary(residuals)

# Calculation 3
rpy.set_default_mode(rpy.NO_CONVERSION)
fit = r.locfit(r("y~x"), alpha = alpha, deg = 1, maxk=1000)
residuals = r.residuals(fit)
rpy.set_default_mode(rpy.BASIC_CONVERSION)
print rpy.r.summary(residuals)

The program crashes in calculation 3 when I try to pass fit to r.residuals. I include the print out from Eclipse.

I would appreciate any help.

Thanks,
Jurek.


RHOME= C:\ProgramFiles\R\R-2.2.1pat
RVERSION= 2.2.1
RVER= 2021
RUSER= C:\Documents and Settings\rapture
Loading the R DLL C:\ProgramFiles\R\R- 2.2.1pat\bin\R.dll .. Done.
Loading Rpy version 2021 .. Done.
Creating the R object 'r' ..  Done
Loading required package: akima
Loading required package: lattice
locfit 1.5-3      2006-04-06
residuals calculation 1
{'Min.': -1.226, '1st Qu.': -0.29999999999999999, '3rd Qu.': 0.35510000000000003, 'Median': 0.019230000000000001, 'Max.': 0.94179999999999997, 'Mean': 5.8970000000000005e-007}
residuals calculation 2
{'Min.': -1.226 , '1st Qu.': -0.29999999999999999, '3rd Qu.': 0.35510000000000003, 'Median': 0.019230000000000001, 'Max.': 0.94179999999999997, 'Mean': 5.8970000000000005e-007}
Traceback (most recent call last):
  File "C:\cygwin\home\RPYProblemExample.py", line 37, in ?
    residuals = r.residuals(fit)
rpy.RException: Error in m[[1]] == "locfit.raw" : comparison (1) is possible only for atomic and list types


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to