Dear R-experts,
Here below, my R code working BUT I get a strange result I was not expecting!
Indeed, the 95% percentile bootstrap CIs is (-54.81, -54.81 ). Is anything
going wrong?
Best,
##
Score=c(345,564,467,675,432,346,476,512,567,543,234,435,654,411
On 13/01/2024 3:33 p.m., varin sacha via R-help wrote:
Score=c(345,564,467,675,432,346,476,512,567,543,234,435,654,411,356,658,432,345,432,345,
345,456,543,501)
Country=c("Italy", "Italy", "Italy", "Turkey", "Turkey", "Turkey",
"USA", "USA", "USA", "Korea", "Korea", "Korea", "Portugal", "Po
В Sat, 13 Jan 2024 20:33:47 + (UTC)
varin sacha via R-help пишет:
> coef(lm(Score~ Time + factor(Country)),data=data[idx,])
Wrong place for the data=... argument. You meant to give it to lm(...),
but in the end it went to coef(...). Without the data=... argument, the
formula passed to lm() p
Dear Duncan,
Dear Ivan,
I really thank you a lot for your response.
So, if I correctly understand your answers the problem is coming from this line:
coef(lm(Score~ Time + factor(Country)),data=data[idx,])
This line should be:
coef(lm(Score~ Time + factor(Country),data=data[idx,]))
If yes, now I
It took me a little while to figure this out, but: the problem is
that if your resampling leaves out any countries (which is very likely),
your model applied to the bootstrapped data will have fewer coefficients
than your original model.
I tried this:
cc <- unique(e$Country)
func <- functio
Sorry, didn't cc this to the list.
Forwarded Message
Subject: Re: [R] Strange results : bootrstrp CIs
Date: Sat, 13 Jan 2024 17:37:19 -0500
From: Duncan Murdoch
To: varin sacha
You can debug things like this by setting options(error = recover). That
will drop into the debug
Well, this would seem to work:
e <- data.frame(Score = Score
, Country = factor(Country)
, Time = Time)
ncountry <- nlevels(e$Country)
func= function(dat,idx) {
if(length(unique(dat[idx,'Country'])) < ncountry) NA
else coef(lm(Score~ Time + Country,data = dat[idx,]
On Sat, 13 Jan 2024 17:59:16 -0500
Duncan Murdoch wrote:
> My guess is that one of the bootstrap samples had a different
> selection of countries, so factor(Country) had different levels, and
> that would really mess things up.
>
> You'll need to decide how to handle that: If you are trying t
On Sat, 13 Jan 2024 16:54:01 -0800
Bert Gunter wrote:
> Well, this would seem to work:
>
> e <- data.frame(Score = Score
> , Country = factor(Country)
> , Time = Time)
>
> ncountry <- nlevels(e$Country)
> func= function(dat,idx) {
>if(length(unique(dat[idx,'Count
9 matches
Mail list logo