Error in nomogram(data = df, fun = function(x) 0.5, varname = c("original.firstorder.RobustMeanAbsoluteDeviation", : argument "fit" is missing, with no default
时间: 2024-01-31 11:04:34 浏览: 106
妊娠期高血压疾病患者妊娠结束后三年慢性高血压的Nomogram 预测模型构建.pdf
非常抱歉,我之前的回答有误。在使用`nomogram()`函数时,需要指定一个已经构建好的模型作为参数`fit`,而不是使用一个预测函数。如果您有一个已经构建好的模型,可以按照如下代码构建nomogram:
```r
library(rms)
library(Hmisc)
# 构建数据框 df,包含每个变量的取值
df <- data.frame(
`original:firstorder:RobustMeanAbsoluteDeviation` = c(0, 0.5, 1),
`log-sigma-4-0-mm-3D:firstorder:InterquartileRange` = c(0, 0.5, 1),
`log-sigma-5-0-mm-3D:glszm:SmallAreaEmphasis` = c(0, 0.5, 1),
`wavelet-LLH:firstorder:InterquartileRange` = c(0, 0.5, 1),
`wavelet-LLH:firstorder:Uniformity` = c(0, 0.5, 1),
`wavelet-HHL:firstorder:Mean` = c(0, 0.5, 1),
`wavelet-HHH:firstorder:Mean` = c(0, 0.5, 1),
`wavelet-LLL:glcm:Autocorrelation` = c(0, 0.5, 1),
`wavelet-LLL:glcm:ClusterProminence` = c(0, 0.5, 1)
)
# 构建一个简单的逻辑回归模型作为示例
data <- read.csv("your_data.csv") # 读取数据
fit <- glm(y ~ ., data = data, family = binomial) # 构建逻辑回归模型
# 构建 nomogram
n <- nomogram(
fit = fit,
data = df,
varname = c(
"RobustMeanAbsoluteDeviation",
"InterquartileRange(log-sigma-4-0-mm-3D)",
"SmallAreaEmphasis(log-sigma-5-0-mm-3D)",
"InterquartileRange(wavelet-LLH)",
"Uniformity(wavelet-LLH)",
"Mean(wavelet-HHL)",
"Mean(wavelet-HHH)",
"Autocorrelation(wavelet-LLL)",
"ClusterProminence(wavelet-LLL)"
),
funlabel = "Predicted Probability",
xfrac = 0.5,
yfrac = 0.5,
ylab = "Predicted Probability",
ggtheme = theme_bw()
)
# 绘制 nomogram
plot(n, lpscale = TRUE)
```
如果您没有一个已经构建好的模型,可以使用`lrm()`函数进行逻辑回归模型的构建。具体代码如下:
```r
library(rms)
library(Hmisc)
# 构建数据框 df,包含每个变量的取值
df <- data.frame(
`original:firstorder:RobustMeanAbsoluteDeviation` = c(0, 0.5, 1),
`log-sigma-4-0-mm-3D:firstorder:InterquartileRange` = c(0, 0.5, 1),
`log-sigma-5-0-mm-3D:glszm:SmallAreaEmphasis` = c(0, 0.5, 1),
`wavelet-LLH:firstorder:InterquartileRange` = c(0, 0.5, 1),
`wavelet-LLH:firstorder:Uniformity` = c(0, 0.5, 1),
`wavelet-HHL:firstorder:Mean` = c(0, 0.5, 1),
`wavelet-HHH:firstorder:Mean` = c(0, 0.5, 1),
`wavelet-LLL:glcm:Autocorrelation` = c(0, 0.5, 1),
`wavelet-LLL:glcm:ClusterProminence` = c(0, 0.5, 1)
)
# 构建一个简单的逻辑回归模型作为示例
data <- read.csv("your_data.csv") # 读取数据
fit <- lrm(y ~ ., data = data) # 构建逻辑回归模型
# 构建 nomogram
n <- nomogram(
fit = fit,
data = df,
varname = c(
"RobustMeanAbsoluteDeviation",
"InterquartileRange(log-sigma-4-0-mm-3D)",
"SmallAreaEmphasis(log-sigma-5-0-mm-3D)",
"InterquartileRange(wavelet-LLH)",
"Uniformity(wavelet-LLH)",
"Mean(wavelet-HHL)",
"Mean(wavelet-HHH)",
"Autocorrelation(wavelet-LLL)",
"ClusterProminence(wavelet-LLL)"
),
funlabel = "Predicted Probability",
xfrac = 0.5,
yfrac = 0.5,
ylab = "Predicted Probability",
ggtheme = theme_bw()
)
# 绘制 nomogram
plot(n, lpscale = TRUE)
```
其中,`lrm()`函数与`glm()`函数类似,用于构建逻辑回归模型。
阅读全文