> Ok. I made a copy of the arima.r function called earima.r to put in some
print
> statements. Fair enough.
>
> Now when I run earima, the .Call statements call find the C subroutines.
>
> I know that this should be a really simple fix
Not quite simple, as it's a nasty-looking namespace problem. But there IS a
work-round using body()<-
First, copy arima from stats to an object in the global namespace; say
earima <- stats:::arima
You can confirm this still works with> earima(lh, order = c(1,0,0))
which does exactly the same as > arima(lh, order = c(1,0,0))
Now copy the earima body code - the bit between "{...}" in the source,
or what you see on the console if you say
body(earima) - into your code editor. Make your edits to that code, wrap
everything (including the {}) in an expression, and assign that amended
expression back into body(earima) using body(earima) <- expression({ revised
code here> }).
Here's what that looks like
> earima <- stats:::arima ## Make the copy
> body(earima) #Inspect original code
{
"%+%" <- function(a, b) .Call(C_TSconv, a, b)
SSinit <- match.arg(SSinit)
SS.G <- SSinit == "Gardner1980"
upARIMA <- function(mod, phi, theta) {
... ## This is the rest of the body code - don't lose any!
...
}
#To add a cat() in that, we can do
> body(erima) <- expression({
cat("Welcome to the new Arima!\n\n") ### an illustrative
cat() welcome call
"%+%" <- function(a, b) .Call(C_TSconv, a, b)
SSinit <- match.arg(SSinit)
SS.G <- SSinit == "Gardner1980"
upARIMA <- function(mod, phi, theta) {
...
...
})
And then
> earima(lh, order = c(1,0,0)) #First example from arima
#Returns (or at least displays) ...
Welcome to the new Arima!
Call:
Arima(x = lh, order = c(1, 0, 0))
Coefficients:
ar1 intercept
0.5739 2.4133
s.e. 0.1161 0.1466
sigma^2 estimated as 0.1975: log likelihood = -29.38, aic = 64.76
... which seems to be doing what you want...
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}