Page 1 of 1

simulation: creating panels

Posted: Wed Apr 09, 2014 2:06 pm
by randal_verbrugge
RATS does not like me to do this, although it seems to be implied as OK in UG 394:

calendar(panelobs=14,a) 2001:1
allocate 3000//2014:1

dec vector[series] age(3000)
dec vector[series] rooms(3000)
do i=1,3000
compute tempage = fix(%uniform(1,99)) ; *initial age = 1,...,99, uniform.
compute temproom = fix(%uniform(4,14)) ; *generates rooms 4 to 13
set rooms(i) = temproom ;*IT IS FINE with this. :D
compute age(i//1) = tempage ;*HERE is where it complains about mixed data types or something. :evil:
do j=2,14
compute age(i//j) = age(i//j-1) + 1 ;*HERE is where it complains about mixed data types or something. :evil:
end do j
end do i

even if I work around this using a command like

set age 1 3000//14 = 0.0

which allows me to execute

compute age(i//1) = tempage ... and the rest of the commands in that block,

I run into problems when I later try to:

do i=1,3000
compute lrent(i//1) = 7.5 +.02*rooms(i//1) + .2*quality(i//1) - .005*age(i//1) ;*HERE is where it complains :evil:
do j=2,14
if (age(i//j).le.10) {
compute lrent(i//j) = lrent(i//j-1) - .005 - BRI(i//j)*.002
}
else {
compute lrent(i//j) = lrent(i//j-1) + .0015 -
}
end do j

Thanks,
Randy

Re: simulation: creating panels

Posted: Wed Apr 09, 2014 2:52 pm
by TomDoan

Code: Select all

calendar(panelobs=14,a) 2001:1
allocate 3000//2014:1

dec vector[series] age(3000)
dec vector[series] rooms(3000)
What are AGE and ROOMS supposed to be? As you've defined this at this point, they will each have 3000 series with 3000 individuals and 14 observations.

It looks like this is what you want:

Code: Select all

calendar(panelobs=14,a) 2001:1
allocate 3000//2014:1
dec vect initage(3000)
dec vect initrooms(3000)
ewise initage(i)=%RANINTEGER(1,99)
ewise initrooms(i)=%raninteger(4,14)
set age = initage(%indiv(t))+(%period(t)-1)
set rooms = initroots(%indiv(t))

Re: simulation: creating panels

Posted: Thu Apr 10, 2014 10:05 am
by randal_verbrugge
Thanks very much!