Displaying 12 results from an estimated 12 matches for "smean".
Did you mean:
mean
2016 Apr 03
1
apply mean function to a subset of data
Here are several ways to get there, but your original loop is fine once it is corrected:
> for (i in 1:2) smean[i] <- mean(toy$diam[toy$group==i][1:nsel[i]])
> smean
[1] 0.271489 1.117015
Using sapply() to hide the loop:
> smean <- sapply(1:2, function(x) mean((toy$diam[toy$group==x])[1:nsel[x]]))
> smean
[1] 0.271489 1.117015
Or use head()
> smean <- sapply(1:2, function(x) mean(head(...
2007 Apr 21
0
possible bug in xYplot and smean.cl.normal
I'm using R (2.4.1) and Hmisc (3.3-1), and I'd like to plot confidence
intervals using xYplot and smean.cl.normal (or smean.cl.boot) from Hmisc.
You can do that using the summarize() to produce a new data.frame and then
plot with xYplot, or by specifying method=smean.cl.normal in the xYplot.
Both produce very similar graphs in all trivial examples I've tried, but not
in the attached dataset, wher...
2016 Apr 02
3
apply mean function to a subset of data
...from
group 2 and calculate the mean as well. So far I've been using a for loop
for doing it but when it comes to a large data set is rather inefficient.
Any hint to vectorize this would be appreciated.
toy = data.frame(group = c(rep(1,10),rep(2,8)), diam =
c(rnorm(10),rnorm(8)))
nsel = c(6,4)
smean <- c(0,0)
for (i in 1:2) smean[i] <- mean(toy$diam[1:nsel[i]])
Thanks
Pedro
[[alternative HTML version deleted]]
2016 Apr 02
0
apply mean function to a subset of data
...an as well. So far I've been using a for loop
> for doing it but when it comes to a large data set is rather inefficient.
> Any hint to vectorize this would be appreciated.
>
> toy = data.frame(group = c(rep(1,10),rep(2,8)), diam =
> c(rnorm(10),rnorm(8)))
> nsel = c(6,4)
> smean <- c(0,0)
> for (i in 1:2) smean[i] <- mean(toy$diam[1:nsel[i]])
>
> Thanks
>
> Pedro
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https:/...
2009 Nov 16
2
Conditional statement
...model in discrete time.
The problem is that the stochastic parameters should not be negative and sometimes they happen to be.
How can I conditionate it to when it draws a negative number, it transforms into zero in that time step?
Here is the function:
stochastic_prost <- function(Fmean, Fsd, Smean, Ssd, f, s, n, time, out=FALSE, plot=TRUE) {
nt <- rep(0, time)
nt[1] <- n
for(n in 2:time) {
nt[n] <- 0.5*rnorm(1, Fmean, Fsd)*rnorm(1, Smean, Ssd)*exp(1)^(-(f+s)*nt[n-1])*nt[n-1]}
if(out==TRUE) {print(data.frame(nt))}
if(plot==TRUE) {plot(1:time, nt, type='l', main='Simulatio...
2004 Dec 03
1
Difficulty implementing "scales" in a lattice plot
...levels and the mean values for these levels are being plotted with CIs.
I am trying to reduce the text size for the labels for this variable. The first function below does not attempt to set the text size for the y axes, and all works well.
xx2 <- with(xx,summarize(q27a, llist(Scanf,bumo), smean.cl.boot, conf.int=.90))
Dotplot(Scanf ~ Cbind(q27a,Lower, Upper)| bumo, xlim=c(5,10),cex=.6, par.strip.text=list(cex=.8), xlab="",main="", data=xx2)
Now, when I add to the above function, scales=(cex=.5), as I show in the function below, the graph reduces the size of the y l...
2006 Feb 08
1
Simple optim - question
Hello,
I want to find the parameters mu and sigma that minimize the following
function.
It's important, that mu and sigma are strictly positive.
-----------------
optimiere = function(fmean,smean,d,x,mu,sigma)
{
merk = c()
for (i in 1:length(d))
merk=c(merk,1/(d[i]^2)*(d[i]-1/(fmean*(1-plnorm(x[i],mu,sigma))))^2)
return(sum(merk))
}
-----------------
To do that I'm using the nlm function, but I only get results for ONE of the
two parameters.
I cannot cope with optimizing the two para...
2002 May 23
2
crosstabulation of means
Hello, I am trying to print a crosttabulation of mean,sd,n for a
continuous variable crossclassified by anoother/s grouping variables. I
came up with:
xtab2 <- function(x,g1,g2) {
funy <- function(z)
list(mean(z,na.rm=T),sd(z,na.rm=T),length(z))
aa <- by(x,list(g1,g2),funy)
bb <- matrix(unlist(aa),nrow=3
,dimnames=list(c("mean","sd","n"),
2009 Apr 30
1
Hmisc: xYplot and panel.lines
...panel.abline(h=4.0, col = "grey") # works fine
panel.lines(-d$chosenValveSetting, col="orange") # in the wrong
place
}
xYplot(I(AmountInTank) + I(-UserOutFlow+UserInFlow) + I(EnvirInFlow) ~
Time.Step, data=subset(h, Version=="Linear increase"), nx=F,
method=smean.cl.boot, type='b',lty.bands=c(2,2), ylim=c(-20,20),
panel=pfunc)
What am I doing wrong?
Hmisc 3.6.0, but older versions reacted similarly.
Thanks for your help!
[1] http://tolstoy.newcastle.edu.au/R/help/06/01/18860.html
2008 Feb 18
2
Custom Plot - means, SD & 5th-95th% (Plotmeans or Boxplot)?
Any help with this problem would be greatly appreciated:
I need to produce a custom plot i haven't come across in R. Basically, I
want to show means, 1st standard deviation and 5th and 95th percentiles
visually, using something resembling a boxplot. Is it possible to completely
customize a boxplot so that it shows means as the bar (instead of, not as
well as medians), standard deviations at
2002 Jan 25
6
bootstrap: boot package
I'm teaching a class and using R for the first time. We're talking
about the bootstrap, and I've been trying to get R to replicate some
simple bootstrap programs with no success. I'd like to be able to use
the boot.ci function to produce confidence intervals (non-parametric)
for some simple statistics, and this requires first creating a "boot"
object. The boot
2005 Dec 01
8
Impaired boxplot functionality - mean instead of median
Hello to all users and wizards.
I am regulary using 'boxplot' function or its analogue - 'bwplot' from
the 'lattice' library. But they are, as far as I understand, totally
flawed in functionality: they miss ability to select what they would
draw 'in the middle' - median, mean. What the box means - standard
error, 90% or something else. What the whiskers mean -