rmodel(sampling)
rmodel()所属R语言包:sampling
Response probability using logistic regression
响应概率采用Logistic回归
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Computes the response probabilities using logistic regression for non-response
采用logistic回归分析对非响应,响应概率计算
用法----------Usage----------
rmodel(formula,weights,X)
参数----------Arguments----------
参数:formula
the regression model formula (y~x).
回归模型公式(Y~X)。
参数:weights
vector of the weights; its length is equal to n, the sample size.
的权重向量,它的长度是等于到n,样本大小。
参数:X
the sample data frame.
的样本数据框。
值----------Value----------
The function returns the sample data frame with a new column 'prob_resp', which contains
该函数返回的样本数据框,其中包含一个新列“prob_resp”
参见----------See Also----------
rhg
rhg
实例----------Examples----------
# Example from An and Watts (New SAS procedures for Analysis of Sample Survey Data)[和瓦(抽样调查数据分析的SAS程序实例)]
# generates artificial data (a 235X3 matrix with 3 columns: state, region, income).[生成人工数据(3一个235X3矩阵,列:国家,区域,收入)。]
# the variable "state" has 2 categories ('nc' and 'sc'). [的变量“状态”有2个类别(“NC”和“SC”)。]
# the variable "region" has 3 categories (1, 2 and 3).[可变的“区域”具有3个类别,(1,2和3)。]
# the sampling frame is stratified by region within state.[抽样框是分层的区域内状态。]
# the income variable is randomly generated[收入变量是随机生成的]
data=rbind(matrix(rep("nc",165),165,1,byrow=TRUE),matrix(rep("sc",70),70,1,byrow=TRUE))
data=cbind.data.frame(data,c(rep(1,100), rep(2,50), rep(3,15), rep(1,30),rep(2,40)),
1000*runif(235))
names(data)=c("state","region","income")
# computes the population stratum sizes[计算人口阶层大小]
table(data$region,data$state)
# not run[不运行]
# nc sc[NC SC]
# 1 100 30[1 100 30]
# 2 50 40[2 50 40]
# 3 15 0[3月15日0]
# there are 5 cells with non-zero values; one draws 5 samples (1 sample in each stratum)[非零值有5个单元,一个绘制5个样品(1个样本在各阶层)]
# the sample stratum sizes are 10,5,10,4,6, respectively[样品阶层的大小是10,5,10,4,6,分别]
# the method is 'srswor' (equal probability, without replacement)[该方法是srswor“(概率相等,无需更换)]
s=strata(data,c("region","state"),size=c(10,5,10,4,6), method="srswor")
# extracts the observed data[提取所观察到的数据]
x=getdata(data,s)
# generates randomly the 'status' column (1 - respondent, 0 - nonrespondent)[随机生成的“状态”栏(1 - 0 - 答辩,无反应者)]
status=round(runif(nrow(x)))
x=cbind(x,status)
# computes the response probabilities [计算响应概率]
rmodel(x$status~x$income+x$Stratum,weights=1/x$Prob,x)
# the same example without stratification[同样的例子不分层]
rmodel(x$status~x$income,weights=1/x$Prob,x)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|