# simulate data for different sample size with same parameter

all,

I'm trying to simulate data for different sample size (let say n= 10,20, and 30). At the same time, i need the parameter (in my case are skewness and kurtosis) for the data for each n is the same. How can i do it in R.

I already tried do like this:

set.seed(100)
n<-10
true.skew<-0
true.kur<-3

library(PearsonDS)
e<-rpearson(n,moments=c(mean=0,variance=1, skewness=true.skew, kurtosis=true.kur))

library(moments)

skewness(e)
kurtosis(e)


and the result are:

>skewness(e)
[1] 0.2110712
> kurtosis(e)
[1] 1.950325
>


then i increase the sample size to n = 20,

set.seed(100)
n1<-20
true.skew<-0
true.kur<-3

library(PearsonDS)
e1<-rpearson(n1,moments=c(mean=0,variance=1, skewness=true.skew, kurtosis=true.kur))

library(moments)

skewness(e1)
kurtosis(e1)


output:

skewness(e1)
[1] 1.311147
> kurtosis(e1)
[1] 5.517818


the problems is, i got the different value of skewness and kurtosis.

Anybody can help me to do this?

Thank you.

• You want to make the sample skewness and kurtosis the same? If so, why? – Glen_b -Reinstate Monica Jan 25 '16 at 5:05
• Actually i want to compare the classical regression model and nonparametric regression (example: theil regression) with the same skewness and kurtosis. I need to know when the sample size increase/decrease (while the skewness and kurtosis remain the same) what will happend to model? – Nor Hisham Haron Jan 25 '16 at 5:44
• You perform each on the same set of samples, so you only need do have the population skewness/kurtosis be the same as you generate new simulated samples; the sample skewness and kurtosis (& every other sample statistic) would be the same automatically of course. The fact that for any one sample the skewness or kurtosis is some value or another value is purely the result of sampling variation around the population model; that's of no great import. – Glen_b -Reinstate Monica Jan 25 '16 at 7:06
• The usual approach would be something like: Generate a sample from a chosen population distribution with some given skewness and kurtosis, and compute your two lines, and repeat say ten thousand times at each sample size you're interested in. You can then compare the properties (e.g. variance or MSE of estimators) across whatever set of models you have in mind. $\:$ However, you can't generalize to different distributions with those same $\gamma_1$ and $\gamma_2$ values, since the behavior will vary across different distributions with the same low-order moments. – Glen_b -Reinstate Monica Jan 25 '16 at 7:13

Your problem may be small sample sizes.

For example, if I use n <- 1000 and the same seed then I get

> skewness(e)
[1] -0.04122395
> kurtosis(e)
[1] 3.026162


which are a lot closer to the preset population statistics of $0$ and $3$

It is unreasonable to expect that for a single small sample the sample skewness and kurtosis will be close to the population figure. Indeed the sample kurtosis seems to be biased down for small samples. Try this code:

library(PearsonDS)
library(moments)
set.seed(100)
n <- 10
cases <- 1000
true.skew <- 0
true.kur <- 3

em <- matrix(rpearson(n*cases,
moments=c(mean=0,variance=1, skewness=true.skew, kurtosis=true.kur)),
ncol=cases)

sk <- apply(em,2,skewness)
ku <- apply(em,2,kurtosis)
plot(sk,ku)


to give

and you would also get a smile or part of a smile sampling from other distributions.

If you want to compare different regression methods for small sample sizes, you should take many samples of the same size and see how the results vary.

• Hello Henry, actually i want to look on varies sample size. 10, 20, 30, 50, 100, 150. – Nor Hisham Haron Jan 25 '16 at 5:47
• @NorHishamHaron It is unreasonable to expect a sample to have the same skewness and kurtosis as the population. I have added a graph illustrating this – Henry Jan 25 '16 at 7:33