[英]How to calculate confidence interval of adstock rate calculated using nls function in R?
I have calculated adstock rate for TV GRP using nls function of R. I have used below code to calculate it: 我已使用R的nls函数计算了电视GRP的广告库存率。已使用以下代码进行计算:
# 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. 此处,y变量是Total_Traffic,x变量是TV_GRP。 Now I want to calculate the confidence interval of rate.
现在我要计算速率的置信区间。 Is there any way in which I can calculate it.
有什么方法可以计算出来。 Please help.
请帮忙。
would be great to have a reproducible example, but the confint
function should work out, as specified within the nls
doc. 拥有一个可重现的示例会很棒,但是
confint
函数应该可以解决,如nls
doc中指定的那样。 Below with lm
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. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.