在R中找到摄氏温度的变化

Finding change in temperature in degree Celsius in R

我有过去 15 年的年平均空间温度数据,我想知道那段时间的温度变化。基本上,目的是看这段时间温度是否升高(indicating global warming/climate change),如果升高了多少度?那么我就可以说,比如这个时间段的温度升高了X摄氏度。

我如何在 R 中执行此操作?

示例数据

year = c(2005, 2005, 2005, 2005, 2006, 2006, 2006, 2006, 2007, 2007, 2007, 2007, 2008, 2008, 2008, 2008)
Tmean = c(24, 24.5, 25.8,25, 24.8, 25, 23.5, 23.8, 24.8, 25, 25.2, 25.8, 25.3, 25.6, 25.2, 25) 

代码

library(tidyverse)

df = data.frame(year, Tmean)


# Find the change/increase/decrease in temperature in the time period
# Stuck on method.....

这是您要找的吗?

year = c(2005, 2005, 2005, 2005, 2006, 2006, 2006, 2006, 2007, 2007, 2007, 2007, 2008, 2008, 2008, 2008)
Tmean = c(24, 24.5, 25.8,25, 24.8, 25, 23.5, 23.8, 24.8, 25, 25.2, 25.8, 25.3, 25.6, 25.2, 25) 

data = data.frame(year, Tmean)

data = data %>% group_by(year) %>% mutate(min = min(Tmean), max = max(Tmean)) %>% 
  mutate(diff = max - min)
data = data %>% select(-c(Tmean, min, max)) %>% unique()
print(data)

首先,您可以绘制数据和回归线,看看温度是否确实在升高:

ggplot(df, aes(year, Tmean)) + 
  geom_point(colour = 'deepskyblue4', size = 3) +
  geom_smooth(method = lm, linetype = 2, color = 'red4', se = FALSE) +
  theme_light() +
  theme(text = element_text(size = 16))

在这个数据集的第一年和最后几年之间,它似乎确实增加了大约 0.75 度。为了对此进行量化,我们可以 运行 线性回归模型:

model <- lm(Tmean ~ year, data = df)

summary(model)
#> 
#> Call:
#> lm(formula = Tmean ~ year, data = df)
#> 
#> Residuals:
#>      Min       1Q   Median       3Q      Max 
#> -1.28000 -0.21437  0.00625  0.25625  1.24750 
#> 
#> Coefficients:
#>              Estimate Std. Error t value Pr(>|t|)
#> (Intercept) -431.5850   284.1228  -1.519    0.151
#> year           0.2275     0.1416   1.607    0.130
#> 
#> Residual standard error: 0.6333 on 14 degrees of freedom
#> Multiple R-squared:  0.1557, Adjusted R-squared:  0.09536 
#> F-statistic: 2.581 on 1 and 14 DF,  p-value: 0.1304

这里的解释是温度平均每年升高0.2275度,即3 * 0.2275,即0.6825度。 p 值 0.130 告诉我们这种变化在统计上不显着(即可能是偶然)