Error in eval(predvars, data, env) : object ‘**‘ not found

Error in eval(predvars, data, env) : object ‘**’ not found

目录

Error in eval(predvars, data, env) : object ‘**’ not found

#问题

#解决

#完整错误

Error in eval(predvars, data, env) : object ‘**‘ not found

#问题

新数据中的变量的名称和训练模型中的变量名称不同

#create data
df <- data.frame(x1="c(3," 4, 5, 6, 7, 8, 11, 12), x2="c(6," 9, 13, 14, 14), y="c(22," 24, 25, 27, 29, 31, 32, 36)) #fit multiple linear regression model <- lm(y ~ x1 + x2, data="df)" #define new observation data.frame(x_1="c(5)," x_2="c(10))" #use the fitted to predict value for predict(model, newdata="new)</code"></->

#解决

#create data
df <- data.frame(x1="c(3," 4, 5, 6, 7, 8, 11, 12), x2="c(6," 9, 13, 14, 14), y="c(22," 24, 25, 27, 29, 31, 32, 36)) #fit multiple linear regression model <- lm(y ~ x1 + x2, data="df)" #define new observation #use the fitted to predict value for predict(model, newdata="new)</code"></->

create data

df

#完整错误

str(df)
‘data.frame’: 6 obs. of 3 variables:
$ team : chr “B” “B” “B” “A” …

$ points : num 12 28 19 22 32 45
$ rebounds: num 5 7 7 12 11 4

library(ggplot2)

ggplot(df, aes(x=team)) +
+ geom_bar()

specify factor level order

df$team = factor(df$team, levels = c(‘C’, ‘A’, ‘B’))

create bar chart again

ggplot(df, aes(x=team)) +
+ geom_bar()
library(ggplot2)

ggplot(df, aes(x=reorder(team, team, function(x)-length(x)))) +
+ geom_bar()
library(ggplot2)

ggplot(df, aes(x=reorder(team, team, function(x) length(x)))) +
+ geom_bar()

create dataset

data

Call:
lm(formula = y ~ x, data = data)

Residuals:
Min 1Q Median 3Q Max
-1.4444 -0.8013 -0.2426 0.5978 2.2363

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.20041 0.56730 7.404 5.16e-06
x 1.84036 0.07857 23.423 5.13e-12

Signif. codes: 0 ‘‘ 0.001 ‘‘ 0.01 ‘‘ 0.05 ‘.’ 0.1 ‘ ‘ 1

Residual standard error: 3.127 on 29 degrees of freedom
Multiple R-squared: 0.7482, Adjusted R-squared: 0.7309
F-statistic: 43.09 on 2 and 29 DF, p-value: 2.062e-09

Coefficients:
+ Estimate Std. Error t value Pr(>|t|)
Error: unexpected symbol in:
“Coefficients:
Estimate Std.”
(Intercept) 30.735904 1.331566 23.083 < 2e-16
Error: unexpected numeric constant in “(Intercept) 30.735904”
disp -0.030346 0.007405 -4.098 0.000306

Error: unexpected numeric constant in ” disp -0.030346 0.007405″
hp -0.024840 0.013385 -1.856 0.073679 .
Error: unexpected numeric constant in ” hp -0.024840 0.013385″


  • Signif. codes: 0 ‘‘ 0.001 ‘‘ 0.01 ‘‘ 0.05 ‘.’ 0.1 ‘ ‘ 1
    Error: unexpected symbol in:
    “—
    Signif. codes”

Residual standard error: 3.127 on 29 degrees of freedom
Error: unexpected symbol in “Residual standard”
Multiple R-squared: 0.7482, Adjusted R-squared: 0.7309
Error: unexpected symbol in “Multiple R”
F-statistic: 43.09 on 2 and 29 DF, p-value: 2.062e-09
Error: unexpected symbol in “F-statistic: 43.09 on”

calculate DFBETAS for each observation in the model

dfbetas

Call:
lm(formula = mpg ~ disp + hp, data = mtcars)

Residuals:
Min 1Q Median 3Q Max
-4.7945 -2.3036 -0.8246 1.8582 6.9363

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 30.735904 1.331566 23.083 < 2e-16
disp -0.030346 0.007405 -4.098 0.000306

hp -0.024840 0.013385 -1.856 0.073679 .

Original: https://blog.csdn.net/zhongkeyuanchongqing/article/details/120601293
Author: Data+Science+Insight
Title: Error in eval(predvars, data, env) : object ‘**‘ not found

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/649564/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球