全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3230 1
2011-09-25
下面是问题的简单描述:
对变量valadd,用hours,hours^2,capflow,capflow^2, hours*capflow 做线性回归:
quardratic<-lm(valadd~hours+I(hours^2)+capflow+I(capflow^2)+I(hours*capflow))

现在需要测试是否模型中的常数项和二次项系数均为0.即是否intercept=hours^2=capflow^2=hours*capflow =0

已知要用到命令
linear.hypothesis(model, hypothesis.matrix, rhs)
可是我目前还是不明白这里的hypothesis.matrix 到底怎么用。
用help(linear.hypothesis)得到的解释是:
hypothesis.matrix: matrix (or vector) giving linear combinations of coefficients by rows, or a character vector giving the hypothesis in symbolic form

可是具体到这个问题里面应该如何定义hypothesis.matrix 呢?

如果有人能给予解答,不胜感谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-12-17 18:52:47

定义hypothesis.matrix 这个问题

可以参考这个例子:

library(car)

mod.davis <- lm(weight ~ repwt, data=Davis)

## the following are equivalent:

linearHypothesis(mod.davis, diag(2), c(0,1))

linearHypothesis(mod.davis, c("(Intercept) = 0", "repwt= 1"))

linearHypothesis(mod.davis, c("(Intercept)","repwt"), c(0,1))

linearHypothesis(mod.davis, c("(Intercept)", "repwt =1"))
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群