Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: mixed effects fractional polynomial
From
"William Johnson" <[email protected]>
To
<[email protected]>
Subject
st: mixed effects fractional polynomial
Date
Wed, 18 Jan 2012 14:26:41 -0600
I am using the code at the end of this post to fit a two degree mixed
effects fractional polynomial model.
I can?t get the code to allow ONLY the first degree to have mixed effects.
My thought was that (names) should be replaced with (p1) on the random
effects side of the xtmixed code, because the power combinations that
fracpolypowers creates are called r(p1) and r(p2), but this doesn't work.
Does anyone have any suggestions?
// Store FP2 powers in local macros
fracpoly_powers, degree(2)
local np = r(np)
forvalues j = 1 / `np' {
local p`j' `r(p`j')'
}
// Compute deviance for each FP model with covariate age
gen x = age
gen y = bmi
local devmin 1e30
forvalues j = 1 / `np' {
qui fracgen x `p`j'', replace adjust(mean)
qui xtmixed y `r(names)' || id: `r(names)',
covariance(unstructured) mle
local dev = -2 * e(ll)
if `dev' < `devmin' {
local p `p`j''
local devmin `dev'
}
di "powers = `p`j''" _col(20) " deviance = " %9.3f `dev'
}
di _n "Best model has powers `p', deviance = " `devmin'
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/