[R] rlogis() in simulation

Hong Ooi Hong.Ooi at iag.com.au
Wed Nov 30 01:34:41 CET 2005


_______________________________________________________________________________________


Well, first the variance of a logistic distribution with scale parameter
s is not s^2, but (pi^2 * s^2)/3 (see ?rlogis). So if you want the
distribution to have a variance of .25, this implies s should be about
sqrt(3*0.25)/pi ~ 0.27567.



-- 
Hong Ooi
Senior Research Analyst, IAG Limited
388 George St, Sydney NSW 2000
(02) 9292 1566

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Doran, Harold
Sent: Wednesday, 30 November 2005 7:53 AM
To: r-help at stat.math.ethz.ch
Subject: [R] rlogis() in simulation

Dear List:

We are generating data such that students are clustered in schools for
some item response data for a simulation study. One component of our
simulation is to generate measurement error from a logistic distribution
with a mean of 0 and standard deviation of 1.7 to match the logistic
curve of the Rasch model.

We are generating an error term for each of the 40 hypothetical test
items a student would respond to. So, we create 40 error terms for each
of the N students. This error term is a composite of a "school effect"
and a student-specific effect. The school effect is the variance term
common to all students in the school whereas the student effect varies
over N.

We want the variance of the school effect, e_gk, to be .25 and we want
the variance of the student-specific effect, e_gik, to be 1.7 - .25 =
1.45 so that the total variance sums to about 1.7.

Below is a self contained example of a small portion of the simulation.
However, I seem to misunderstand the scale and location parameters in
the rlogis function. Can anyone suggest how I might specify the variance
of the school effect to be .25 and for the student effect to be 1.45 as
I describe above? You can see my erroneous code below.

Thanks,
Harold


## Note, the subscripts are a little messy as I am changing some
notation. But it should be transparent (I hope)

N   <- 5000 # Number of students
J   <- 50   # Number of schools
N_j <- N/J  # Number of students in each school
rps  <- rep(N_j, J)

error <- matrix(numeric(N * 40), ncol = 40)
for(i in 1:40){
e_gik   <- rlogis(N, 0, sqrt(1.7-.25) ) 
e_gk    <- rep(rlogis(J, 0, sqrt(.25) ), rps) 
error[,i] <- e_gk + e_gik
}


Windows XP

platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    2              
minor    2.0            
year     2005           
month    10             
day      06             
svn rev  35749          
language R          

	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html



_______________________________________________________________________________________

The information transmitted in this message and its attachme...{{dropped}}




More information about the R-help mailing list