housing(MASS)
housing()所属R语言包:MASS
Frequency Table from a Copenhagen Housing Conditions Survey
从哥本哈根住房情况调查的频率表
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The housing data frame has 72 rows and 5 variables.
housing数据框有72行和5个变量。
用法----------Usage----------
housing
格式----------Format----------
Satisfaction of householders with their present housing circumstances, (High, Medium or Low, ordered factor).
其目前的住房情况,(高,中或低,有序的因素)的住户满意。
Perceived degree of influence householders have on the management of the property (High, Medium, Low).
认知程度影响住户对物业管理(高,中,低)。
Type of rental accommodation, (Tower, Atrium, Apartment, Terrace).
租住房屋(大厦,中庭,公寓,台)的类型。
Contact residents are afforded with other residents, (Low, High).
联系居民给予与其他居民(低,高)。
Frequencies: the numbers of residents in each class.
频率:每班居民的人数。
源----------Source----------
Madsen, M. (1976) Statistical analysis of multiple contingency tables. Two examples. Scand. J. Statist. 3, 97–106.
马德森,M.(1976)多个列联表的统计分析。举两个例子。 scand。研究中央集权。 3,97-106。
Cox, D. R. and Snell, E. J. (1984) Applied Statistics, Principles and Examples. Chapman & Hall.
考克斯,DR和Snell,EJ(1984),应用统计,原则和范例。查普曼和霍尔。
参考文献----------References----------
Modern Applied Statistics with S. Fourth edition. Springer.
举例----------Examples----------
options(contrasts = c("contr.treatment", "contr.poly"))
# Surrogate Poisson models[替代泊松模型]
house.glm0 <- glm(Freq ~ Infl*Type*Cont + Sat, family = poisson,
data = housing)
summary(house.glm0, cor = FALSE)
addterm(house.glm0, ~. + SatInfl+Type+Cont), test = "Chisq")
house.glm1 <- update(house.glm0, . ~ . + Sat*(Infl+Type+Cont))
summary(house.glm1, cor = FALSE)
1 - pchisq(deviance(house.glm1), house.glm1$df.residual)
dropterm(house.glm1, test = "Chisq")
addterm(house.glm1, ~. + SatInfl+Type+Cont)^2, test = "Chisq")
hnames <- lapply(housing[, -5], levels) # omit Freq[省略频率]
newData <- expand.grid(hnames)
newData$Sat <- ordered(newData$Sat)
house.pm <- predict(house.glm1, newData,
type = "response") # poisson means[泊松意味着]
house.pm <- matrix(house.pm, ncol = 3, byrow = TRUE,
dimnames = list(NULL, hnames[[1]]))
house.pr <- house.pm/drop(house.pm %*% rep(1, 3))
cbind(expand.grid(hnames[-1]), round(house.pr, 2))
# Iterative proportional scaling[迭代按比例缩放]
loglm(Freq ~ Infl*Type*Cont + Sat*(Infl+Type+Cont), data = housing)
# multinomial model[多项式模型]
library(nnet)
(house.mult<- multinom(Sat ~ Infl + Type + Cont, weights = Freq,
data = housing))
house.mult2 <- multinom(Sat ~ Infl*Type*Cont, weights = Freq,
data = housing)
anova(house.mult, house.mult2)
house.pm <- predict(house.mult, expand.grid(hnames[-1]), type = "probs")
cbind(expand.grid(hnames[-1]), round(house.pm, 2))
# proportional odds model[比例优势模型]
house.cpr <- apply(house.pr, 1, cumsum)
logit <- function(x) log(x/(1-x))
house.ld <- logit(house.cpr[2, ]) - logit(house.cpr[1, ])
(ratio <- sort(drop(house.ld)))
mean(ratio)
(house.plr <- polr(Sat ~ Infl + Type + Cont,
data = housing, weights = Freq))
house.pr1 <- predict(house.plr, expand.grid(hnames[-1]), type = "probs")
cbind(expand.grid(hnames[-1]), round(house.pr1, 2))
Fr <- matrix(housing$Freq, ncol = 3, byrow = TRUE)
2*sum(Fr*log(house.pr/house.pr1))
house.plr2 <- stepAIC(house.plr, ~.^2)
house.plr2$anova
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|