分位数回归 in R
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
中文看这篇: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