首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R:使用coefplot()时出错(“运算符对原子向量无效”)

R:使用coefplot()时出错(“运算符对原子向量无效”)
EN

Stack Overflow用户
提问于 2015-01-06 02:59:25
回答 1查看 855关注 0票数 2

我从systemfit()中得到了结果,并试图将每个方程的系数可视化。为了避免使用"$",我编写了coefplot(summary(fitsur)[["eq"]][1])

但是,我仍然得到了"$ operator对于原子向量无效“的错误。

你能帮我避免这个错误吗?

代码语言:javascript
复制
fitsur <- systemfit(list(EQ1 = rp1, EQ2 = rp2, EQ3 = rp3, EQ4 = rp6), data=data)
> summary(fitsur)[["eq"]][1]
[[1]]

OLS estimates for 'EQ1' (equation 1)

                  Estimate   Std. Error  t value  Pr(>|t|)   
(Intercept)   -2.081244665  0.820103650 -2.53778 0.0114454 * 
ID110         0.110331812  0.068478736  1.61118 0.1077442   
ID130         0.022217695  0.024279274  0.91509 0.3605675   
FPP01         -0.022953616  0.032193881 -0.71298 0.4761763   
DEP04          0.005921742  0.002822725  2.09788 0.0363958 * 
Inc_Consensus  2.004021829  0.932511596  2.14906 0.0320889 * 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.483239 on 522 degrees of freedom
Number of observations: 535 Degrees of Freedom: 522 
SSR: 1148.399037 MSE: 2.199998 Root MSE: 1.483239 
Multiple R-Squared: 0.069067 Adjusted R-Squared: 0.047666 

> coefplot(summary(fitsur)[["eq"]][1])
 Error: $ operator is invalid for atomic vectors
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-06 04:09:27

在我看来,coefplot(fitsur$eq[[1]])可能会解决你的问题。

下面是一个可重复的例子:

代码语言:javascript
复制
library(systemfit)
library(coefplot)

# this paragraph was borrowed from the systemfit manual
data( "Kmenta" )
eqDemand <- consump ~ price + income
eqSupply <- consump ~ price + farmPrice + trend
system <- list( demand = eqDemand, supply = eqSupply )
## OLS estimation
fitols <- systemfit( system, data=Kmenta )

names(fitsur) #
# [1] "eq"           "call"         "coefficients" "coefCov"      "residCovEst" 
# [6] "residCov"     "method"       "rank"         "df.residual"  "iter"        
# [11] "control"      "panelLike"   

str(fitsur$eq,list.len=2)
# List of 2
# $ :List of 14
# ..$ eqnNo          : int 1
# ..$ eqnLabel       : chr "demand"
# .. [list output truncated]
# ..- attr(*, "class")= chr "systemfit.equation"
# $ :List of 14
# ..$ eqnNo          : int 2
# ..$ eqnLabel       : chr "supply"
# .. [list output truncated]
# ..- attr(*, "class")= chr "systemfit.equation"

coefplot(fitsur$eq[[1]])
# Hit <Return> to see next plot: 
# ...shows the plot...
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27791454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档