[R] truncated regression out-of-sample predictions
Wouterse, Fleur (IFPRI-Senegal)
F.Wouterse at cgiar.org
Wed Jul 8 23:23:22 CEST 2009
Dear all,
I am trying to implement Simar & Wilson's (2007) second algorithm and
have the following question: If I use a truncated regression on the m<n
observations, how do I get fitted values for all n observations, instead
of for m observations, which is what the command fitted returns; I would
need these to construct the left-truncation needed to draw n random
deviates.
Thanks for your help,
Fleur
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Karina Boege
Sent: Wednesday, July 08, 2009 11:18 AM
To: r-help at r-project.org
Subject: [R] bootstrapping error message "Error in t.star[r, ] <-
statistic(data, i[r, ], ...) : number of items to replace is not a
multiple of replacement length"
Hi,
I am trying to run some bootstraps with the boot package. When I run
it with 400 replicates it does it ok, but then I need to run the same
analysis but with 89, 86, 102 and 106 samples (for four different
environments), and then is when I get the error message:
> mybootstrap <- boot(Datos, mystat, 2000)
Error in t.star[r, ] <- statistic(data, i[r, ], ...) : number of
items to replace is not a multiple of replacement length
Anyone familiar with this error message?
Does anyone knows the minimum sample size for boot package to run
properly? Is there anyway to tell R how many samples should it pick
for the resampling?
If it helps, this is how my model looks like:
mymodel = lm(Datos[,4]~Datos[,1]+
Datos[,8]+Datos[,9]+Datos[,10]+Datos[,11]+Datos[,12])
summary(mymodel)
mystat <- function(a,b)
f<- lm(a[b,4]~a[b,1]+a[b,8]+ a[b,9]+a[b,10]+a[b,11]+a[b,12])$coef
mybootstrap <- boot(Datos, mystat, 2000)
INT1<-boot.ci(mybootstrap, conf=0.95, type="all", index=1)
INT2<-boot.ci(mybootstrap, conf=0.95, type="all", index=2)
INT3<-boot.ci(mybootstrap, conf=0.95, type="all", index=3)
INT4<-boot.ci(mybootstrap, conf=0.95, type="all", index=4)
INT5<-boot.ci(mybootstrap, conf=0.95, type="all", index=5)
INT6<-boot.ci(mybootstrap, conf=0.95, type="all", index=6)
INT7<-boot.ci(mybootstrap, conf=0.95, type="all", index=7)
Thanks for your help! I am new to bootstraps and to R, and I feel
pretty lonely with this
Karina Boege
______________________________________________
R-help at 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.
More information about the R-help
mailing list