# Use RLink to run the quantile regression function from R?

Posted 5 months ago
359 Views
|
0 Replies
|
1 Total Likes
|
 I am running a Monte Carlo simulation to compare errors from least squares method and quantile regression.I have generated the data as per below (y = x Beta + error), for three different beta's. (\[Tau] is my quantile level)The data is ready for LinearModelFit. But how can I apply the rq function in R from the quantreg library to my data?I appreciate your help. This community is awesome.Thanks in advance,Thad Set n, m and \[Tau] n = 1000; m = n; \[Tau] = 0.9; columns = 100; Generate data SeedRandom[1976]; xdata = Table[RandomVariate[NormalDistribution[], n], columns]; \[Epsilon]data = Table[RandomVariate[NormalDistribution[], n], columns]; \[Beta]data = {1/3, 1, 3}; num\[Beta] = Length[\[Beta]data]; ydata = Table[xdata \[Beta]data[[k]] + \[Epsilon]data, {k, num\[Beta]}]; data = Table[ Transpose[{xdata[[k]],ydata[[q, k]]}], {q, num\[Beta]}, {k, columns}]; Run Least Squares lsFunc = Table[LinearModelFit[#, x, x] & /@ data[[q]], {q, num\[Beta]}]; Moreover, I need the ability to extract the parameters from the quantile regression results, like I can do with LinearModelFit["BestFitParameters"] and ["FitResiduals"].