Displaying 20 results from an estimated 200 matches similar to: "help on setting boundaries for generating random numbers"
2005 Apr 14
4
data manipulation
Hello,
my question is about the data handling.
I have a data set that is lined as:
4 1 17 1 1
-5.1536 -0.1668 -2.3412 -0.5062 0.9621 0.3640 0.3678 -0.5081 -0.2227
0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232 0.8673 -0.1033 -0.0796
-0.0341 -0.1716 -0.1801 -0.7014 0.6578 0.5611
4 1 17 2 1
-5.1536 -0.1668 -2.3412 -0.5062 0.9621 0.3640 0.3678 -0.5081 -0.2227
0.8142 -0.0389 -0.0445
2005 Jan 07
3
lognorm
Hi!
I 've a problem to have a lognorm distribution with
mean=1 and var (or sigma)=1.
rlnorm(1000,0,0)
rlnorm(1000,1,1)
rlnorm(1000,0,1)
.... ?
Can you help me?
2001 Dec 17
1
behavior of r* and d* functions at boundaries (PR#1218)
(Sent this to r-help back in October, got no comments, forgot
to re-submit it as a bug report.)
There are a few inconsistencies, at least, in some of the functions that
generate random deviates from particular distributions (I think they're
bugs because they're inconvenient, but maybe someone can make an argument
for the current behavior). If people think these are really bugs I can
2004 May 01
2
Generating Lognormal Random variables (PR#6843)
Full_Name: Anthony Gichangi
Version: 1.90
OS: Windows XP Pro
Submission from: (NULL) (130.225.131.206)
The function rlnorm generates negative values for lognormal distribution.
x- rlnorm(1000, meanlog = 0.6931472, sdlog = 1)
Regards
Anthony
2009 Feb 11
3
Generating Numbers With Certain Distribution in R
Dear all,
Is there a way to generate K numbers of integer (K = 10^6).
The maximum value of the integer is 200,000 and minimum is 1.
And the occurrences of this integer follows
a lognormal distribution.
- Gundala Viswanath
Jakarta - Indonesia
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
2008 Feb 20
3
reshaping data frame
Dear all,
I'm having a few problems trying to reshape a data frame. I tried with
reshape{stats} and melt{reshape} but I was missing something. Any help is
very welcome. Please find details below:
#################################
# data in its original shape:
indiv <- rep(c("A","B"),c(10,10))
level.1 <- rpois(20, lambda=3)
covar.1 <- rlnorm(20, 3, 1)
level.2
2008 May 04
1
Is my understanding of rlnorm correct?
rlnorm takes two 'shaping' parameters: meanlog and sdlog.
meanlog would appear from the documentation to be the log of the mean.
eg if the desired mean is 1 then meanlog=0.
So to generate random values that fit a lognormal distribution I would
do this:
rlnorm(N , meanlog = log(mean) , sdlog = log(sd))
But when I check the mean I don't get it when sdlog>0. Interestingly I
2013 May 10
1
rlnorm(n, meanlog = 0, sdlog = 1)
Hi list,
Does anyone know the code behind rlnorm(n, meanlog = 0, sdlog = 1)? I am
going to write it in c#.
thanks
Alireza
[[alternative HTML version deleted]]
2005 Jun 29
2
MLE with optim
Hello,
I tried to fit a lognormal distribution by using optim. But sadly the output
seems to be incorrect.
Who can tell me where the "bug" is?
test = rlnorm(100,5,3)
logL = function(parm, x,...) -sum(log(dlnorm(x,parm,...)))
start = list(meanlog=5, sdlog=3)
optim(start,logL,x=test)$par
Carsten.
[[alternative HTML version deleted]]
2009 Jul 20
3
Histograms on a log scale
Dear All,
I would like to be able to plot histograms/densities on a semi-log or
log-log scale.
I found several suggestions online
http://tolstoy.newcastle.edu.au/R/help/05/09/12044.html
https://stat.ethz.ch/pipermail/r-help/2002-June/022295.html
http://www.harding.edu/fmccown/R/#histograms
Now, consider the code snippet taken from
http://www.harding.edu/fmccown/R/#histograms
# Get a random
2012 May 16
3
finding mean and SD for a log-normal distribution
Dear R Expert
allow me to ask a quick qestion: I have a mean value of 6 and a SD of 3 describing my distribution. I would like to "convert" this distribution into a log normal distribution that would best describe it when resimulated using log normal distribution. Currently I am using another software to estimate the respective mean and SD on the log scale and the results are: 1.6667
2012 Oct 11
2
Help on probability distribution question
Dear All,
I have a questions I would like to ask about and wonder if you have any thoughts to make it work in R.
1. I work in the field of medicine where physiologic variables are often simulated, and they can not have negative values. Most often the assumption is made to simulate this parameters with a normal distribution but in the "log-domain" to avoid from negative values to be
2009 May 20
1
sem with categorical data
I am trying to run a confirmatory factor analysis using the SEM package. My
data are ordinal. I have read
http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf.
When I apply the hetcor function, I receive the following error:
Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr = corr,
:
at least one element of 'lower' is larger than 'upper'
Example:
2012 Nov 29
1
instrumental variables regression using ivreg (AER) or tsls (sem)
Dear friends,
I am trying to understand and implement instrumental variables
regression using R.
I found a small (simple) example here which purportedly illustrates the
mechanics (using 2-stage least-squares):
http://www.r-bloggers.com/a-simple-instrumental-variables-problem/
Basically, here are the R commands (reproducible example) from that
site:
# ------ begin R
library(AER)
2012 Oct 30
6
standard error for quantile
Dear all
I have a question about quantiles standard error, partly practical
partly theoretical. I know that
x<-rlnorm(100000, log(200), log(2))
quantile(x, c(.10,.5,.99))
computes quantiles but I would like to know if there is any function to
find standard error (or any dispersion measure) of these estimated
values.
And here is a theoretical one. I feel that when I compute median from
given
2013 Mar 18
2
Fit a mixture of lognormal and normal distributions
Hello
I am trying to find an automated way of fitting a mixture of normal and log-normal distributions to data which is clearly bimodal.
Here's a simulated example:
x.1<-rnorm(6000, 2.4, 0.6)x.2<-rlnorm(10000, 1.3,0.1)X<-c(x.1, x.2)
hist(X,100,freq=FALSE, ylim=c(0,1.5))lines(density(x.1), lty=2, lwd=2)lines(density(x.2), lty=2, lwd=2)lines(density(X), lty=4)
Currently i am using
2009 Aug 26
2
Statistical question about logistic regression simulation
Hi R help list
I'm simulating logistic regression data with a specified odds ratio
(beta) and have a problem/unexpected behaviour that occurs.
The datasets includes a lognormal exposure and diseased and healthy
subjects.
Here is my loop:
ors <- vector()
for(i in 1:200){
# First, I create a vector with a lognormally distributed exposure:
n <- 10000 # number of study subjects
2010 Jul 13
1
Batch file export
Dear all,
I have a code that generates data vectors within R. For example assume:
z <- rlnorm(1000, meanlog = 0, sdlog = 1)
Every time a vector has been generated I would like to export it into a csv
file. So my idea is something as follows:
for (i in 1:100) {
z <- rlnorm(1000, meanlog = 0, sdlog = 1)
write.csv(z, "c:/z_i.csv")
Where "z_i.csv" is a filename that is
2002 Jun 12
1
confidence intervals
Hello,
I wonder if anyone has a function for calculating confidence intervals for
ratios. I have mortality rates calculated for several groups from sample
data -- but these can be treated as ratios?). I am entertaining the idea of
bootstrapping them.
Any help would be greatly appreciated.
TIA, Marwan
----------------------------------------------------------------------------
------------