[R-sig-ME] MCMCglmm Starting Value structure

Jarrod Hadfield j.hadfield at ed.ac.uk
Sat Oct 6 23:36:36 CEST 2012


Hi,

Sorry - I should have a more useful error message. Th argument to tune  
needs to be a matrix.

Cheers,

Jarrod


Quoting Robin Jeffries <rjeffries at ucla.edu> on Fri, 5 Oct 2012 13:28:55 -0700:

> I am encountering the same problem of defining the starting values,
> yet for a different model. I am running a survival model with no
> random effects on n subjects.
>
> run1 <- MCMCglmm(cbind(low, up) ~ var1 + var2,
>               family="cengaussian", data=sex,
>               nitt=2100, thin=5, burnin=100,
>               prior = prior1, tune=NULL, pl=TRUE)
>
> prior1 <- list(R = list(V=1, n=0.002),
>                        B = list(mu=rep(0,2), V=prior.var))
>
> Since I have no random effects, there is no G matrix and  the
> liabilities are just a single vector with a scalar variance.
> So for example, say I want to start the liabilities at 1
> prop.mean <- as.matrix(rep(1,n))
> and a prior variance
> prop.var <- 3
>
> If I don't provide starting value for my residuals, R,
> test2a <- MCMCglmm(cbind(low, up) ~ var1 + var2,
>                  family="cengaussian", data=sex,
>                  nitt=2100, thin=5, burnin=100,
>                  prior = prior1, tune=prop.var,
>                  start=list( liab=prop.mean, QUASI=FALSE),
>                  pl=TRUE)
>
> I get the error message: Error in if (dim(tune[[i]])[1] !=
> dim(tune[[i]])[2] | dim(tune[[i]])[2] !=  :
>   argument is of length zero
>
> Since R is a scalar, I tried to use the same structure as the prior
> run2b <- MCMCglmm(cbind(low, up) ~ var1 + var2,
>                  family="cengaussian", data=sex,
>                  nitt=2100, thin=5, burnin=100,
>                  prior = prior1, tune=prop.var,
>                  start=list(R=list(V=1),
>                             liab=prop.mean,
>                             QUASI=FALSE),
>                  pl=TRUE)
> but got the same dimension mis-match error.
>
> If i use the error term from run1  as starting values for R,
> run2c <- MCMCglmm(cbind(low, up) ~ var1 + var2,
>                  family="cengaussian", data=sex,
>                  nitt=2100, thin=5, burnin=100,
>                  prior = prior1, tune=prop.var,
>                  start=list(R=list(V=run1$error.term),
>                             liab=prop.mean,
>                             QUASI=FALSE),
>                  pl=TRUE)
>
> I get the error: Error in eigen(m, only.values = TRUE) :
>   (list) object cannot be coerced to type 'double'
>
> At this point I cannot decipher what it is I need to change to
> properly provide starting values.
>
> Thanks,
> -Robin
>
>
> On Tue, Jun 7, 2011 at 9:26 PM, Jarrod Hadfield <j.hadfield at ed.ac.uk> wrote:
>>
>> Hi,
>>
>> A bug has crept into MCMCglmm at some point when specifying starting
>> values. The correct syntax should be start2c for which you get an error
>> message. I will update as soon I have finished some of the other updates
>> I am working on. As a work around you can add another matrix to the G
>> element:
>>
>> start2c$G[[5]]<-diag(2)
>>
>> It will be ignored but will alow the code to run.
>>
>> Sorry,
>>
>> Jarrod
>>
>>
>>
>>
>>
>> On Tue, 2011-06-07 at 10:34 -0700, Robin Jeffries wrote:
>> > I am having some difficulty defining the correct structure for the
>> > starting values in MCMCglmm.
>> > Several prior google searches for examples of starting values for
>> > MCMCglmm resulted only in one unhelpful L-serv posting where the
>> > poster was subsequently told to RTM and quit posting. I hope that I
>> > show that I have spent time trying to find the answer on my own prior
>> > to posting.
>> >
>> >
>> > My prior structure is:
>> >
>> > prior1 = list(R = list(V = 1, nu = .002),
>> >   G = list(
>> >    G1 = list(V = diag(3), n=4),
>> >    G2 = list(V = diag(3), n=4),
>> >    G3 = list(V = 1, nu=1),
>> >    G4 = list(V = 1, nu=1)
>> > ))
>> >
>> >
>> > To set up starting values I first set Rc and Gc to be vectors of
>> > length 1 and 20 respectively. I then tried the starting value
>> > structure as
>> >
>> > start2a = list( R = Rc,
>> >   G = list(
>> >    G1 = Gc[1:9],
>> >    G2 = Gc[10:18],
>> >    G3 = Gc[19],
>> >    G4 = Gc[20]),
>> > QUASI=FALSE)
>> >
>> > which gives me the error "V is the wrong dimension for some
>> > startG/startR elements"
>> > So I tried to structure it exactly as the priors (with lists and  
>> matricies)
>> >
>> > start2b = list(R = list(V =Rc),
>> > G = list(
>> >  G1 = list(V = matrix(Gc[1:9], nrow=3, ncol=3)),
>> >  G2 = list(V = matrix(Gc[10:18], nrow=3, ncol=3)),
>> >  G3 = list(V = Gc[19]),
>> >  G4 = list(V = Gc[20])
>> > ))
>> >
>> > and got the same error message.
>> >
>> > Since the help file/notes/vignette says that "the starting values is a
>> > list of 4 possible elements, where G itself is also a list with as
>> > many elements as RE components" I tried a combination of the above
>> > two:
>> >
>> > start2c = list(
>> > R = Rc,
>> > G = list(
>> >  G1 = matrix(Gc[1:9], nrow=3, ncol=3),
>> >  G2 = matrix(Gc[10:18], nrow=3, ncol=3),
>> >  G3 = Gc[19],
>> >  G4 = Gc[20]),
>> > QUASI=FALSE)
>> >
>> > but then was greeted with the error "Error in start$G[[r]] : subscript
>> > out of bounds"
>> >
>> > If someone could help me out with what the structure of the starting
>> > values is supposed to look like, it would be appreciated.
>> >
>> >
>> > Robin Jeffries
>> > MS, DrPH Candidate
>> > Department of Biostatistics
>> > UCLA
>> > 530-633-STAT(7828)
>> >
>> > _______________________________________________
>> > R-sig-mixed-models at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>> >
>>
>>
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>
>



-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the R-sig-mixed-models mailing list