similar to: How to generate integers from uniform distribution with fixed mean

Displaying 20 results from an estimated 10000 matches similar to: "How to generate integers from uniform distribution with fixed mean"

2010 Jun 21
2
How to predict the mean and variance of the dependent variable after regression
Hi, folks, As seen in the following codes: x1=rlnorm(10) x2=rlnorm(10,mean=2) y=rlnorm(10,mean=10)### Fake dataset linmod=lm(log(y)~log(x1)+log(x2)) After the regression, I would like to know the mean of y. Since log(y) is normal and y is lognormal, I need to know the mean and variance of log(y) first. I tried mean (y) and mean(linmod), but either one is what I want. Any tips? Thanks in
2010 Jun 24
2
count data with a specific range
I would like to prepare the data for barplot. But I only have the data frame now. x1=rnorm(10,mean=2) x2=rnorm(20,mean=-1) x3=rnorm(15,mean=3) data=data.frame(x1,x2,x3) If there a way to put data within a specific range? The expected result is as follows: range x1 x2 x3 -10-0 2 5 1 (# points in this
2010 Jun 22
2
Verify the linear regression model used in R ( fundamental theory)
Hi, folks, As I understand, Least-squares Estimate (second-moment assumption) and the Method of Maximum Likelihood (full distribtuion assumption) are used for linear regression. I do >?lm, but the help file does not tell me the model employed in R. But in the book 'Introductory Statistics with R', it indicates R estimate the parameters using the method of Least-squares. However it
2012 Aug 29
3
Help on calculating spearman rank correlation for a data frame with conditions
Dear all, Suppose my data frame is as follows: id price distance 1 2 4 1 3 5 ... 2 4 8 2 5 9 ... n 3 7 n 8 9 I would like to calculate the rank-order correlation between price and distance for each id. cor(price,distance,method = "spearman") calculate a correlation for all. Then I tried to use apply(data,list='id',cor(price , distance , method =
2010 Jul 21
2
Variance of the prediction in the linear regression model (Theory and programming)
Hi, folks, Here are the codes: ############## y=1:10 x=c(1:9,1) lin=lm(log(y)~x) ### log(y) is following Normal distribution x=5:14 prediction=predict(lin,newdata=x) ##prediction=predict(lin) ############### 1. The codes do not work, and give the error message: Error in eval(predvars, data, env) : numeric 'envir' arg not of length one. But if I use the code after the pound sign, it
2010 Nov 06
1
How to generate multivariate uniform distribution random numbers?
I wish to generate 100 by 1 vector of x1 and x2 both are uniform distributed with covariance matrix \Sigma. Thanks, Michael [[alternative HTML version deleted]]
2010 Jun 23
1
How to 'understand' R functions besides reading R codes
Apologize for not being clearer earlier. I would like to ask again. Thank Joris and Markleeds for response. Two examples: 1. Function 'var'. In R, it is the sum of square divided by (n-1) but not by n. (I know this in R class) 2. Function 'lm'. In R, it is the residual sum of square divied by (n-2) not by n, the same as in the least squares estimate. But the assumption following
2010 Jun 18
1
How to calculate the robust standard error of the dependent variable
Hi, folks linmod=y~x+z summary(linmod) The summary of linmod shows the standard error of the coefficients. How can we get the sd of y and the robust standard errors in R? Thanks! [[alternative HTML version deleted]]
2010 Jun 26
1
All a column to a data frame with a specific condition
Hi, folks, Please first look at the codes: plan_a=c('apple','orange','apple','apple','pear','bread') plan_b=c('bread','bread','orange','bread','bread','yogurt') value=1:6 data=data.frame(plan_a,plan_b,value) library(plyr) library(reshape) mm=melt(data, id=c('plan_a','plan_b'))
2010 Jul 02
2
how to save summary(lm) and anova (lm) in format?
Hi, folks, I would like to copy the output of summary(lm) and anova (lm) in R to my word file. But the output will be a mess if I just copy after I call summary and anova. ##################### x=rnorm(10) y=rnorm(10,mean=3) lm=lm(y~x) summary(lm) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -1.278567 -0.312017 0.001938 0.297578 1.310113
2010 Jun 25
2
Delete rows in the data frame by limiting values in two columns
Hi, folks, Finally Friday~~ Here comes the question: x=c('germany','poor italy','usa','england','poor italy','japan') y=c('Spain','germany','usa','brazil','england','chile') s=1:6 z=3:8 test=data.frame(x,y,s,z) #Now I only concern the countries ('germany','england','brazil').
2010 Sep 08
3
Uniform Distribution
Hello, I would like to uniformly distribute values from 0 to 200. Can someone help me find the appropriate uniform distribution generator? I would like to thank you in advance for your help. Best Regards Alex [[alternative HTML version deleted]]
2013 Oct 08
3
Latin Hypercube Sample and transformation to uniformly distributed integers or classes
Hi, I'd like to use Latin Hypercube Sampling (LHC) in the the context of uncertainty / sensitivity analysis of a complex model with approximately 10 input variables. With the LHC approach I'd like to generate parameter combinations for my model input variables. Therefore I came across an simple example here on the mailing list (
2011 Jun 02
4
generating random covariance matrices (with a uniform distribution of correlations)
List members, Via searches I've seen similar discussion of this topic but have not seen resolution of the particular issue I am experiencing. If my search on this topic failed, I apologize for the redundancy. I am attempting to generate random covariance matrices but would like the corresponding correlations to be uniformly distributed between -1 and 1. The approach I have been using is:
2012 Nov 07
6
how to generate a set of random numbers that sum to 1 with uniform distribution of elements
Hi, I am looking for a way to generate a matrix of random numbers in a way that each row of the matrix would sum to 1 and that the numbers in the columns of the matrix would have a uniform distribution. So far I have found several ways to create random numbers that would sum to 1, but then the distribution of the individual elements is more or less skewed - there are much more small numbers than
2010 Sep 04
0
How to generate integers from uniform distribution with
On 04-Sep-10 19:27:54, Yi wrote: > Enh, I see. > It totally makes sense. > Thank you for your perfect explanation. > Enjoy the long weekend~ > Yi You're welcome! Earlier I tried an experiment with rejection sampling, which seems to work well for the case where you want mean of the sampled values to exactly be the mean of the range being sampled from. The number of tries, even
2007 Dec 07
1
how to generate uniformly distributed random integers
I'm a beginner of R. I can use runif() to generate uniformly distributed numbers, but I don't know which function can generate uniformly distributed random integers, or what kind of method do? Thanks! -- View this message in context: http://www.nabble.com/how-to-generate-uniformly-distributed-random-integers-tf4960778.html#a14208376 Sent from the R help mailing list archive at
2010 Jun 29
3
How to delete the replicate rows by summing up the numeric columns
Hi, folks, I am sorry that I did not state the problem correctly yesterday. Please let me address the problem by the following codes: first=c('u','b','e','k','j','c','u','f','c','e')
2005 Jul 01
5
Generating correlated data from uniform distribution
Dear R users, I want to generate two random variables (X1, X2) from uniform distribution (-0.5, 0.5) with a specified correlation coefficient r. Does anyone know how to do it in R? Many thanks! Menghui
2006 Oct 09
2
How to generate the random numbers uniformly distributed on the unit disc?
Hi, I want to get random number which is uniformly distributed on the unit disc. How can I do that with R? Best wishes, WAN WAN [[alternative HTML version deleted]]