【问题标题】:R I Plotting a confidence interval for a logarithmic - exponential fittingR I 绘制对数 - 指数拟合的置信区间
【发布时间】:2022-01-16 09:06:13
【问题描述】:

假设我有这两个向量:

 A <- c(0.06280179, 0.08216760, 0.07482619, 0.06823409, 0.06952835, 0.07018200,  0.06021379, 0.01093384, 0.01347112, 0.01426566, 0.02643976, 0.03703703, 0.04278447, 0.04821157, 0.05714920, 0.04756160, 0.02538775, 0.02267100, 0.02388572, 0.02309525, 0.0201453, 0.03132787, 0.03698205, 0.05634021, 0.06859215, 0.08044785, 0.08345671, 0.09029339, 0.08528164, 0.07538614, 0.01229222)
B <- c(0.06634636, 0.04257361, 0.04921238, 0.08225855, 0.11344899, 0.13373171, 0.14987047, 0.19256872, 0.14790440, 0.08028606, 0.06475687, 0.03736584, 0.05676217, 0.10489289, 0.17173170, 0.21296917, 0.27816564, 0.25458431, 0.29817322, 0.22127536, 0.15497217, 0.18341950, 0.14756396, 0.16856496, 0.13028875, 0.14073265, 0.11733407, 0.12458992, 0.12484860, 0.16910507, 0.28517631

我有兴趣调整对数函数并用灰色的置信区间绘制数学表达式(就像我们可以使用 stat_smooth(aes(...), method = "lm") 一样)。如何使用ggplot2 做到这一点?

提前致谢。

【问题讨论】:

    标签: r function ggplot2 model


    【解决方案1】:

    更新:

    library(tidyverse)
    df <- tibble(A, B)
    
    ggplot(df,aes(A, B)) +
      geom_point() +
      stat_smooth(method="lm",formula=y~log(x),fill="grey")+
      theme_bw()
    

    第一个答案: 你的意思是这样的吗:

    library(tidyverse)
    df <- tibble(A, B)
    
    ggplot(df,aes(A, B)) +
      stat_summary(fun.data=mean_cl_normal) + 
      geom_smooth(method='lm', formula= y~x)
    

    【讨论】:

    • 这就是我想要的,但是对于一个对数方程。
    • 对数方程是什么?拟合非线性最小二乘法?
    猜你喜欢
    • 2014-08-29
    • 2014-09-03
    • 2015-12-17
    • 2012-02-28
    • 2019-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-28
    相关资源
    最近更新 更多