[R] add lowess predicted line to scatter plot

2012-09-24 Thread Maximilian Lklweryc
Hi, I have a scatter plot of the variables GNI and Lifeexp (Gross National Income and Life Expectancy, both metric). So I plotted them and I want to add a regression line and a lowess line. I use lowess and not loess because I have missing values. My code: plot(GNI,Lifeexp) abline(lm(Lifeexp~GNI),

[R] plotting 1000 simulations, error message: plot.new has not been called yet

2012-11-21 Thread Maximilian Lklweryc
Hi, I know this is not a mailing list for r, but I posted my question on several help pages and did not get any help. I really don't know how to solve my problem, maybe you could help me? want to simulate stock paths. I have simulated 1000 paths with 22 trading days (1 starting value). Now I want

[R] How to discretize the Variance Gamma Process for stock price simulation?

2012-11-24 Thread Maximilian Lklweryc
Hi, I want to do stock price simulation. First of all, I used the geometric brownian motion. To simulate the values, I used not the closed form solution for the GBM given by: S_t=S_0*exp[(μ−σ^2)t+σWt] but the discrete version, so I can "see" every day realization: S_i+1=μΔt∗S_i+σφΔt∗S_i+S_i No

[R] Variance gamma process simulation and plot

2012-11-25 Thread Maximilian Lklweryc
Hi, I have simulated one possible path of a variance gamma process by the following code: vektor<-c(1:23) S0=20 theta=0.01 v=5 sigma=0.1 vektor[1]<-S0 for (i in 2:23){ randomgamma<-rgamma(1, shape=1/v, scale = v) randomnormal<-rnorm(1,mean=0,sd=1) vektor[i]<-vektor[i-1]+theta*randomgamma+sigma*

[R] Plot 3d density

2012-11-28 Thread Maximilian Lklweryc
I want to create a 3d plot with densities. I use the function density to first create a 2d dimensional plot for specific x values, the function then creates the density and puts them into a y variable. Now I have a second set of x values and put it again into the density function and I get a secon