Hello, I am trying to make the following code work.
-------------------------------------------------------- import rpy2.robjects as robjects r = robjects.r r.library("fGarch") def garch(p, q): robjects.globalEnv["var_r"] = robjects.FloatVector([4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14]) robjects.globalEnv["var_t"] = robjects.FloatVector([4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69]) lm = r.lm("var_r ~ var_t") print r.anova(lm) robjects.globalEnv["res"] = r.garchFit("data ~ garch("+str(p)+","+str(q)+")", "data=var_r") print r.summary("res") if __name__ == "__main__": garch(1, 1) ---------------------------------------------------------- And the answer. ---------------------------------------------------------- Analysis of Variance Table Response: var_r Df Sum Sq Mean Sq F value Pr(>F) var_t 1 0.64094 0.64094 2.1197 0.1835 Residuals 8 2.41902 0.30238 Traceback (most recent call last): File "D:\Devel\workspace\Model\src\libstrategist\modelRE\garch.py", line 16, in <module> garch(1, 1) File "D:\Devel\workspace\Model\src\libstrategist\modelRE\garch.py", line 11, in garch robjects.globalEnv["res"] = r.garchFit("data ~ garch("+str(p)+","+str(q)+")", "data=var_r") File "C:\Python25\Lib\site-packages\rpy2\robjects\__init__.py", line 407, in __call__ res = super(RFunction, self).__call__(*new_args, **new_kwargs) rinterface.RRuntimeError: Error in if (allVarsTest != 1) { : missing value where TRUE/FALSE needed Loading required package: timeDate Loading required package: timeSeries Loading required package: fBasics Loading required package: MASS Warning messages: 1: package 'fGarch' was built under R version 2.7.2 2: package 'timeDate' was built under R version 2.7.2 3: package 'timeSeries' was built under R version 2.7.2 4: package 'fBasics' was built under R version 2.7.2 Error in if (allVarsTest != 1) { : missing value where TRUE/FALSE needed In addition: Warning message: In data(data = var_r) : data set 'var_r' not found ---------------------------------------------------------- I don't understand why lm can see var_r and why garchFit don't. Thank you for any help! Frédéric This message (and any associated files) is intended only for the use of the individual or entity to which it is addressed and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not the intended recipient you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Internet communications cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. Therefore, we do not accept responsibility for any errors or omissions that are present in this message, or any attachment, that have arisen as a result of e-mail transmission. If verification is required, please request a hard-copy version. Any views or opinions presented are solely those of the author and do not necessarily represent those of the company. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list