s-news
[Top] [All Lists]

scope of functions: why objects not found in garch()?

To: "'s-news@lists.biostat.wustl.edu'" <s-news@lists.biostat.wustl.edu>
Subject: scope of functions: why objects not found in garch()?
From: Yingfu Xie <Yingfu.Xie@sekon.slu.se>
Date: Mon, 23 Aug 2004 11:27:57 +0200
Hello, all,

I had problems with a very simple function. Please take a look. I think it
to do with scope of functions. 

> temp
function(data = rnorm(1000), archcoef = 2, garchcoef = 1)
{
        data <- data
        a <- garch(formula.mean ~ -1, formula.var ~ garch(archcoef,
                garchcoef), series = data, trace = F)
        return(a)
}
> temp()
Warning messages:
  1 missing values generated coercing from character to numeric in:
        as.numeric(p1)
Problem in get(p1): Object "garchcoef" not found 
Use traceback() to see the call stack
> traceback()
9: eval(action, sys.parent())
8: doErrorAction("Problem in get(p1): Object \"garchcoef\" not found
",
7: get(p1)
6: garch.eq(formula.var, leverage = leverage)
5: garch.model(formula.mean, formula.var, leverage = leverage)
4: garch(formula.mean ~ -1, formula.var ~ garch(archcoef, garchcoef)
,
3: temp()
2: eval(expression(temp()))
1: 
Message: Problem in get(p1): Object "garchcoef" not found

I also tried get() or eval() inside but it failed and returned very strange
error message, e.g., if I change 'garchcoef' to
'eval(expression(p<-garchcoef),local=sys.parent(1))', it says:

> temp()
Warning messages:
1: argument to ':' has length 9, using first value in: nl:(nc[1] -
        1)
2: argument to ':' has length 1, using first value in: (nc[2] +
        1):nr
3: 1 missing values generated coercing from character to numeric 
        in: as.numeric(d1)
Problem in get(d1): Object "e,))1(tnerap.sys=lacol,)f" not found 
Use traceback() to see the call stack

I must have missed something. I searched the archive and found some
discussion of scope of function. But I cannot find a solution to my case
from it. Maybe my problem is related to 'garch' of Finmetrics too? 
Thank you very much for your help!

I use s-plus 6.2, OS: Win2k, and Finmetrics 1.0 (2002).


Best regards,
Yingfu 
###########################################

This message has been scanned by F-Secure 
Anti-Virus for Microsoft Exchange.

###########################################



<Prev in Thread] Current Thread [Next in Thread>
  • scope of functions: why objects not found in garch()?, Yingfu Xie <=