There is no qtplot help page so I went to the package help Index and saw qtplot.lmscreg listed. It had a 'pcol.arg' to control points color so I set it to "transparent": qtplot(fit4, percentiles = c(5,50,90,99), main = "Quantiles", las = 1, xlim = c(15, 90), ylab = "BMI", lwd...

Statistical comments first before getting to your question, which has two Stata answers at least. Quantile regression is defined by prediction of quantiles of the response (what you call the dependent variable). You may or may not want to do that, but using quantile-based groups for predictors does not itself...

r,ggplot2,regression,quantile,vgam

How about something like this: # required packages library(VGAM) require(reshape2) require(ggplot2) # fitted values from vgam fit4 <- vgam(BMI ~ s(age, df = c(4, 2)), lms.bcn(zero = 1), data = bmi.nz, trace = TRUE) fitted.values <- data.frame(qtplot.lmscreg(fit4, percentiles = c(5,50,90,99))$fitted.values) fitted.values[, 'age'] <- bmi.nz[, 'age'] # melt data.frame dmelt <-...

r,classification,plyr,quantile

I don't see anything wrong with your computation. Each quartile contains same number of elements only when you have a very large data set. Below I extracted Diameter for the first group. table(findInterval(diameter, quantile(diameter, c(.25, .5, .75)))) # 0 1 2 3 #22 23 24 23 sum(diameter < quantile(diameter, .25))...

r,ggplot2,quantile,density-plot

You can calculate the quantiles beforehand. Using your example data: library (dplyr) d2 <- df.example %>% group_by(model, type) %>% summarize(lower = quantile(value, probs = .025), upper = quantile(value, probs = .975)) And then plot like this: ggplot(df.example, aes(x = value)) + facet_grid(type ~ model) + geom_density(aes(fill = model, colour =...

You can try apply(obs, 1, function(x) quantile(x[x>=1], probs=.95)) ...

Building on akrun's idea, you could modify summary.default mySummary <- summary.default body(mySummary)[[3]][[3]][[4]][[3]][[4]] <- quote(qq <- stats::quantile(object, type = type)) formals(mySummary) <- c(formals(mySummary), type = 6) And now the type is 6 by default args(mySummary) # function (object, ..., digits = max(3L, getOption("digits") - # 3L), type = 6) # NULL...

General discussion: There are many different possibilities for sample quantile functions; we want them to have various properties (including being simple to understand and explain!), and depending on which properties we want most, we might prefer different definitions. As a result, the wide variety of packages between them use many...

After xtile PH_scale = PH, nq(4) this is a easy replace replace PH_scale = cond(inlist(PH_scale, 1, 4), 1, 2) Alternatively, create percentiles directly _pctile PH, nq(4) gen PH_scale = cond(PH < r(r1) | PH > r(r3), 1, 2) if PH < . Note that indicator variables are widely defined as...

Umm... use na.rm=TRUE in your call to quantile. The problem probably is that you have a variable T defined as something else that is evaluating to FALSE. This works for me here: A=matrix(seq(1,8),nrow=4) A[2,2]=NA quantile(A,probs=0.5, na.rm=TRUE) ...

You can also use unname > result <- quantile(c(1,2,3,4),0.75) > unname(result) [1] 3.25 Also you can subset by using [[ > result[[1]] [1] 3.25 ...

r,histogram,percentile,quantile

Still difficult to figure out what you are trying to accomplish, but this is my best guess: # create reproducible example - you already have this... set.seed(1) df <- data.frame(Y=sample(0:1,100000,replace=T), TOTA=runif(100000,0,18938000)) na <- sample(1:100000,5000) # 5% NA df[na,]$TOTA <- NA # you start here... breaks <- c(0,10^(2:6), 5938000, 10938000, 15938000,...

It seems that the qqplot function takes two input parameters, x and y as follows: qqplot(x, y, plot.it = TRUE, xlab = "your x-axis label", ylab="your y-axis label", ...) When you made your call as given above, you only gave one vector, hence R complained the y argument was missing....

You can use findInterval in combination with by; by(df,findInterval(df$Y,quantile(df$Y,c(0.25,0.5,0.75))),estFun) ...

Precomputing these values and plotting them separately seems like the simplest option. Doing so with dplyr requires minimal effort: library(dplyr) q.95 <- df_tot %>% group_by(Dataset) %>% summarise(Bin_q.95 = quantile(Bin, 0.95)) ggplot(data=df_tot[which(df_tot$Pdf>0),], aes(x=Bin, y=Pdf, group=Dataset, colour=Dataset)) + geom_point(aes(color=Dataset), alpha = 0.7, size=1.5) + geom_vline(data = q.95, aes(xintercept = Bin_q.95, colour =...

For the first problem: you can only use the unique breaks and pass those to cut. For the second, convert the factor to an integer and use the integer as the index in the probs vector to pull out the appropriate quantile break. ## Some sample data, the third column...

How about the cut function. Just need to include the min in your quantiles. q <- quantile(Sum.df$Values, probs = c(0, 0.33,.66,1)) Sum.df$group <- cut(Sum.df$Values, q, include.lowest=TRUE, labels=paste("Group", 1:3)) ...

r,function,arguments,simulation,quantile

An illustration of my comment above: etacor1 <- function(rho = 0, nsim = 1e4, fx = qnorm, fy = qnorm, fx.args = formals(fx), fy.args = formals(fy)){ #generate a bivariate correlated normal sample x1 <- rnorm(nsim) x2 <- rnorm(nsim) fx.arg1 <- names(formals(fx))[1] fy.arg1 <- names(formals(fy))[1] if (length(rho) == 1){ y <-...

d3.js,charts,quantile,quantization

A quantize scale won't work in this case, as your domain and range are not split uniformly. Instead, you can use a threshold scale. Here's an example: var dollars = d3.format("$,d"), data = d3.range(100).map(function(d, i) { return { revenue: parseInt(Math.random() * 1000000000), title: "Company " + i, sector: "Sector "...

matlab,loops,for-loop,distribution,quantile

Your test variable is a three-dimensional variable, so when you do test2 = test(:,1); and then test2(:) <VaR_Calib_EVT/100 it's not the same as in your second example when you do test(:,i)<(VaR_Calib_EVT(:,i)/100) To replicate the results of your first example you could explicitly do the test2 assignment inside the loop, which...

r,data.frame,rank,quantile,split-apply-combine

The idiomatic way to do this kind of thing in R would be to use a combination of split and lapply. You're halfway there with your use of lapply; you just need to use split as well. lapply(split(data, data$v1), function(df) { cutoff <- quantile(df$v2, c(0.8, 0.9)) top_pct <- ifelse(df$v2 >...

Is this what you need? ggplot() + geom_point(data=df, aes(x=sort(Obs), y=sort(Model))) + xlab('Obs') + ylab('Model') Or maybe this... df.ord = do.call('rbind', lapply(split(df, df$type), function(.d) transform(.d, Obs = sort(Obs), Model = sort(Model)))) ggplot() + geom_point(data=df.ord, aes(x=Obs, y=Model, col=type)) + facet_grid(~type) ...