Dear Rui Barrada,
 
Thank you so much for your kind sharing. It's really help.
 
Regards,
Lim Hock Ann
 

________________________________
 From: Rui Barradas <ruipbarra...@sapo.pt>

Cc: R-Help <r-help@r-project.org> 
Sent: Tuesday, September 18, 2012 12:03 AM
Subject: Re: [R] Problem with Stationary Bootstrap
  

Hello,

The problem is your function calling itself until there's no more
    stack memory left.
Besides, your function doesn't make any sense. You pass an argument
    'fit' then do not used it but change it's value then return itself.
Corrected:

set.seed(1)
X <- runif(10, 0, 10)
Y <- 2 + 3*X
a <- data.frame(X = X, Y = Y)

fun <- function(a){
  fit <- lm(Y ~ X, data=a)
  return(coef(fit))
}
result <- boot::tsboot(a, statistic = fun, R = 10, sim = "geom",
    l = 10, orig.t = TRUE)

Hope this helps,

Rui Barradas


Em 17-09-2012 14:42, Hock Ann Lim escreveu:

Dear R experts,
 
I'm running the following stationary bootstrap programming to find the 
parameters estimate of a linear model:  
 
X<-runif(10,0,10)
Y<-2+3*X
a<-data.frame(X,Y)
coef<-function(fit){
  fit <- lm(Y~X,data=a)
   return(coef(fit))
}
 result<- tsboot(a,statistic=coef(fit),R = 10,n.sim = NROW(a),sim = 
"geom",orig.t = TRUE)
 
Unfortunately, I got this error message from R:
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Can someone tells me what's wrong in the programming.
 
Thank you.
 
Regards,
Lim Hock Ann [[alternative HTML version deleted]]  
> 
>
>______________________________________________ R-help@r-project.org mailing 
>list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting 
>guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.   
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to