search for: ybar

Displaying 20 results from an estimated 26 matches for "ybar".

Did you mean: bar
2010 Nov 16
2
Vectors out of lists?
Hello there I have a list, Y, and each component of that list is a real-valued function (that is, Y[[i]](u) returns a number). I was wishing to build the mean function and the first thing I thought of was Ybar<-function(u){ mean(Y[[1:n]](u)) } but obviously this doesn't work, since Y[[1:n]] is not allowed at all. Any elegant suggestions? I really would like to avoid something like Ybar<-function(u){ for (i in 1:n){ Ybar<-Ybar + Ybar[[i]](u) } Ybar<-1/n*Ybar } Thanks...
2008 Jul 20
4
drawing segments through points with pch=1
Please excuse me for asking such basic questions: Here is my code > y=c(1.21,0.51,0.14,1.62,-0.8,0.72,-1.71,0.84,0.02,-0.12) > ybar=mean(y) > ll=length(y); > ybarv=rep(ybar,ll) > x=1:ll > plot(x,ybarv,pch=1) > segments(x[1],ybar,x[ll],ybar) What I get is a collection of small circles, with a segment "on top" of the circles, which is almost what I want. But I don't want the segment to be visible...
2008 Jul 20
3
asp and ylim
#See David Williams' book "Weighing the odds", p286 y <- c(1.21, 0.51, 0.14, 1.62, -0.8, 0.72, -1.71, 0.84, 0.02, -0.12) ybar <- mean(y) ylength <- length(y) ybarv <- rep(ybar, ylength) x <- 1:ylength plot(x,y,asp=1,xlab="position",ylab="ybar",type="n",ylim=c(-1,1)) segments(x[1], ybar, x[ylength], ybar) segments(x,ybarv,x,y) points(x, ybarv, pch=21, bg="white") points(x...
2011 Jun 03
2
Y error bars, dates on the X-axis
...;t want to include error bars. I can also produce a nice plot with error bars, if I just use Julian days for the x-axis, but I'd much rather have the actual dates. I have tried writing my own function, plotCI {gplots} and errbar {Hmisc}. This is my own version: y.error.bars<-function(x,y,ybar){plot(x,y,pch=16,ylim=c(min(y-ybar),max(y+ybar))) arrows(x,y-ybar,x,y+ybar,code=3,angle=90,length=0.1)} y.error.bars(x,y,yb) It works if x is numeric, but once change the x variable to be a date, I get the following error message: "Error in arrows(x, y - ybar, x, y + ybar, code = 3, angle = 9...
2008 Sep 06
2
Hopefully an easy error bar question
...],xv[i]),c(yv[i]+z[i],yv[i]-z[i])) lines(c(xv[i]-g,xv[i]+g),c(yv[i]+z[i], yv[i]+z[i])) lines(c(xv[i]-g,xv[i]+g),c(yv[i]-z[i], yv[i]-z[i])) }} Have then worked out the standard errors and added that using: se<-c() and then added the final bit of code: labels<-as.character(levels(Sex2)) ybar<-as.vector(tapply(Height2,Sex2,mean)) error.bars(ybar,se,labels) So i was wondering, in order to get error bars on my barplot with two levels do i need to change the last bit of code. For example im looking at mean body condition (y) against age (x) and sex (level), i tried to change the code t...
2007 Sep 25
2
Need help with function writing
...for the data in yvec. A boxplot comparing # the treatments' data is constructed. Output is a one-row # data frame reporting the results of the test and # confidence interval ################################################## trtvec=as.factor(trtvec) boxplot(split(yvec,trtvec)) title(header) ybar=tapply(yvec,trtvec,mean) varvec=tapply(yvec,trtvec,var) nvec=table(trtvec) error.df=nvec[1]+nvec[2]-2 pooled.var=((nvec[1]-1)*varvec[1]+(nvec[2]-1)*varvec[2])/error.df diff12estimate=ybar[1]-ybar[2] stderr=sqrt(pooled.var*((1/nvec[1])+(1/nvec[2]))) tratio=diff12estimate/stderr twosidedP=2*(1-pt(abs...
2010 Nov 18
0
On efficiency, Vectorize and loops
...ion(t)local({force(t); function(u){ X3[[t]](u)+epsilon3[[t]](u) } })) Y4<-lapply(1:n, function(t)local({force(t); function(u){ crossprod(xi[,t],sqrt(2)*cos(pi*outer(1:d,u))) + crossprod(2^(1-(1:10))*Z[,t],sqrt(2)+sin(pi*outer(1:10,u))) } })) ###################### # remove later Ybar<-function(u){ Ybar<-0 for (t in 1:n){ Ybar<-Ybar+Y[[t]](u) } Ybar<-1/n*Ybar } Ybar2<-function(u){ Ybar2<-0 for (t in 1:n){ Ybar2<-Ybar2+Y2[[t]](u) } Ybar2<-1/n*Ybar2 } Ybar3<-function(u){ Ybar3<-0 for (t in 1:n){ Ybar3<-Ybar3+Y3[[t]...
2000 Jul 08
1
iteration scheme
Dear friends. On p 95 in 3. ed. MASS a zero-truncated Poisson distribution is analyzed. I understand the probability distribution and expected mean. The Newton iteration scheme is Lam(m+1)=Lam(m)-[Lam(m)-Ybar(1-exp(-Lam(m))]/[1-Ybar*exp(-Lam(m)], and I suppose the latter part should be f(Lam(m))/f ' (Lam(m)) and f(Lam(m)) is Lam(m)/(1-exp(-Lam(m)), right ? But then f ' (Lam(m)) is (exp(Lam(m)*(exp(lam(m)-Lam(m)-1)/(exp(lam(m)-1)^2 and the iterations scheme is not right ? So I got this wrong....
2002 May 09
4
Rsquared in summary(lm)
Hello, I'm doing some linear regression: >lm<-lm(osas~alp,data) >summary(lm) However, the Rsquared in the output of summary() is not the same as the "standard" Rsquared calculated by spreadsheets, and outlined in statistical guidebooks, being SSR/SSTO. The output says "multiple Rsquared", but it is no multiple regression... What's the difference? Thanks,
2002 May 11
2
Bug on Mac version of lm()?
...oeff), Std.Error=as.vector(std.err) ) cat("\n") print(t(z)) cat( "\nR-Square:", object at r.square, "\n\n" ) } ) ols1 <- function( y, x ){ size <- length(x) # number of ovservations xbar <- mean(x) ybar <- mean(y) Sxx <- sum( (x-xbar)^2 ) b <- sum( (x-xbar)*(y-ybar) )/Sxx # coefficient a <- ybar - b*xbar # interception e <- y - a - b*x # residuals # SSE (error sum of squares) SSE <- sum( e^2 ) # SST (total sum of squares) SST <- sum( (y-ybar)^2 ) # SSR (reg...
2012 Jul 18
1
Regression Identity
Hi, I see a lot of folks verify the regression identity SST = SSE + SSR numerically, but I cannot seem to find a proof. I wonder if any folks on this list could guide me to a mathematical proof of this fact. Thanks. David. -- View this message in context: http://r.789695.n4.nabble.com/Regression-Identity-tp4636829.html Sent from the R help mailing list archive at Nabble.com.
2007 Sep 24
1
hypothesis testing
...s for the data in yvec. A boxplot comparing # the treatments' data is constructed. Output is a one-row # data frame reporting the results of the test and # confidence interval ################################################## trtvec=as.factor(trtvec) boxplot(split(yvec,trtvec)) title(header) ybar=tapply(yvec,trtvec,mean) varvec=tapply(yvec,trtvec,var) nvec=table(trtvec) error.df=nvec[1]+nvec[2]-2 pooled.var=((nvec[1]-1)*varvec[1]+(nvec[2]-1)*varvec[2])/error.df diff12estimate=ybar[1]-ybar[2] stderr=sqrt(pooled.var*((1/nvec[1])+(1/nvec[2]))) tratio=diff12estimate/stderr twosidedP=2*(1-pt(abs...
2007 Nov 07
1
Homework help: t test hypothesis testing with summarized data?
Is this how a t hypothesis test is done when I don't have the actual data, but just the summarized statistics: > #Homework 9.2.6 [1] > n<-31 > xbar<-3.10 > s_x<-1.469 > m<-57 > ybar<-2.43 > s_y<-1.35 > s_pooled<- (((n-1)*s_x^2) + ((m-1)*s_y^2)) / (n + m - 2) > s_pooled [1] 1.939521 > t_obs <- (xbar - ybar) / (s_pooled * (sqrt(1/n + 1/m))) > t_obs [1] 1.547951 > qt(c(.025, .975), n+m-2) [1] -1.987934 1.987934 > # Therefore, fail to reject H0 a...
2006 Sep 27
3
t-stat Curve
Number of subjects = 25 Mean of Sample = 77 Standard Deviation (s) = 12 sem = 2.4 df = 24 The claim is that population mean is less than 80 * > 80 So our H0 (null hupotheis) is * > 80 > qt(.95,24) [1] 1.710882 > qt(0.05, 24) [1] -1.710882 tstat = -1.25 on t24 falls between 1.711 (.95,24) and *1.711 (.005,24) How Could I sketch t curve for the above data where my * would be at the
2008 Sep 30
1
Using sub to get captions in barplots
...ns are on a single line. However, when I try this for bar plots with error bars (altering the error.bars function form Crawley's The R Book, see below), the captions are split on more than 1 line. Is there a way to get the caption on a single line? Cheers, David y.bar.new = c(30, 15) se.ybar.new = c(2,3) error.bars(y.bar.new, se.ybar.new, c("Control (n=18)", "CKD (n=18)")) error.bars<-function(yv,z,nn){ xv<-barplot(yv,ylim=c(0,(max(yv)+max(z))),names=nn,ylab="Total five hour potassium excretion (mmol)", sub= "Figure 1B: Hour 1-5 potassium excr...
2005 Apr 21
2
local average
...r your help! Assume I have a matrix of two covariates: n <- 1000 Y <- runif(n) X <- runif(n,min=0,max=100) data <- cbind(Y,X) Now, I would like to compute the local average of Y for each X interval 0-1, 1-2, 2-3, ... 99-100. In other words, I would like to obtain 100 (local) Ybars, one for each X interval with width 1. Also, I would like to do the same but instead of local means of Y obtain local medians of Y for each X interval. Best, Jens
2012 Oct 25
2
error bars
...ene$AVE-RAEthylene$STD,add = TRUE,lty=2,pch=17); Today, I went to update my plot. However, in R version 2.15.1 I get error code saying that this function cannot be found: Error: could not find function "errbar" I would perfer to avoid using the xy.error.bars<-function(x, y, xbar, ybar) coding for these error bars, as I have many data to put on one plot. I've searched the .pdf file for R 2.15.1 version and cannot find any updates for this function. Do I have to reinstall version 2.13 again?? I need to generate these plots today!! Please advise. Regards, Franklin [[a...
2010 Jul 18
2
loop troubles
...em is I want to have elements from the previous posterior to be the new prior and now I cant figure out how to do the code below in a loop. The data below is dummy data, I used a starting mu of 1, and starting precision of 0. bayes.analysis.treat<-function(mu0,p0){ n1 = 5 n2 = 10 n3 = 15 ybar1 = 12 ybar2 = 13 ybar3 = 14 sd1 = 2 sd2 = 3 sd3 = 4 #posterior 1 var1 = sd1^2 #sample variance p1 = n1/var1 #sample precision p1n = p0+p1 mu1 = ((p0)/(p1n)*mu0)+((p1)/(p1n))*ybar1 sigma1 = 1/sqrt(p1n) #posterior 2 var2 = sd2^2 #sample variance p2 = n2/var2 #sample precision p2n = p1n...
2007 Mar 28
2
Suggestion for memory optimization and as.double() with friends
...n why I bring it up, is because many (most?) methods are using as.double() etc "just in case" when passing arguments to .Call(), .Fortran() etc, e.g. stats::smooth.spline(): fit <- .Fortran(R_qsbart, as.double(penalty), as.double(dofoff), x = as.double(xbar), y = as.double(ybar), w = as.double(wbar), <etc>) Your memory usage is peaking in the actual call and the garbage collector cannot clean it up until after the call. This seems to be waste of memory, especially when the objects are large (100-1000MBs). Cheers Henrik
2007 Sep 03
1
how to compute cross correlation
Hello R Users, How to compute cross correlation between two time series. Data is in ASCII format. I am using R on windows. Many thanks, Regards, Yogesh [[alternative HTML version deleted]]