On Oct 7, 2010, at 6:40 AM, Julia Lira wrote:


Dear all,



I am a new user in r and I am facing some problems with the quantile regression specification. I have two matrix (mresultb and mresultx) with nrow=1000 and ncol=nsim, where I specify (let's say) nsim=10. Hence, the columns in my matrix represents each simulation of a determined variable. I need to regress each column of mresultb on mresultx. My codes are the following:



set.seed(180185)
nsim <- 10
mresultx <- matrix(-99, nrow=1000, ncol=nsim)
mresultb <- matrix(-99, nrow=1000, ncol=nsim)
#Keep constants that do not vary ....  outside the loop.
  N <- 200
  I <- 5
#Create an object to hold results.

M <- matrix(0, ncol=2, nrow=nsim)

for (i in 1:nsim){
  # make a matrix with 5 cols of N random uniform values

  u <- replicate( 5, runif(N, 0, 1) )
  # fit matrix u in another matrix of 1 column
  mu <- matrix(u, nrow=1000, ncol=1)
  # make auction-specific covariate
  x <- runif(N, 0, 1)
  mx <- matrix(rep(x,5), nrow=1000, ncol=1)
  b0 <- matrix(rep(c(1),1000), nrow=1000, ncol=1)
  #function for private cost
  c <- b0+b0*mx+mu
  #bidding strategy
  b <- mx+((I+1)/I)+((I-1)/I)*mu
  mresultb[,i] <- b
  mresultx[,i] <- mx
  qf05 <- rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)

# Use a a method of storing result that does not overwrite prior values
  M[i, ] <- coef(qf05)
}

> M
          [,1]     [,2]
 [1,] 1.546023 1.060197
 [2,] 1.593085 1.012752
 [3,] 1.561060 1.039669
 [4,] 1.555189 1.080506
 [5,] 1.595738 1.030818
 [6,] 1.599211 1.004429
 [7,] 1.572492 1.066966
 [8,] 1.619282 0.964974
 [9,] 1.595431 1.028448
[10,] 1.585927 1.023855

Not sure why you created mresultb and mresultx to accept multiple columns, sinc ewhat your really wanted was the results of the regression, but if there were a reasons then they are still there to be examined.



But I just can see the quantile regression coefficients for 1 simulation, not for each i.

Maybe this is a stupid question, but i am not so familiar with this software yet.



Thanks in advance!



Julia
                                        
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to