分位数回归的R语言实现

转载自:http://www.douban.com/note/313981246/

E文看这篇:http://www.econ.uiuc.edu/~roger/research/rq/vig.pdf
中文看这篇:http://www.xiaowanxue.com/up_files/2012121819040.html

工具:R中的quantreg包
主要的分位数回归命令:rq(),nlrq(),lprq(),boot.rq等
 
rq(formula, tau=.5, data, subset, weights, na.action, method=”br”, model = TRUE, contrasts, …)
formula:公式,形如y~x1+x2+..,y为因变量,x为自变量
tau:分位数,0-1之间
data:案例数据,包括公式中的所有变量
subset:观测值的子集
weight:为观测值赋权
na.action:用于过滤缺失值的命令
model:逻辑变量,TRUE得到模型结构
method:拟合分位数回归的方法,主要有
method=”br”,Koenker和Orey的单纯形算法(Simplex Method),这个是默认算法 ;
method=”fn”,内置点发(Frisch–Newton interior point method);
method= “pfn”, Frisch–Newton approach;
method=”fnc”,不等式约束条件下的分位数回归
method=”lasso”或者”scad”
 
 
案例:
library(quantreg)
data(engel)
attach(engel)
plot(income, foodexp, cex = 0.25, xlab = “Household Income”,
ylab = “Food Expenditure”)
points(income, foodexp, cex = 0.5, col = “blue”)
abline(rq(foodexp ~ income, tau = 0.5), col = “blue”)
abline(lm(foodexp ~ income), lty = 2, col = “red”)
taus for (i in 1:length(taus)) {
abline(rq(foodexp ~ income, tau = taus[i]), col = “gray”)
}
文章来源:http://blog.163.com/yugao1986@126/blog/static/692285082013321344148/

原文链接:http://tezhengku.com/topic/?p=832

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值