Showing posts with label curve. Show all posts
Showing posts with label curve. Show all posts

Friday, May 3, 2013

RG#104: Rootogram plot

require(latticeExtra)
require(lattice)


library(lattice)
set.seed(1234)
x1 <- rpois(1000, lambda = 25)


plt <- rootogram(~x1, dfun = function(x) dpois(x, lambda = 25))
plt 

 
 

Sunday, April 7, 2013

RG#21: Plotting curves (any formula, normal density )

#Example:
 curve(x^2, col = "red")

curve(x^3-x+1.5,from=-10,to=10,lty=2, col = "blue")
 # normal curve
x=seq(-50,150,length=1000)
set.seed(1234)
y=dnorm(x,mean=50,sd=30)
plot(x,y,type="l",lwd=2,col="red")

# add one or more curves
curve(x^2-1, col = "green2")
curve(x^2-5*x, -2.5, 2.5, add = TRUE, col = "red")

 
# add curves to scatter plot
# xyscatter plot
set.seed(1234)
x = c(0.1, 0.2, 0.3, 0.4, 0.5)
y = (-0.5*log (1-(2*x)) + rnorm(length (x), 0.2, 0.1))
plot(x,y, col = "red",  pch = 18)
 
curve(-0.5*log (1-(2*x)),from=0,to=0.5, lty=2,   col = "blue", add = TRUE)
 
 
 
 

 

Friday, April 5, 2013

RG#9: Drawing basic normal curve

# data
# generate 600 numbers in sequence between -4 to 4
x <- seq(-4, 4, length=600)
# calculate normal density
ds <- dnorm(x)


# plot
plot(x, ds, type="l", lty=1, col = 2, xlab="x value", ylab="Density", main="standarized normal distribution curve")