仅从 predict.nls 获取单个值 - 为什么?
Only getting a single value from predict.nls - why?
我是 运行 以下获得 predicted/fitted 值的人:
library(RCurl)
data <- getURL("https://gist.githubusercontent.com/aronlindberg/a8a6644a639c35ceb9d9/raw/5b7c13bbcd439dacbca70e07c96b6c33804273d2/data.csv")
object <- read.csv(text = data)
mod <- nls(formula = "solution_complexity ~ problem_complexity", data=object, start = list(problem_complexity=0))
predict(mod)
但是,这只给了我一个值。我怎样才能得到所有的预测值?
如果我这样做
predict(mod, newdata = object[, "problem_complexity", drop = FALSE])
[1] 2 6 4 3 3 4 8 16 7 5 3 12 4 3 9 2 1 5 1 1 4 6 2 5
它似乎有效。
我是 运行 以下获得 predicted/fitted 值的人:
library(RCurl)
data <- getURL("https://gist.githubusercontent.com/aronlindberg/a8a6644a639c35ceb9d9/raw/5b7c13bbcd439dacbca70e07c96b6c33804273d2/data.csv")
object <- read.csv(text = data)
mod <- nls(formula = "solution_complexity ~ problem_complexity", data=object, start = list(problem_complexity=0))
predict(mod)
但是,这只给了我一个值。我怎样才能得到所有的预测值?
如果我这样做
predict(mod, newdata = object[, "problem_complexity", drop = FALSE])
[1] 2 6 4 3 3 4 8 16 7 5 3 12 4 3 9 2 1 5 1 1 4 6 2 5
它似乎有效。