Displaying 20 results from an estimated 93862 matches for "mean".
Did you mean:
means
2005 Nov 30
8
Solving Systems of Non-linear equations
I am trying to write a function that will solve a simple system of
nonlinear equations for the parameters that describe the beta
distribution (a,b) given the mean and variance.
mean = a/(a+b)
variance = (a*b)/(((a+b)^2) * (a+b+1))
Any help as to where to start would be welcome.
--
Scott Story
Graduate Student
MSU Ecology Department
319 Lewis Hall
Bozeman, Mt 59717
406.994.2670
sstory at montana.edu
2009 Aug 24
1
how to add 95% confidential interval as vertical lines to x axe in density plot
...ork, but I do not know
how to handle functions of this library when I used ggplot2 to draw the graph.
Thank you in advance.
The data and codes followed:
# dummy data
factor<-rep(c("Alice","Jone","Mike"),each=100)
factor<-factor(factor)
traits1<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))
traits2<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))
traits3<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))
traits4<-c(rnorm(100, mean=1, sd=1), rnorm(100, me...
2009 Aug 21
0
how to plot 95% confidential interval as vertical lines to x axe in density plot
...ork, but I do not know
how to handle functions of this library when I used ggplot2 to draw the graph.
Thank you in advance.
The data and codes followed:
# dummy data
factor<-rep(c("Alice","Jone","Mike"),each=100)
factor<-factor(factor)
traits1<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))
traits2<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))
traits3<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))
traits4<-c(rnorm(100, mean=1, sd=1), rnorm(100, me...
2010 Jun 09
4
question about "mean"
Hi there:
I have a question about generating mean value of a data.frame. Take
iris data for example, if I have a data.frame looking like the following:
---------------------
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4
0.2 setosa
2 4.9...
2011 Oct 18
1
Repeat a loop until...
...ars about loops but I'm afraid that I'm still stuck. I am using Windows XP and R 2.9.2.
I am generating some data using the multivariate normal distribution (within the 'mnormt' package). [The numerical values of sanad and covmat are not important.]
> datamat <- rmnorm(n=1500,mean=c(mean(sanad[,1]),mean(sanad[,2]),mean(sanad[,3])),varcov=covmat)
The middle column of 'datamat' is simulated data for age. Obviously some of the simulated values are not going to be sensible. Therefore I'd like to set up a function that looks at each row of 'datamat' and if...
2006 Oct 27
3
Marginal Effect larger than 1 for a binary variable (summary.Design after lrm)
...prevRP + owning + adv_binc_ratio * (repmethIO + repmethSR +
no_dis_no_def + prevLO + prevOO + prevRP + owning) + agem1 *
(repmethIO + repmethSR + no_dis_no_def + prevLO + prevOO +
prevRP + owning), data = a)
This is part of my result:
> summary(resultt1,adv_binc_ratio=mean(a$adv_binc_ratio),agem1=mean(a
$agem1),repmethIO=c(0,mean(a$repmethIO),1),repmethSR=c(0,mean(a
$repmethSR),1),no_dis_no_def=c(0,mean(a$no_dis_no_def),1),prevLO=c
(0,mean(a$prevLO),1),prevOO=c(0,mean(a$prevOO),1),prevRP=c(0,mean(a
$prevRP),1),regEA=c(0,mean(a$regEA),1),regEM=mean(a$regEM),regGL=...
2009 Apr 14
1
mean fold change issues and p values
I am new to R and have two scripts written slightly different but should to relatively the same thing but my lack of experience with the program I can not figure out the what I need to do to correct it. The first script gives me a consistent mean fold change values with every run but can generate negative p values for some. For the second version of the script, the fold changes seem to be very random but the p values do not go negative. I have highlighted the differences in the script that I noticed. I am think some combination of these...
2016 Apr 14
4
Bug in by() function which works for some FUN argument and does not work for others
Dear Sirs,
I am Professor at Indira Gandhi Krishi Vishwavidyalaya, Raipur,
Chhattisgarh, India.
While taking classes, I found the *by() *function producing following error
when I use FUN=mean or median and some other functions, however,
FUN=summary works.
Given below is the output of the example I used on a built-in dataset
"mtcars", along with error message reproduced herewith:
> by(data=mtcars, INDICES=list(mtcars$am), FUN=mean)
: 0
[1] NA
------------------------------...
2010 May 26
2
How to calculate mean of means
I have 3 columns of numbers, and i want to find the mean of each
separately, and then the mean of all of the means.
ive tried:
av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3))
av3daysB
but it only gives me the mean of the first column (avr1)
Any suggestions?
Thanks,
Emilija
2024 Mar 26
2
Printout and saved results
...utine first return "out" and the printout gets printed, but not
saved.
I then run the "invisible" line. Results got saved and accessible but no
printout.
How can I have both printout and also have the results saved? Thank you!
> dstat4 <- function(data,digits=3){
+?? Mean??? <- apply(data,2,mean,na.rm=TRUE)
+?? Std.dev <- apply(data,2,sd,? na.rm=TRUE)
+?? Min <- apply(data,2,min,na.rm=TRUE)
+?? Max <- apply(data,2,max,na.rm=TRUE)
+?? Obs <- dim(data)[1]
+?? out <-round(cbind(Mean,Std.dev,Min,Max,Obs),digits)
+?? out
+ # invisible(list(Mean=Mean,Std...
1999 Nov 24
1
Need help..
Dear All,
I am trying to generate some Pareto random variates
using the inverse method. This is really straightfoward
and my R function looks as below :
pareto <- function(c, a, cnt=1000)
{
u <- runif(cnt)
x <- (c / ((u ^ (1 / a))))
mean.theo <- ((c * a) / (a - 1))
mean.gen <- mean(x)
cat('Pareto mean : theoritical', mean.theo,
'generated', mean.gen, '\n')
return(x)
}
I am also giving the outputs below to illustrate my
point. I understand the point that as 'a' is less
than 2.0, the var...
2020 Sep 21
2
Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"
Hello everyone,
I am using *mlogit* to analyse my choice experiment data. I have *3
alternatives* for each individual and for each individual I have *9
questions*. I have a response from *516 individuals*. So it is a panel of
9*516 observations. I have arranged the data in long format (it contains
100 columns indicating different variables and identifiers).
In mlogit I tried the following
2016 Apr 15
4
Bug in by() function which works for some FUN argument and does not work for others
...5,
of a famous book "R by Example" written by "Jim Albert and Maria Rizzo"
published in Springers (2012) in a Use R! Series. The output of the by()
function printed in the book is being reproduced below for information to
all:
> by(data=brain[, -1], INDICES=brain$Gender, FUN=mean, na.rm=TRUE)
brain$Gender: Female
FSIQ VIQ PIQ Weight Height MRI_Count
111.900 109.450 110.450 137.200 65.765 862654.600
------------------------------------------------------------
brain$Gender: Male
FSIQ VIQ PIQ Weight Height MRI_Count
115.00000 115.25000 111.60000 166.44444 71.431...
2005 Aug 04
1
Where the error message comes from?
Hi all:
I get the following error message that I am not able to resolve.
Error in if (const(t, min(1e-08, mean(t)/1e+06))) { :
missing value where TRUE/FALSE needed
It appears right before the last data.frame statement.
Below is the program that simulates data from one way random effects
model and then computes normality and bootstrap confidence interval for
Cost-Effectiveness Ratio....
2011 Sep 15
1
Questions on 'lme' function, urgent!
...an expression level different between any
two of the tissue types, how many of them have an expression level unique to
only one tissue (i.e., gene20 is expressed at a very low level (0.1) in
Liver, but expressed at the same level (~0.7) across all the other tissue
types).
So my hypotheses are:
H0: Mean(B)=Mean(L)=Mean(K)=Mean(H)
H1: Mean(B)?Mean(L)=Mean(K)=Mean(H) or Mean(L)?Mean(B)=Mean(K)=Mean(H) or
Mean(K)?Mean(B)=Mean(L)=Mean(H) or Mean(H)?Mean(B)=Mean(K)=Mean(L)
H2: Mean(B)?Mean(L)?Mean(K)?Mean(H)
In my analysis, the gene expression level is the dependent value (Y), the
tissue-typ...
2008 Feb 21
1
anova power calculations
...ly
appreciated.
I'm working now on a similar problem, but instead of a balanced ANOVA, I
have an unbalanced one. The first part of the question was:
You assume that the within-population standard deviations all equal 9. You
set the Type 1 error rate at รก = .05. You presume that the population means
will have the following values: uA = 17.5, uB = 19, uC = 25, and uD = 20.5.
You intend to run 80 subjects in all, with equal n's across all 4 groups.
You plan on conducting a one-way ANOVA. Compute your power to reject the
null hypothesis under these conditions.
I did:
within.var = 9 ^ 2
mea...
2009 Jul 07
2
Multiplication of data frame with vector
...55372 58012 55546 57309
M336T90 11063 10312 10674 10840 11208
M427T91 12064 11956 12692 12340 11924
M429T91 4594 3890 4096 4019 4204
M447T90 26553 27647 26889 26751 26929
Now I'm trying to transform each value column-wise to make columns to all have the same mean with:
df * mean(mean(df)) / mean(df).
I just can't get my head around this: mean(df) gives me the correct column means vector, and mean(mean(df)) gives me the correct total mean. The above operation works correctly for individual rows, i.e. if I do
df[1,]*mean(mean(df))/mean(df)
Can someone...
2003 May 28
1
Numbers that look equal, should be equal, but if() doesn't see as equal (repost with code included)
...ns is smaller than 2. Nothing to split, exiting.");
}
if ( length(data) < 2 )
{
stop("The length of the data is really short. Is that ok?");
}
if ( bins * n != length(data) )
{
stop("Cannot construct bins of equal length.");
}
t(array(data, c(n,bins)));
}
mean.bins <- function(data)
{
# For the vincentizing procedures in vincentize() and binify(),
# it made sense to check the data array/vector/matrix. Here,
# we now just need to check that data is a matrix.
if ( !is.matrix(data) )
{
stop("The data is not in matrix form.");
}
means...
2009 Mar 10
6
Pseudo-random numbers between two numbers
I would like to generate pseudo-random numbers between two numbers using
R, up to a given distribution,
for instance, rnorm.
That is something like rnorm(HowMany,Min,Max,mean,sd) over
rnorm(HowMany,mean,sd).
I am wondering if
dnorm(runif(HowMany, Min, Max), mean, sd)
is good. Any idea? Thanks.
-james
2017 Sep 09
2
Avoid duplication in dplyr::summarise
...e a single summarise function that could be
applied to both. My attempt below fails.
df <- data.frame(matrix(rnorm(40), 10, 4),
f1 = gl(3, 10, labels = letters[1:3]),
f2 = gl(3, 10, labels = letters[4:6]))
df %>%
group_by(f1, f2) %>%
summarise(x1m = mean(X1),
x2m = mean(X2),
x3m = mean(X3),
x4m = mean(X4))
df %>%
group_by(f1) %>%
summarise(x1m = mean(X1),
x2m = mean(X2),
x3m = mean(X3),
x4m = mean(X4))
# My fail attempt
s <- function() {
dplyr::summarise(x1m =...