David:
Response=rbinom(50,1,0.2), and yhat=runif(50) are simulating the output of a 
say logistic model, where Response is actual 0-1 responses, and yhat is the 
predicted
response variable. 
I usually resample the original data to get some noise out of the data. I find 
it valuable if I can resample from a large sample than the original. 
(I know this is viewed by some as unorthodox.)

Your point: I only need Response as a column vector. 
That said, what would you alter, please?
Thanks for your time.
Regards, 
Bruce

______________
Bruce Ratner PhD
The Significant Statistician™
(516) 791-3544
Statistical Predictive Analytics -- www.DMSTAT1.com
Machine-Learning Data Mining -- www.GenIQ.net



> On Apr 21, 2017, at 3:43 PM, David L Carlson <dcarl...@tamu.edu> wrote:
> 
> You have an issue at the top with
> 
> Resp <- data.frame(Response=rbinom(50,1,0.2), yhat=runif(50))
> Resp <- Resp[order(Response$yhat,decreasing=TRUE),]
> 
> Since Response$yhat has not been defined at this point. Presumably you want
> 
> Resp <- Resp[order(Resp$yhat,decreasing=TRUE),]
> 
> The main issue is that you have a variable Response that is located in a data 
> frame called ResponseX10. 
> 
> In creating cum_R you need
> 
> cum_R    <- with(ResponseX10, cumsum(Response))
> 
> then dec_mean
> 
> dec_mean <- with(ResponseX10, aggregate(Response, by=list(decc), mean))
> 
> then dd
> 
> dd  <- with(ResponseX10, cbind(Response, dd_))
> 
> 
> You might consider if Response really needs to be inside a data frame that 
> consists of a single column (maybe you do if you need to keep track of the 
> row numbers). If you just worked with the vector Response, you would not have 
> to use with() or attach().
> 
> I'm not sure what the first few lines of your code are intended to do. You 
> choose random binomial values and uniform random values and then order the 
> first by the second. But rbinom() is selecting random values so what is the 
> purpose of randomizing random values? If the real data consist of a vector of 
> 1's and 0's and those need to be randomized, sample(data) will do it for you.
> 
> Then those numbers are replicated 10 times. Why not just select 500 values 
> using rbinom() initially?
> 
> 
> David C
> 
> 
> -----Original Message-----
> From: BR_email [mailto:b...@dmstat1.com] 
> Sent: Friday, April 21, 2017 1:22 PM
> To: David L Carlson <dcarl...@tamu.edu>; r-help@r-project.org
> Subject: Re: [R] Looking for a package to replace xtable
> 
> David:
> I tried somethings and got a little more working.
> Now, I am struck at last line provided: "dec_mean    <- 
> aggregate(Response ~ decc, dd, mean)"
> Any help is appreciated.
> Bruce
> 
> *****
> Resp <- data.frame(Response=rbinom(50,1,0.2), yhat=runif(50))
> Resp <- Resp[order(Response$yhat,decreasing=TRUE),]
> 
> ResponseX10    <- do.call(rbind, replicate(10, Resp, simplify=FALSE))
> str(ResponseX10)
> 
> ResponseX10    <- ResponseX10[order(ResponseX10$yhat,decreasing=TRUE),]
> 
> str(ResponseX10)
> head(ResponseX10)
> 
> ResponseX10[[2]] <- NULL
> ResponseX10 <- data.frame(ResponseX10)
> str(ResponseX10)
> 
> cum_R    <- cumsum(Response)
> cum_R
> 
> sam_size <- n

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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