PublicSchools(sandwich)
PublicSchools()所属R语言包:sandwich
US Expenditures for Public Schools
美国公立学校的开支
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Per capita expenditure on public schools and per capita income by state in 1979.
上公立学校的人均支出和人均收入由国家于1979年。
用法----------Usage----------
data(PublicSchools)
格式----------Format----------
A data frame containing 51 observations of 2 variables.
一个数据框包含51的2个变量的意见。
Expenditure per capita expenditure on public schools,
人均消费性支出公立学校的开支,
Income per capita income.
人均收入的收入。
源----------Source----------
Table 14.1 in Greene (1993)
表14.1格林(1993)
参考文献----------References----------
of Unknown Form, Computational Statistics \& Data Analysis, 45, 215-233.
Macmillan Publishing Company, New York.
United States. US Government Printing Office, Washington, DC.
实例----------Examples----------
## Willam H. Greene, Econometric Analysis, 2nd Ed.[#威廉姆H.格林,计量分析,第二版。]
## Chapter 14[#第14章]
## load data set, p. 385, Table 14.1[#负载数据组检测号码。 385表14.1]
data(PublicSchools)
## omit NA in Wisconsin and scale income[#省略NA在威斯康星州和规模收益。]
ps <- na.omit(PublicSchools)
ps$Income <- ps$Income * 0.0001
## fit quadratic regression, p. 385, Table 14.2[适合二次回归,P。 385表14.2]
fmq <- lm(Expenditure ~ Income + I(Income^2), data = ps)
summary(fmq)
## compare standard and HC0 standard errors[#比较标准和HC0标准误差。]
## p. 391, Table 14.3[#P。 391表14.3]
library(sandwich)
coef(fmq)
sqrt(diag(vcovHC(fmq, type = "const")))
sqrt(diag(vcovHC(fmq, type = "HC0")))
if(require(lmtest)) {
## compare t ratio[#比较t比]
coeftest(fmq, vcov = vcovHC(fmq, type = "HC0"))
## White test, p. 393, Example 14.5[#白检验,p。 393例14.5]
wt <- lm(residuals(fmq)^2 ~ poly(Income, 4), data = ps)
wt.stat <- summary(wt)$r.squared * nrow(ps)
c(wt.stat, pchisq(wt.stat, df = 3, lower = FALSE))
## Bresch-Pagan test, p. 395, Example 14.7[#Bresch异教检验,p。 395例14.7]
bptest(fmq, studentize = FALSE)
bptest(fmq)
## Francisco Cribari-Neto, Asymptotic Inference, CSDA 45[旧金山克里巴里托,渐近推断,CSDA 45#]
## quasi z-tests, p. 229, Table 8[#拟Z-测试中,P。 229,表8]
## with Alaska[#与阿拉斯加]
coeftest(fmq, df = Inf)[3,4]
coeftest(fmq, df = Inf, vcov = vcovHC(fmq, type = "HC0"))[3,4]
coeftest(fmq, df = Inf, vcov = vcovHC(fmq, type = "HC3"))[3,4]
coeftest(fmq, df = Inf, vcov = vcovHC(fmq, type = "HC4"))[3,4]
## without Alaska (observation 2)[#而阿拉斯加(观察)]
fmq1 <- lm(Expenditure ~ Income + I(Income^2), data = ps[-2,])
coeftest(fmq1, df = Inf)[3,4]
coeftest(fmq1, df = Inf, vcov = vcovHC(fmq1, type = "HC0"))[3,4]
coeftest(fmq1, df = Inf, vcov = vcovHC(fmq1, type = "HC3"))[3,4]
coeftest(fmq1, df = Inf, vcov = vcovHC(fmq1, type = "HC4"))[3,4]
}
## visualization, p. 230, Figure 1[#可视化检测号码。 230,图1中]
plot(Expenditure ~ Income, data = ps,
xlab = "per capita income",
ylab = "per capita spending on public schools")
inc <- seq(0.5, 1.2, by = 0.001)
lines(inc, predict(fmq, data.frame(Income = inc)), col = 4)
fml <- lm(Expenditure ~ Income, data = ps)
abline(fml)
text(ps[2,2], ps[2,1], rownames(ps)[2], pos = 2)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|