This is a multi-part message in MIME format.
--040502080208060001050807
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
1. It appears that "coef<-.varIdent" method does not work properly in
some instances.
Execution error:
Error in `coef<-.varIdent`(`*tmp*`, value = c(11, 12)) :
Cannot change the length of the varIdent parameter after
initialization
occurs when "coef<-.varIdent" is applied to an initialized object of
class varIdent with some of the coefficients being _fixed_.
Attached files: 'varIdentOrthoEmail.txt' and 'varIdentOrthoEmail.Rout'
illustrate the problem.
2. The code for "coef<-.varIdentX" method in
'varIdentmethodsRevised.txt' file illustrates how to fix this problem.
3. Specifically, to fix the problem the line
if (length(value) != nGroups - 1)
in the "coef<-.varIdent" method should be replaced
with the following two lines :
nFixed <- sum(as.numeric(attr(object,"whichFix"))) # inserted
new line
if (length(value) != nGroups - nFixed - 1) { #
modified original line
4. Note: Although I am using lme "3.1-80", the related problem PR#9765
is fixed manually by over-writing varIdent function.
Thank you
Andrzej Galecki
--040502080208060001050807
Content-Type: text/plain;
name="varIdentXOrthoEmail.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="varIdentXOrthoEmail.txt"
ls()
require(nlme)
sessionInfo()
## New class varIdentX and methods defined.
### coef<-.varIdentX illustrates how to fix a bug in coef<-.varIdent
# Note: PR#9765 fixed in varIdent() and varIdentX()
source("C:/temp/varIdentmethodsRevised.txt")
ls()
Chunk 1: Everything is OK here
# value= and fixed= arguments
# variance component at age=12 is fixed
val <- c("10"=1.10,"14"=1.14)
vf <- varIdent(value=val, form=~1|age, fixed=c("12"=1.12))
vfi <- Initialize(vf,Orthodont)
str(vfi)
coef(vfi)
coef(vfi, unconstrained = FALSE, allCoef = TRUE)
vfiCopy <- vfi# copy of an initialized object
Chunk 2: Bug in coef<-.varIdent illustrated
length(vfiCopy) # length is 2
coef(vfiCopy) <- c(11,12) # Execution error
# Error in `coef<-.varIdent`(`*tmp*`, value = c(11, 12)) :
#Cannot change the length of the varIdent parameter after initialization
Chunk 3: Consequently the same execution error in gls
gls.error <- gls(distance ~ age,
weights = vfi,
data=Orthodont)
#Error in `coef<-.varIdent`(`*tmp*`, value = c(0.095310179804325,
0.131028262406404 :
# Cannot change the length of the varIdent parameter after
initialization
### Chunk 1A:
val <- c("10"=1.10,"14"=1.14)
vf <- varIdentX(value=val, form=~1|age, fixed=c("12"=1.12))
vfi <- Initialize(vf,Orthodont)
str(vfi) # Note: class varIdentX
coef(vfi)
coef(vfi, unconstrained = FALSE, allCoef = TRUE)
vfiCopy <- vfi# copy of an initialized object
Chunk 2A: Bug in coef<-.varIdent *** corrected ***
length(vfiCopy) # length is 2
coef(vfiCopy) <- c(11,12) # NO Execution error
Chunk 3A: No execution error in gls
gls.noerror <- gls(distance ~ age,
weights = vfi,
data=Orthodont)
--040502080208060001050807
Content-Type: text/plain;
name="varIdentXOrthoEmail.Rout"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="varIdentXOrthoEmail.Rout"
> ls()
character(0)
> require(nlme)
Loading required package: nlme
[1] TRUE
> sessionInfo()
R version 2.5.0 (2007-04-23)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
other attached packages:
nlme
"3.1-80"
>
>
> ## New class varIdentX and methods defined.
> ### coef<-.varIdentX illustrates how to fix a bug in coef<-.varIdent
> # Note: PR#9765 fixed in varIdent() and varIdentX()
> source("C:/temp/varIdentmethodsRevised.txt")
> ls()
[1] "coef.varIdentX" "coef<-.varIdentX" "Initialize.varIdentX"
[4] "varIdent" "varIdentX"
>
>
>
> Chunk 1: Everything is OK here
> # value= and fixed= arguments
> # variance component at age=12 is fixed
>
> val <- c("10"=1.10,"14"=1.14)
> vf <- varIdent(value=val, form=~1|age, fixed=c("12"=1.12))
> vfi <- Initialize(vf,Orthodont)
> str(vfi)
Classes 'varIdent', 'varFunc' atomic [1:2] 0.0953 0.1310
..- attr(*, "groupNames")= chr [1:4] "8" "10" "14" "12"
..- attr(*, "fixed")= Named num 0.113
.. ..- attr(*, "names")= chr "12"
..- attr(*, "formula")=Class 'formula' length 2 ~1 | age
.. .. ..- attr(*, ".Environment")=
..- attr(*, "groups")= chr [1:108] "8" "10" "12" "14" ...
..- attr(*, "whichFix")= logi [1:3] FALSE FALSE