1

I have calculated adstock rate for TV GRP using nls function of R. I have used below code to calculate it:

# Adstock function
adstock <- function(inp_x, rate=0){
  return(as.numeric(stats::filter(x= inp_x, filter=rate, method="recursive")))
}


rate_TV = nls((Total_Traffic)~b0+b1*adstock(TV_GRP, rate), data = loans, 
               start=c(b0=0, b1=1,rate=0.1), trace = TRUE, nls.control(maxiter = 100))
summary(rate_TV)

Here, y variable is Total_Traffic and x variable is TV_GRP. Now I want to calculate the confidence interval of rate. Is there any way in which I can calculate it. Please help.

Ankita Patnaik
  • 271
  • 1
  • 7

1 Answers1

0

would be great to have a reproducible example, but the confint function should work out, as specified within the nls doc. Below with lm

x <- c(1:100)
y <- rnorm(100)
mod <- lm(y~x)
confint(mod)

                   2.5 %      97.5 %
(Intercept) -0.759751731 -0.03777529
x           -0.002136328  0.01027562

Hope it helps.

gaut
  • 5,771
  • 1
  • 14
  • 45