时间分段分析错误(值彼此太接近。请更改(减少数量)起始值)
Error in time segmented analysis ( values too close each other. Please change (decreases number of) starting values)
我使用时间分段分析来获得停止研究趋势的 p 值,但它给了我一个错误
使用代码
data<-read.table(text="
Year Stopped
2015 973
2016 1025
2017 1151
2018 1384
2019 4507
2020 15557
", header=T, sep="")
library(segmented)
dput(names(data))
q.lm<-lm(Stopped ~ Year,data);summary (q.lm)
o<-segmented(q.lm,seg.Z=~Year, psi = c(2019)); summary(o)
#Error: psi values too close each other. Please change (decreases number of) starting values
#Alternatively I tried this
o<-segmented(q.lm,seg.Z=~Year, psi = NA); summary(o)
#Error: psi values too close each other. Please change (decreases number of) starting values
o$psi;slope(o);confint.segmented(o)
o.fitted<-fitted(o)
o.model<-data.frame(Year = data$Year, Percent =o.fitted)
这是我的情节,我需要获得其趋势的 p 值
任何建议将不胜感激。
尝试用 Year
拟合 log(Stopped)
。问题中的情节表明它可能值得一试。而且它还建议 2018
作为断点,而不是 2019
.
library(segmented)
q.lm <- lm(log(Stopped) ~ Year, data)
summary(q.lm)
o <- segmented(q.lm, seg.Z = ~Year, psi = 2018)
summary(o)
plot(o)
points(log(Stopped) ~ Year, data)
我使用时间分段分析来获得停止研究趋势的 p 值,但它给了我一个错误
使用代码
data<-read.table(text="
Year Stopped
2015 973
2016 1025
2017 1151
2018 1384
2019 4507
2020 15557
", header=T, sep="")
library(segmented)
dput(names(data))
q.lm<-lm(Stopped ~ Year,data);summary (q.lm)
o<-segmented(q.lm,seg.Z=~Year, psi = c(2019)); summary(o)
#Error: psi values too close each other. Please change (decreases number of) starting values
#Alternatively I tried this
o<-segmented(q.lm,seg.Z=~Year, psi = NA); summary(o)
#Error: psi values too close each other. Please change (decreases number of) starting values
o$psi;slope(o);confint.segmented(o)
o.fitted<-fitted(o)
o.model<-data.frame(Year = data$Year, Percent =o.fitted)
这是我的情节,我需要获得其趋势的 p 值
任何建议将不胜感激。
尝试用 Year
拟合 log(Stopped)
。问题中的情节表明它可能值得一试。而且它还建议 2018
作为断点,而不是 2019
.
library(segmented)
q.lm <- lm(log(Stopped) ~ Year, data)
summary(q.lm)
o <- segmented(q.lm, seg.Z = ~Year, psi = 2018)
summary(o)
plot(o)
points(log(Stopped) ~ Year, data)