[R] Fit data to distribution

Muhammad Rahiz muhammad.rahiz at ouce.ox.ac.uk
Fri Jun 3 20:14:17 CEST 2011


Hi all,

I hope to get some assistance in this. I have two datasets, x and y. I'm 
trying to fit dataset y to the distribution of dataset x. I have the 
shape, and rate of the distribution of dataset x, but not it's scale.

x  <- abs(rnorm(21))
y  <- abs(rnorm(21))

plot(density(x))
lines(density(y),col="red")
legend("topright",legend=c("x","y"),col=c("black","red"),lty=1,bty="n")

x1 <- fitdistr(x,"gamma")$estimate 	# get scale and rate


-- 
Muhammad Rahiz



More information about the R-help mailing list