如何提取 bfast 对象的斜率
How to extract the slope of a bfast object
我对 R 中 bfast 函数的结果有疑问。假设我有一个没有检测到中断的时间序列。
library(bfast)
library(zoo)
NDVI <- as.ts(zoo(som$NDVI.b,som$Time))
NDVI_w <- window(NDVI, c(2001, 4) , c(2008, 13))
fit <- bfast(NDVI_w, h=1/2, season="dummy", max.iter=1)
plot(fit)
如何从 bfast(拟合)对象中提取趋势分量的斜率值? ANOVA=TRUE 的选项 'plot' 不起作用。
plot(fit, ANOVA=TRUE)$slope
一个选项可能是,根据提供的趋势组件计算它,但是有什么方法可以直接从 'fit' 对象中获取它吗?
out <- fit$output[[1]]
plot(out$Tt)
lm(out$Tt ~ time(out$Tt))$coefficients[2]
非常感谢任何提示。
您已经知道(大概是从帮助文件中)趋势分量由fit$output[[1]]$Tt
给出。
你说你想要"slope value of the trend component"。因此,只需从前两个趋势值中获取斜率:
diff(fit$output[[1]]$Tt[1:2])/diff(time(fit$output[[1]]$Tt)[1:2])
.
我对 R 中 bfast 函数的结果有疑问。假设我有一个没有检测到中断的时间序列。
library(bfast)
library(zoo)
NDVI <- as.ts(zoo(som$NDVI.b,som$Time))
NDVI_w <- window(NDVI, c(2001, 4) , c(2008, 13))
fit <- bfast(NDVI_w, h=1/2, season="dummy", max.iter=1)
plot(fit)
如何从 bfast(拟合)对象中提取趋势分量的斜率值? ANOVA=TRUE 的选项 'plot' 不起作用。
plot(fit, ANOVA=TRUE)$slope
一个选项可能是,根据提供的趋势组件计算它,但是有什么方法可以直接从 'fit' 对象中获取它吗?
out <- fit$output[[1]]
plot(out$Tt)
lm(out$Tt ~ time(out$Tt))$coefficients[2]
非常感谢任何提示。
您已经知道(大概是从帮助文件中)趋势分量由fit$output[[1]]$Tt
给出。
你说你想要"slope value of the trend component"。因此,只需从前两个趋势值中获取斜率:
diff(fit$output[[1]]$Tt[1:2])/diff(time(fit$output[[1]]$Tt)[1:2])
.