The problem is that I can see a matrix with the coefficients, but not with the 
coefficients of all the simulations.

 

look at the codes now:

 

set.seed(180185)
nsim <- 10
mresultx <- matrix(-99, nrow=1000, ncol=nsim)
mresultb <- matrix(-99, nrow=1000, ncol=nsim)
for (i in 1:nsim){
# make a matrix with 5 cols of N random uniform values
N <- 200
I <- 5
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)
M <- matrix(-99, nrow=2, ncol=nsim)
M[,i] <- coef(qf05) 
} 


I am quite sure there is a mistake in the code: 
qf05 <- rq(formula = mresultb[,i] ~ mresultx[,i], tau=0.5)
because it is just generating the coefficients for one simulation, not for 10 
simulations.

 

best,

 

Julia 


Date: Thu, 7 Oct 2010 18:51:40 +0800
Subject: Re: [R] quantile regression
From: minhua...@gmail.com
To: julia.l...@hotmail.co.uk

You should define M as a vector or matrix depending on the length of coef(qf05) 
and let M[i] or M[,i] be coef(qf05).


On Thu, Oct 7, 2010 at 6:40 PM, Julia Lira <julia.l...@hotmail.co.uk> 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)
for (i in 1:nsim){
# make a matrix with 5 cols of N random uniform values
N <- 200
I <- 5
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)
M <- coef(qf05)
}


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

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

                                          
        [[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.

Reply via email to