简体   繁体   English

如何计算在R中使用nls函数计算的广告费率的置信区间?

[英]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.

相关问题 如何使用R中的“引导函数”计算置信区间 - How to calculate confidence interval using the "bootstrap function" in R 如何使用R获得函数的置信区间 - How to get the confidence interval for a function using R 如何计算 predict() R function 的预测差异的置信区间? - How to calculate the confidence interval for the difference in predictions of the predict() R function? 如何计算 R 中向量的置信区间(使用“binom.confint”)? - How to calculate the confidence interval (using “binom.confint”) for a vector in R? 如何在不使用 confint 的情况下计算 R 中均值的置信区间 - How can I calculate confidence interval for a mean in R not using confint R 如何根据比例计算置信区间 - R how to calculate confidence interval based on proportion 如何计算 R 中某个比例的 95% 置信区间? - How to calculate 95% confidence interval for a proportion in R? 是否有用于从 nls 模型计算插值 X 的 95% 置信区间的 R 函数? - Is there an R function for computing 95% confidence interval of interpolated X from an nls model? 计算 R 中值的置信区间 - calculate confidence interval for value in R 是否有使用 Clopper-Pearson 置信区间计算所需样本量的 R 函数? - Is there an R function to calculate the required sample size using the Clopper-Pearson Confidence Interval?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM